What I need to acomplish, is hook into the BaseBehaviour, whenever OnGameSlowdown
is called on the BaseBehaviour, it needs to trigger said method in all derived classes.
In this example. OnGameSlowdown
gets called whenever the game slows down, I want to hook this method from other components to do something specific to each component that is listening.
public class BaseBehaviour : MonoBehaviour
{
protected virtual void OnGameSlowdown()
{
Debug.Log("Base OnGameSlowdown");
}
protected virtual void OnGameResume()
{
}
public IEnumerator Slowdown(float slowdownTime, float slowdownDuration)
{
Time.timeScale = slowdownTime;
OnGameSlowdown();
yield return new WaitForSeconds(slowdownDuration * slowdownTime);
Time.timeScale = 1f;
OnGameResume();
}
}
PlayerController
public class PlayerController : BaseBehaviour
{
protected override void OnGameSlowdown()
{
Debug.Log("PlayerController OnGameSlowdown");
}
}