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.
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
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.
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?
You can create new EditorWindows, custom inspectors and custom GUI inside the scene view. Supporting SpaceNavigator is gonna be hard at the moment, though.
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.
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.
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.
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.
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.
I’ve posted my camera view scripts on the wiki unifycommunity.com , 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, 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…)
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?
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.
The context menu for Hierarchy is hard-coded inside the HierarchyWindow base classes. you’ll need to make your own EditorWindow, duplicating HierarchyWindow functionality.