- Home /
How to control the exposure of public variables in the inspector pane based on a value of another variable?
Hello,
Let's say that I have enums.
     public enum StoryUIButton
     {
         Music, 
         SoundEffects, 
         PauseAndResume,
         Continue, 
         Restart,
         MainMenu,
         NextLevel,
     };
     public StoryUIButton ThisStoryButtonIsFor;
Now based upon the value I select for "ThisStoryButtonIsFor" in the inspector, I want to expose a certain set of variables?
  // If is a Music Button, this should be exposed, else hide in the inspector pane
      public UISprite EnabledSprite, DisabledSprite;
     
  // If it is a PauseAndResume button -> this variable should be exposed, else hide in the inspector pane
       public Transform MultiplierLabel, ScoreLabel, BaseHUD;
         
  // If it is a Continue button -> this variable should be exposed, else hide in the inspector pane.
        public Transform [] HUDWings = new Transform [3];
     
Is it possible? If so how?
Thank you and your help is always appreciated.
Karsnen
take a look at extending the editor - http://docs.unity3d.com/Documentation/Components/gui-ExtendingEditor.html
You can expose what ever variables you want, and add logic as well...
Answer by perchik · Jul 18, 2013 at 04:05 PM
The short answer is that you're going to want to look at a Editor script, particularly custom editors. You can use an EnumPopup to handle the enum and then draw editor fields based on what is selected. I have an example I can dig up for you, but this should get you started in the right direction.
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                