VS Code needle template snippet

To give class creation with needle engine a more “Unity” feeling I created a VS Code snippet to easily set up the class template boilerplate code. After copying that you can just type needle in a newly created typescript class and VS code will create the template code for you :slightly_smiling_face:

Code:

{
    "NeedleBehaviour": {
        "prefix": "needle",
        "body": ["import { Behaviour } from \"@needle-tools/engine\";\n", "export class ${1:ClassName} extends Behaviour {", "\tstart() {\n$0\n\t}", "\tupdate() {\n\n\t}", "}"],
        "description": "Empty Needle Behaviour template"
    }
}

image.png
image.png

Original Post on Discord

by user 474974683163394049

Setting up user snippes in VSC is pretty easy, just follow the screenshots and copy&paste the code :slightly_smiling_face:


image.png

by user 474974683163394049

by user 474974683163394049

That’s cool
Can such snippets be part of a workspace or does a user need to set that up manually?

You can btw in Unity rightclick an NpmDef and select Create > TypeScript to get a new script from our basic Behaviour template

You can rightclick anywhere in the project view in fact and it will create a typescript with a template in Unity - if its on an npmdef it will add it to your npmdef, if its somewhere else it will add it to src/scripts (and open it in both cases)

But having that in vscode is still cool and works cross apps then :slightly_smiling_face:

image.png

ahhhhh, ok didn’t see the Typescript menu item until now. Was too immersed in VS Code ^^ My workflow, most of the times, doesn’t involve switching between Unity and the devenv too often, so I’m used to work mainly from the devenv. But good to know, that it’s possible from within Unity too :slightly_smiling_face:

by user 474974683163394049

Yeah makes total sense :slightly_smiling_face: