Inheritance public variables defined in the inspector problem.
So I have this hierarchy.
What i want to do is have a script associated to Platform like this:
public class PlatformController : MonoBehaviour {
public float rotationSpeed;
public HandController handController;
}
I want to define these variables in the inspector. Then i have another class for the child objects that extends PlatformController.
public class RectCenterController : PlatformController
{
//private variables
void Start()
{
//code
}
void Update()
{
//code
}
}
What i want to do is use PlatformController variables (that I define in the inspector) in RectCenterController but when i declare them as public it makes it so that RectCenterController has to define them in the inspector too, reseting them to the default values (0 and null).
I tried using protected variables in PlatformController, it works, but it doesn't allow me to define handController in the inspector. (It's a variable from the scene.)
HandController is an object from the Leap Motion SDK btw.
Your answer
![](https://koobas.hobune.stream/wayback/20220612074500im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How would I get around multiple inheritance for this instance? 1 Answer
Protected variable is assigned in parent but null in child 1 Answer
Custom class, Null Reference Exception 4 Answers
C# syntax question Generic and overriding 0 Answers
Grab an inherited subclass script from a GameObject in C# 0 Answers