therealjohn / UnityProjectTemplatesAndSnippets

An extension for VS 2019 that adds file templates and snippets for Unity projects
19 stars 9 forks source link

MonoBehaviour Editor script template #5

Closed hedgewizards closed 8 months ago

hedgewizards commented 2 years ago

The goal of this template is to create a CustomEditor script file to extend an existing MonoBehaviour Script.

this is a Rough, likely not working outline of this editor script. I'm having issues building on my machine: type or namespace 'EnvDTE' not found, type or namespace 'EnvDTE80', not found, and type or namespace 'Microsoft.VisualStudio' not found. Do I test this some other way than just pressing play? I'm happy to clean this up myself if I can get it working on my machine.

What Needs Work?

Should this be a snippet?

When I create an editor script, it is to extend an existing MonoBehaviour I already have. I don't know anything about how snippets work so I'm not sure if creating an external file is even possible, but it seems like it might be more intuitive, and could sidestep the above file naming confusion.

The other issue with using a snippet is specifying a file location to create that new file in. all editor scripts need to be in a subfolder named "Editor" somewhere in the tree, and different developers put "Editor" in different places. for example given the directory Assets/Scripts/Player/PlayerController.cs, do you create the editor script in Assets/Scripts/Player/Editor/PlayerControllerEditor.cs or in Assets/Scripts/Editor/Player/PlayerController.cs? I think it would be bad to automatically create the script in a specific directory the developer maybe doesn't even want. Is there a way to prompt for a file location when adding the snippet?