As our NinjaCamp project Bas and I decided on a cause a bit humbler than many of the other projects going on here: We just want to improve the workflow of creating a new script in Unity.
The current way to make a new behaviour for a GameObject in Unity is like this:
- Create the script in the desired folder.
- Rename the script.
- If it’s a C# script, rename the class to match the file name.
- Drag the script onto the GameObject.
With the solution we’re working on, you can instead just choose “New Script” from the Components menu, and you’ll get this:
This is a work in progress, but much of the base functionality is already there. While the window is open (which will float on top) you can optionally click any GameObject or Prefab to make the script be attached to that, and you can click any folder in the Project view to save the script in that folder. You can also pick which of the built-in callback functions you want included from the beginning (we only have four right now but we’ll add the others as well).
When you click “Create and Attach” the script will be created with the right file name and class name, compiled, and then added to your selected GameObject or Prefab if you chose one.
We’re also adding this partially related button:
The idea here is to just make it more obvious and simpler how to add a component to a GameObject – no need to reach for that menu anymore. And no, the button is not part of the AudioSource component, it’s below it and is still missing some style work and a separator line above it. It’s a work in progress!
We’re still missing more work on the script template building options, but I can already see that this thing will save me time in the future, if nothing else. ;)