I have two main classes. First, the FSMSystem class:
public class FSMSystem<T> : MonoBehaviour where T : FSMSystem<T> { private T m_Owner = default(T); protected FSMState<T> currentState; private Dictionary<int, FSMState<T>> m_states; public FSMSystem(T owner) { m_Owner = GameObject.FindObjectOfType(typeof(T)) as T;
And second class, FSMState:
public abstract class FSMState<T> { public abstract int GetStateID(); public abstract void OnEnter (FSMSystem<T> fsm, FSMState<T> prevState); public abstract void OnUpdate (FSMSystem<T> fsm); public abstract void OnExit (FSMSystem<T> fsm, FSMState<T> nextState); }
This results in the following error:
error CS0309: type ' T ' must be converted to ' FSMSystem<T> ' in order to use it as a parameter ' T ' in a generic type or method FSMSystem<T>
Can someone tell me how to solve this? I see many other posts similar to this, but I do not see the relationship.
source share