Kind of like how Unity calls Awake() in a script inheriting from MonoBehaviour, I want to call Initialize() and Execute() in any scripts inheriting from Ability.cs. How can I do this in C#?
The function you’re looking to call in the parent script must be public, then just call it as you would any other function.
using UnityEngine;
using System.Collections;
public class Parent : MonoBehaviour
{
public void ParentFunction()
{
Debug.Log("Parent function was called!");
}
}
using UnityEngine;
using System.Collections;
public class Child : Parent
{
// Use this for initialization
void Start ()
{
ParentFunction();
}
}