So from what I’ve googled so far, my interpretation of the word “override” is not the same as is meant in c# but you’ll see what I’m getting at. So I’ve set up three classes (scripts) like so:
using UnityEngine;
using System.Collections;
public class Basy {
public int test = 3;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
}
using UnityEngine;
using System.Collections;
public class Testy : Basy {
float test = 2f;
// Use this for initialization
void Start () {
}
// Update is called once per frame
public void Update () {
Debug.Log ("test " + test);
}
}
using UnityEngine;
using System.Collections;
public class Executey : MonoBehaviour {
Testy test = new Testy ();
void Awake ()
{
}
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update ()
{
test.Update ();
}
}
Everything runs fine, and as I expected, “2” gets debugged. My question is, is there any possible way to access the “int test = 3” field from the testy class? I made this field an int purely for testing purposes. In a situation where they would both be floats, surely the field in the class “Testy” would be technically overriding the one in the “Basy” class?