Unity Community


Results 1 to 16 of 16

  1. Location
    Medellin, Colombia
    Posts
    448

    Questions about customizing the editor

    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.
    Director of Development
    C2 Estudio
    www.c2estudio.com

  2. Administrator
    Location
    Copenhagen
    Posts
    1,586
    Hi.

    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.


  3. Location
    Medellin, Colombia
    Posts
    448
    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...
    Code:  
    1. @MenuItem ("Hierachy/Do Something")
    2. static function DoSomething () {
    3.     Debug.Log ("Perform operation");
    4. }

    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.
    Director of Development
    C2 Estudio
    www.c2estudio.com


  4. Location
    Medellin, Colombia
    Posts
    448
    Ok just as I guessed

    Code:  
    1. @MenuItem ("Hierarchy/Do Something")
    2. static function DoSomething () {
    3.     Debug.Log ("Perform operation");
    4. }

    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...

    Code:  
    1. @CustomEditor (Camera)
    2. class SelectedCameraViewScene extends Editor {
    3.    
    4.     function OnSceneGUI () {
    5.        
    6.         if(target.camera)
    7.         {
    8.             Handles.BeginGUI();
    9.             GUILayout.BeginArea(Rect(0,0,100,100));
    10.             GUILayout.Box(target.name);
    11.             target.camera.Render();
    12.                GUILayout.EndArea();
    13.             Handles.EndGUI();   
    14.         }
    15.     }
    16. }
    Director of Development
    C2 Estudio
    www.c2estudio.com


  5. Location
    Ontario, Canada
    Posts
    1,661
    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,
    -Jeremy
    GUI-eXtended 1.x is now Open-Source!
    https://bitbucket.org/JeremyHollings...ded_opensource

  6. Keyboard operator

    Location
    Copenhagen, Denmark
    Posts
    2,929
    Not sure what your exact need is, but this could perhaps prove helpful:
    http://forum.unity3d.com/viewtopic.php?p=138144#138144
    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/12/23/Behave-2-2/
    Check out ReView!


  7. Location
    Medellin, Colombia
    Posts
    448
    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.

    Not sure what your exact need is, but this could perhaps prove helpful:
    http://forum.unity3d.com/viewtopic.php?p=138144#138144
    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
    Director of Development
    C2 Estudio
    www.c2estudio.com


  8. Location
    Ontario, Canada
    Posts
    1,661
    Quote Originally Posted by ratamorph
    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.

    Not sure what your exact need is, but this could perhaps prove helpful:
    http://forum.unity3d.com/viewtopic.php?p=138144#138144
    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.
    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.

    -Jeremy
    GUI-eXtended 1.x is now Open-Source!
    https://bitbucket.org/JeremyHollings...ded_opensource


  9. Location
    Medellin, Colombia
    Posts
    448
    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.
    Director of Development
    C2 Estudio
    www.c2estudio.com


  10. Location
    Medellin, Colombia
    Posts
    448
    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.
    Director of Development
    C2 Estudio
    www.c2estudio.com


  11. Posts
    42
    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.


  12. Location
    Medellin, Colombia
    Posts
    448
    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
    Director of Development
    C2 Estudio
    www.c2estudio.com


  13. Posts
    63
    Quote Originally Posted by ratamorph
    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
    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...)

    http://unity3d.com/support/documenta...d-context.html

    will show as (see attachment)
    Attached Images  


  14. Location
    Medellin, Colombia
    Posts
    448
    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
    The MenuItem attribute allows you to add menu items to the main menu and inspector context menus.
    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.
    Director of Development
    C2 Estudio
    www.c2estudio.com


  15. Location
    Vancouver
    Posts
    75
    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.


  16. Posts
    21
    The context menu for Hierarchy is hard-coded inside the HierarchyWindow base classes. you'll need to make your own EditorWindow, duplicating HierarchyWindow functionality.

    http://postimage.org/image/p19oxvsaf/11dba4c7/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •