Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Inspector Question

Discussion in 'Scripting' started by thepenguinmaster, Dec 3, 2014.

  1. thepenguinmaster

    thepenguinmaster

    Joined:
    May 22, 2013
    Posts:
    29
    I have an item that is not a game object. I have properties on that item. I am wondering if it is possible to display properties form that item (class) if it is not a game object.


    Here is a better description:


    Let’s say I have an editor window, and inside that editor window there are either panels or other winnows. When I select one of those windows that contains properties, I would like to display those properties for edit in the inspector. Maybe there is an onclick/select event that I can pass a class to the inspector to display the properties to the user (as with when you select a game object).


    My problem is I am unsure how to select a class that is not a game object and is just a script into the inspector. I saw the Selection.objects but I don’t know if this is what I need because I would prefer not to have the item being inspected in the scene or the hierarchy.


    What I am specifically trying to accomplish is to have something like the animation controller, where you can select an item in the animation tree, and modify the properties in the inspector, without having an item in the scene.


    Any suggestions or leads would be a huge help.
     
  2. LiberLogic969

    LiberLogic969

    Joined:
    Jun 29, 2014
    Posts:
    138
  3. thepenguinmaster

    thepenguinmaster

    Joined:
    May 22, 2013
    Posts:
    29
    ok I understand serialization and why it is required for the inspector, but what I am trying to figure out is not how to have any game object appear in the inspector, but how to programatically select a class that is not a gameobject into the inspector, that also does not exist in the scene or heiarchy. I would of coarse add the serializable attribute to the class that I wanted to represent the data (as one normally would), but that dosnt really answer the question. Maybe I didnt make the question completely clear there.
     
  4. thepenguinmaster

    thepenguinmaster

    Joined:
    May 22, 2013
    Posts:
    29
    Ok so I had to go the logn way around here to figure this out.

    I decompiled the DLLs in the Managed folder of my unity install and everything I need is there. I took a look at the animationController and they have a 'node' object that drives everything.

    The node object inherits ScriptableObject, this seems to be key for selecting with the inspector. The window is created with the nodes position, and what seems to be another key, is the window is passed the Node objects instance Id as its ID.

    Later there is a function that gets the mouse events and depending on what keys are pressed will either add or remove the Node object from a list. every update, the script will scan through all nodes (whos rectangles corrispond with the actual window because they are updated every cycle) and use a < > comparison with the click location.

    To show the item in the inspector, they call something like Selection.objects = list.ToArray();
    The importiant part here, is that they are not responding to a window click, and they are using a ScriptableObject as the base for their node so it can be displayed in the inspector. I may clean this up, write an example, and repost for anyone else who may want to know how this is done.