Problem with protected variable, not updating!

Ok I’m making the UI of a game, I created two classes one is the parent (UIInteract.cs) and another is the inheritance (UIIteractIcon). There is a protected boolean variable named ShowInteract. The flow is when I switch the ShowInteract to true value, the GUI of the UIIteractIcon should show on the game screen.

public class UIInteract : MonoBehaviour {
   

    protected INVENTORY.SingleItem currentItemInteract;
    protected int PerformSlot;
    protected bool ShowInteract = true;


    // Use this for initialization
    void Awake () {
       
   
    }



    public bool Show{
        set{ ShowInteract = value;}
        get{ return ShowInteract;}
    }

    public void StartInteract(INVENTORY.SingleItem InteractItem, int slotNumber){

        theSlot = slotNumber;
        currentItemInteract = InteractItem;
        Show = false;

    }
}
public class UIInteractIcon : UIInteract {

//    private bool canShow;

    void OnGUI(){
   
//        canShow = ShowInteract;
        if (ShowInteract) {

            scaleFactor.x = (float)(Screen.width) / _PARAMETERS.MaxScreenWidth;
            scaleFactor.y = (float)(Screen.height) / _PARAMETERS.MaxScreenHeight;
            GUI.matrix = Matrix4x4.TRS (new Vector3 (0, 0, 0), Quaternion.identity, new Vector3 (scaleFactor.x, scaleFactor.y, 1));
        //    Debug.Log("Show interaction menu");
            GUI.BeginGroup(new Rect(687,274,535,400),theSkin.box);
            if(currentItemInteract.Equals(UIItemList.Dagger)){
                GUI.Box(new Rect(0,0,535,400),"",theSkin.GetStyle("Dagger"));
            }else if(currentItemInteract.Equals(UIItemList.Avens)){
                GUI.Box(new Rect(0,0,535,400),"",theSkin.GetStyle("Avens"));
            }else if(currentItemInteract.Equals(UIItemList.RustyDagger)){
                GUI.Box(new Rect(0,0,535,400),"",theSkin.GetStyle("RustyDagger"));
            }else if(currentItemInteract.Equals(UIItemList.Germander)){
                GUI.Box(new Rect(0,0,535,400),"",theSkin.GetStyle("Germander"));
            }

            GUI.EndGroup();

        }
    }
}

However the case is when I called the function StartInteract() in UIInteract.cs. The GUI doesnt show in the game. I checked the value of ShowInteract in UIInteract.cs. It has been updated to true. But the value I get from the inheritance class UIInteractIcon is still false. I have no idea why it likes this. Thanks a lot if anyone can help.!!

As I understand it you have a gameobject (or two) with an Interact AND an InteractIcon component, so two seperated components.
You now assume that when changing the variable in the Interact component, itll reflect into the InteractIcon component?

If thats the case: Infact, it doesnt. Inheritance doesnt mean that a base class is global to any deriving class and does globaly/statically share any variable. Infact inheritance does mean that a base class reflects all fields/methods into the derived class. To visualize this for you a bit, it doesnt matter if you have the ShowInteract in your base class, you could aswell have it in InteractIcon, itll be effectivly the same. (Just as an example, inheritance does mean way more)

To get to the point, you need to set the ShowInteract variable on your InteractIcon component…

Oh and you should read a bit about code design. Fields should never start with upper case, instead lower plus camel case.

Thanks buddy! Yea I think I misunderstood the concept of inheritance, thanks for reminding.