I'm very excited about the new editor scripting functionality, you can do a lot with it but there's still a few things I don't understand if I'm allowed to do or how.
1. Can you modify a standard editor window? say change the behavior of the camera in the scene view, I was watching the Unite 08 opening keynote, and if I understand right Nicholas said he did the fps camera using the editor scripting api. If so how do I do it, can't seem to find it in the docs. I wanna try to add support for this http://forum.unity3d.com/viewtopic.php?t=6109
2. Related to the first question, can I modify the popup menu that apears in the hierachy window? say I add a new option called create empty children? that creates an empty game object that's a children of the one highlited.
3. How did Nicholas do the picture in picture looking window that would show the view of the currently selected camera? is it actually a part of the scene view window or is it a floating window?
Any input would be greatly apreciated.
I suggest you take a look at the FAQ in the UnityGUI section - that has a link to a new doc page about editor GUI scripting: http://unity3d.com/support/documenta...ingEditor.html
1) You can create new EditorWindows, custom inspectors and custom GUI inside the scene view. Supporting SpaceNavigator is gonna be hard at the moment, though.
2) Yes - use the MenuItem property: http://unity3d.com/support/documenta.../MenuItem.html
3) It was done with a custom inspector that had an OnSceneGUI which called Camera.Render on the target object.
Mathematicians that only do calculations that we already know about and are comfortable with? They're called accountants, and they have no friends.
Thanks for the quick reply, I've been reading the docs and doing some tests.
I guess my first question would be how to make the windows, inspectors and such be a part of the scene view and not just floating dockable windows. And very similarely how do I access the popup menu in the hierachy? I followed the link and that explains me clearly how to create popup menus of my own or add them to the menu bar, but doesn't show me how to add them to an existing standard window like the hierachy.
I'm guessing something like...
But that just a wild guess...
I figure the reason adding space navigator support would be hard at the moment is because we don't get access to the scene view camera, am I right?
Lastly is there a particular reason you used a custom inspector for the camera view window? My first guess would have been just to make a window.
Thanks again for taking the time to answer my questions.
Ok just as I guessed
Will just create a Hierarchy menu in the main menu which contains Do Something, What I want is the popup to appear when I right click an object in the Hierarchy. I tried CONTEXT/Hierarchy/Do Something (another wild guess) and that didn't seem to do anything.
I also tried to do the custom inspector that shows the selected camera view in the scene view and runned into some issues.
1. How do I make it so it doesn't override the camera inspector?, I just want this script to show me the view in the window for any camera that I select without having to add a script to every camera that I want to have this feature.
Even without the OnInspectorGUI it will get rid of the camera component inspector UI.
2. How do I make camera.Render() render inside the GUILayout area instead of the whole scene window?
I could probably address both of this issues by attaching an extra custom inspector to my cameras that takes a render texture and draw that render texture inside my GUI, but I'd like to avoid that if possible.
Here's what I did...
I haven't had time to read this all the way though, but "Camera.current" will return the current camera, which in the Editor is the scene view camera.
You shouldn't have to add any scripts to your scene camera for this.
Hope that helps,
Emil "AngryAnt" Johansen
Game developer, AI specialist, Unity expert
Freelancer, ex Unity Technologies
AI in Unity, tips and tricks: http://angryant.com, http://twitter.com/angryant
Coding bare-footed grants you extra CPU cycles!
Want to play? http://angryant.com/freelance/
Behave 2 is out! http://angryant.com/2013/08/25/Behave-2-1/
Check out ReView!
I wasn't aware Camera.current was the scene view camera on the editor, I just tried a simple script to move it and that doesn't seem to do anything, I wonder if that's why Nicholas said it would be hard to do, I wonder if its even possible.
I'm trying to stay away from render textures, Nicholas said he did it using Camera.Render but that just renders over the whole scene view and not on my smaller box.
Do you guys have any idea how to add an item to the context menu on hierarchy window? I've been browsing the docs and trying different things all day and can't seem to figure it out
You set the camera's pixelRect before calling myCamera.Render in your GUI code (on the repaint event). Just remember that the camera's y origin is flipped from the GUI's representation.Originally Posted by ratamorphI wasn't aware Camera.current was the scene view camera on the editor, I just tried a simple script to move it and that doesn't seem to do anything, I wonder if that's why Nicholas said it would be hard to do, I wonder if its even possible.
Nice that's a lot better! now I need to figure out how to make my script not overwrite the Camera component inspector GUI.
Is there a way to do this? I don't want to use another script to hook up my inspector to because I want this for all the cameras I use in the project.
I've posted my camera view scripts on the wiki http://www.unifycommunity.com/wiki/i...ra_view_window , Ended up using a script that you attach to the cameras because that way you can switch on/off the feature for any camera aswell as modify the rectangle on the scenView.
I'm open for any suggestions on how it can be improved.
Still no luck with accessing the Hierarchy menuItem?
I'm also interested in finding out how to do it.
Any help would be more than welcome.
Still no luck, I'm guessing it can't be done at the moment, the docs are not clear on how this can be accomplished and doesn't seem like anyone has done it (atleast noone that wants to share an answer or reading this) so I gave up, wasted too much time trying to do so to the point that it was more productive to just add the item to the main menu and use a shortcut.
If you find a way to do this please post it here or PM me, I'll post it in the wiki so everyone can do it.
If anyone from UT read this, adding menu items to the context menu of the hierarchy or project view windows would be a very nice addition, and if we actually can do this please give us a snippet in the docs, in here or a sample project because we clearly can't figure this out ourselves
I do not know way to see the context menu hierarchy window. But you can see it in the Inspector. It is also possible to add them to your custom scripts (I guess since 2.5(?) because I found a thread where someone was asking for that...)Originally Posted by ratamorphDo you guys have any idea how to add an item to the context menu on hierarchy window? I've been browsing the docs and trying different things all day and can't seem to figure it out
will show as (see attachment)
Thanks for the reply Tri
I've also managed to modify the context menu in the inspector, but still haven't been able to modify the hierarchy one.
The docs say
But is the hierarchy panel an inspector?The MenuItem attribute allows you to add menu items to the main menu and inspector context menus.
That's what has me thinking it might not be possible.
Maybe if I could access the hierarchy window instance itself and access that menu somehow, but I've looked for such instance and haven't found it.
UnityEditor includes an internal interface ICanHazCustomMenu, which gives an EditorWindow a chance to add custom menu items to the drop down menu in the upper right corner. Unfortunately this isn't accessible to us.