Search Unity

EditorGUILayout: Controlling SetActive on SerializedObjects from Inspector

Discussion in 'Scripting' started by OceanBlue, Nov 19, 2014.

  1. OceanBlue

    OceanBlue

    Joined:
    May 2, 2013
    Posts:
    251
    Hi

    On my game control script, I have a group of game objects in the scene that I'd like to be able to switch on and off via my inspector script using EditorGUILayout. I have used serializedObject.FindProperty on my Editor script to grab the reference for the objects in the Control Script. But unless I'm running the game, these won't show up. I need them to display when not in play mode, so that I can then set up my editor script to allow me to turn the object on or off (active).

    Problem also is that in my Control script, i can no longer SEE the game object variable public GameObject enemies[] because of the Editor script attached and hence can't assign them to the script from the scene.

    Hope I'm making some sense here lol

    UPDATE:

    Showing visually what I want to achieve.

    So far in inspector, I have the following:


    What I want to achieve is:


    Any suggestions?

    Thanks
     
    Last edited: Nov 19, 2014
  2. OceanBlue

    OceanBlue

    Joined:
    May 2, 2013
    Posts:
    251
    Note that the above should also save the active/inactive state of the game object when the scene is played