Accessing a private var from a subclass

How do I access a private var that is defined by a superclass. I believe other languages usually have a `protected` as well as `public` and `private` that allows this sort of thing.

class Foo extends MonoBehaviour {
  private var someVar:int = 10;
}

class Bar extends Foo {
  function Update() {
    Debug.Log(someVar);
  }
}

Output:

'Foo.someVar' is inaccessible due to its protection level.

I don't want this var showing up in the unity object inspector, but I do want subclasses to easily access it.

Do I need to create an explicit getter `function getSomeVar()` for this? That seems inelegant.

Even for public members you can add the HideInInspector tag, e.g.:

@HideInInspector
public var imPublicButNotInInspector : int;

If im not mistaken, you can try this:

class Foo extends MonoBehaviour {
  protected var someVar:int = 10;
}

class Bar extends Foo {
  function Update() {
    Debug.Log(someVar);
  }
}

A protected var is not accesable for all classes, only accesable for the class that has the protected var and all classes that extends the class that has the protected var.