In Unity, you create new scripts many times per day, and folders but there’s no keyboard shortcuts. I fixed this, and made the popup rather more intelligent than Unity’s built-in one. I’ve decided to make the basic version available for free here:
UPDATE: there’s a bug in the 1.0 version – it WILL NOT WORK if you set your Project window to 2-column layout. This is due to BUGS IN UNITY (not my code!). I have a workaround that’s in the Asset Store version, but is missing from the free version. I’ll patch it later
FreeIntelligentNew.dll – I’m not supporting this; it’s free: use at your own risk.
Or, for $2, you can get the latest version with full source code from Asset Store – I’m supporting + updating this.
Drag/drop the DLL into any folder named “Editor” in your project.
(required by Unity; this is how they make sure that Editor scripts aren’t accidentally included in your final game)
- Select the Project panel
- Hit shift-N
- By default, it intelligently guesses if you wanted a new Folder or a new Script. If it guessed wrong, hit “tab” to cycle through the options
- Choose a name and hit Enter (like normal in Unity). Done!
This works by peeking into some of Unity’s internals and detecting which EditorWindow has focus. If it’s the Project window, it uses some hardcoded constants (which differ between Unity versions, due to bugs they gradually fix, I think) to get the positions right, and offer you the popup.
I did it this way because Unity currently provides NO PUBLIC API for reproducing some of their core Editor features (e.g. where they temporarily change the render-style of the “newly-created item” in a Unity windowpane, so that you can edit the name in-line. Not possible for you or I!)
With a bit more hacking, I might be able to hook Unity’s own code and enable / trigger / alter the hidden features from keyboard, but … that’s on the wrong side of “Fragile; would probably break unexpectedly in a future version”.
How I’ve done it so far it sits independently of Unity’s code, and is very unlikely to stop working, or to cause bugs later on. YMMV…
(if you want to know more, get the Asset Store version, read the source. I’m happy to answer quetsions via the support links or in the Unity Forums page for this)
1 reply on “Use shift-N to create new scripts in Unity Project Window, fast”
Thanks a lot for this utility!! And not only fast adding scripts… They are “//Use this for initialization” free!!