Search Unity

I'd like to extend editor with my own tools

Discussion in 'Scripting' started by megisto, Apr 22, 2014.

  1. megisto

    megisto

    Joined:
    Dec 25, 2009
    Posts:
    127
    Hi, is there a specific book (or tutorials) on how to program Unity editor, for a low/average level programmer?
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
  3. hpjohn

    hpjohn

    Joined:
    Aug 14, 2012
    Posts:
    2,190
  4. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,620
    Yeah, you don't really need special tutes. The GUI works just like UnityGUI, but has a bunch of extras for the Editor. Likewise, playing with stuff in the scene is the same, but there's also some extra stuff to let you do things at the project level rather than the scene level.
     
  5. megisto

    megisto

    Joined:
    Dec 25, 2009
    Posts:
    127
    Docs are useful, but i'd like a more practical approach. Just as an example: what if i want to build a simple, say, road tool, something like a bezier to road tool, that draws a stripe of polygons, set UV and place material, that works in the editor. Or a terrain tool and such.

    A step by step tut to start understand the logic would be useful.
     
  6. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,620
    But... what you just described is it.

    For your road example, assuming that you can already make beziers and extrude polys from them and so on, doing it in an Editor script isn't anything special or remarkably different. You write the same functionality, but you hook it up to some buttons or whatnot that you show in the Editor's GUI. That's it.

    What are the particular bits you're having trouble with? I had trouble with this stuff initially because I was under the mistaken impression that you could only use the Editor classes directly from the Editor. Once I realised I was wrong about that - I could docallGUI.Whatever and just directly look for stuff in the scene and change it - everything was a snap.

    If you can make it happen in your game, you can make it happen in the Editor. The only extra bit you need to learn to get started is how to make an editor GUI of whatever type is relevant, and the docs have that covered pretty well.
     
  7. megisto

    megisto

    Joined:
    Dec 25, 2009
    Posts:
    127
    By "Editor" i mean the editor when the Play button is not pressed, not the compiled game. I am asking it just in case i am getting this thing wrong.
    So for example i can setup a LOD system or a dynamic loading of items that works in the editor?

    I am working on a game in which i need very specific tool, like a cut scene and camera animation editor and some simple mesh editor. I know there is a bunch of assets in the assets store that can manage this thing, but i think this is a chance to learn something more.
     
  8. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    That's what angrypenguin is talking about.

    --Eric
     
  9. megisto

    megisto

    Joined:
    Dec 25, 2009
    Posts:
    127
    Great. What language do you think is better for this kind of job? Js or C#?
     
  10. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    They both work, but I prefer JS for editor scripting since I can import the GUILayout class and just do Label, Button, etc. without having to put GUILayout in front of everything, and C# doesn't let you import classes (only namespaces).

    --Eric