Categories & Tags
Archive

NinjaCamp III: New Script Dialog

March 23, 2011 in Events, Technology by

Update: The Create Script Dialog is now on the Asset Store

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:

 

New Script Dialog 


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:

 

Add Component 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. ;)

Share this post

Comments (29)

Comments are closed.

23 Mar 2011, 10:43 am

Neat! That makes a very frequently used part of the workflow way more streamlined and self-explanatory. It also seems like something that can be designed, created and finished in a week, and deployed in a future release without much trouble. :)

John Morales
23 Mar 2011, 10:48 am

Great! The button should go in even if the script stuff can’t make it. But it all looks great!!

Please add Start() and Awake() function template checkboxes, too.

23 Mar 2011, 10:54 am

Great!

It’s exactly this kind of small keen polish which I love and helps so much more than big features, or shiny things.

23 Mar 2011, 11:12 am

Great to see the work flow is being improved.
I wonder what would be the options in the category list.

Martin Schultz
23 Mar 2011, 11:19 am

Excellent stuff. Seeing this makes me believe that the “eat your own dog food” does not get forgotten. Great, more of this kind of workflow enhancements!

Cameron
23 Mar 2011, 11:26 am

Neat, flow is everything in Unity. The button in the inspector is much better.
How about a tick box to place the { } on the next line? Braces on the end of the previous line confuse my students and drive me insane :)

Cameron
23 Mar 2011, 11:31 am

Also, the tiny flow aspects I think are really why people use Unity, not the big marketing bullet points (which are cool also obviously). I also don’t see much community involvement with those things as they tend to get overshadowed by big over the top requests. I write my little ideas here http://forum.unity3d.com/threads/51433-Small-efficiency-ideas

FierceForm
23 Mar 2011, 11:37 am

Please let us select if we want to put the brackets on the next line. I hate having to always format the script when I open it.

Ilsoap
23 Mar 2011, 12:25 pm

That’s a good idea FierceForm… I wouldn’t use that feature personally, but I know that some people just like that formatting better.

Great job, Unity team!

Sebastian
23 Mar 2011, 12:55 pm

yes, finally !

Jason Amstrad
23 Mar 2011, 1:37 pm

Now let’s just hope to hear from the AI team very soon.

23 Mar 2011, 3:04 pm

Give us an option to include “using System.Collections.Generic;” if we want to

stealthcold
23 Mar 2011, 3:06 pm

Good! =D

23 Mar 2011, 3:57 pm

reordering components please

23 Mar 2011, 3:59 pm

This is promissing, how about a search widget on top of that menu,
Workflow would then be:
click Add Component
type box
press enter
wam bam here comes a box collider

23 Mar 2011, 4:11 pm

You should add options for the lifespan of the object in the awake (dont destroy on load)

@require component

And the menu label

with those options it makes it more streamlined to not forget them ;)

Felix
23 Mar 2011, 4:15 pm

There could be a button to choose an existing script. This scripts includes (UnityEditor, Generics, …) and standard functions (Awake, Start, …) would then be taken and put into the new script. This would be a really nice way to have absolutely free templates – everyone could use it the way he wants. Like me – there would a handful of “template” scripts in the Inspector, and I could choose between them. Would in a lot of cases be much faster than copying the script, renaming, assigning to new object (together with your Create-and-Attach functionality). Cool idea!

23 Mar 2011, 4:41 pm

Cool! Anything to make our lives easier is wellcome.
That is a great idea and very intuitive way to create scripts form scratch.

¡Guys, think in more improvements like this one, please!(and get them to life)

Manon Seppen
23 Mar 2011, 5:54 pm

Material instancing would be very nice too.

Cameron
23 Mar 2011, 9:51 pm

Sounds like a fantastic idea. Nice work!

23 Mar 2011, 10:38 pm

if you can not work on templates so just let us choose an script to add it’s content to the new script. let users put all script templates in a folder in unity’s installation directory and choose from them in new script dialog.
change the formatting of { } please. it’s something really uncommon and unwanted!
i know that others said these 2 before but just want to tell it another time!

23 Mar 2011, 11:47 pm

Sweet! Ok we need an ETA now :P

TheLogan
24 Mar 2011, 4:30 am

Looks really good!
Perhaps you could add the ability to create a “standard template”?

Matt
26 Mar 2011, 6:27 am

Looks simple, clever and very useful. I like it a lot! :)

cannon
27 Mar 2011, 1:58 pm

Being able to select which functions to add will save me a lot of time hunting through the docs for which function definitions in MonoBehaviour have special meanings for Unity (no more asking myself, is it OnCollisionExit or OnCollisionLeave every couple of months). Great workflow improvement!

Fernando Zapata
28 Mar 2011, 11:41 am

I’ve been manually editing the NewBehaviour scripts in the Unity Application package (to add #pragma strict by default and match my coding conventions). But the problem is that after an upgrade they revert back to the Unity default version. I’d love to be able to set default templates that would not get lost between updates.

Cameron Bonde (Vectrex)
30 Mar 2011, 1:24 pm

“how about a search widget on top of that menu…type box, press enter, wam bam here comes a box collider”

That’s a great idea. I have loads of scripts sorted in folder etc which I know where they are and what they’re called. It’s slow to mess about popping open folders etc

31 Mar 2011, 12:29 am

very handy =)

Tim
31 Mar 2011, 1:10 pm

It would be nice to be able to select bracketing style (K&R / Allman) – I always change the brackets, first thing I do on every new class :-P

Some way of setting up a standard code template would be nice too – something that gets stored with the project so that it doesn’t get rewritten with each new Unity version, and you could use a different template with each new project if you liked.

Leave a Reply

Comments are closed.