Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Can I make custon variables for my gui

Discussion in 'Immediate Mode GUI (IMGUI)' started by ahmetthe, Sep 25, 2023.

  1. ahmetthe

    ahmetthe

    Joined:
    Mar 11, 2020
    Posts:
    1
    I want to add or remove extra variables depending on current enum chosen for the doors
    Code (CSharp):
    1. public class IronMachine : MonoBehaviour
    2. {
    3.     [SerializeField] private DoorPref door1;
    4.     [SerializeField] private DoorPref door2;
    5.     [SerializeField] private DoorPref door3;
    6.    
    7.  
    8.     enum DoorTypes { Weapon, Armor, PowerUp }
    9.     [Serializable]
    10.     class DoorPref
    11.     {
    12.         public DoorTypes doorType;
    13.         public float threshold;
    14.  
    15.         #region Editor
    16.         #if UNITY_EDITOR
    17.         [CustomEditor(typeof(DoorPref))]
    18.         public class DoorEditor: Editor
    19.         {
    20.             public override void OnInspectorGUI()
    21.             {
    22.                 base.OnInspectorGUI();
    23.  
    24.             }
    25.         }
    26.        
    27.         #endif
    28.         #endregion
    29.     }
    if I change DoorPref to monobehaviour I can take its object to control DoorTypes chosen but it also changes them to objects on inspector so I cant see or choose the enums

    How can I make this work ?
     

    Attached Files: