using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Test : MonoBehaviour
{
void Start()
{
Debug.Log("Started");
test1();
}
public virtual void test1(){}
}
public class testing : Test
{
public override void test1()
{
Debug.Log("Override called");
}
}
You have to create an instance of the class ‘testing’. Only that class has the overridden method e.g:
public class Test : MonoBehaviour
{
void Start()
{
Debug.Log("Started");
var testingInstance = new testing();
testingInstance.test1();
}
public virtual void test1(){}
}
public class testing : Test
{
public override void test1()
{
Debug.Log("Override called");
}
}
However, you might not want to have ‘Test’ inherit from Monobehaviour, because it’s not preferable to create instances of monobehaviour classes manually.