An Inheritance question. ( accessing non-static members from a script component)

Hi i’m struggling with an aspect of unity involving inheritance.

I initially assumed the best way to work would be to derive new classes from GameObjects but as they are a sealed class it has throw a little confusion into the way I would work. I then understood that prefabs were essentially the way around this, you could bundle up your own bespoke GameObjects in the form of prefabs (is this correct) now the problem comes when accessing members of instances of those prefabs. I have set up a bit of code which essentially looks like this.

I have tried it with getComponent on (Cube) and (“Cube”) on the instance and it doesn’t show that the isActive bool variable is available for setting.

Thank you in advanced

//----------------------------------------------------------------------------------------
// First Script
//----------------------------------------------------------------------------------------

public class GameItem : MonoBehavior
{
    public bool is Active;
}

//----------------------------------------------------------------------------------------
// Second Script ~ Is on a Cube Prefab
//----------------------------------------------------------------------------------------

public class Cube : GameItem
{
    isActive = true;
}

//----------------------------------------------------------------------------------------
// Third Script
//----------------------------------------------------------------------------------------

public class CubeEffector : MonoBehavior
{
    public GameObject cubePrefab; // Holds a reference to the Cube Prefab

    GameObject cubeInstance = Instantiate(cubePrefab, transform.position, transform.localRotation);

    if(conditions are met){
        cubeInstance.isActive = false;
    }

}

try (although there are other syntaxes):

Cube c = (Cube)cubeInstance.GetComponent(typeof(Cube));
c.isActive = false;

You might have to place the ‘isActive == true’ declaration inside the Awake() function for that class.