Hello everyone, I was doing some work in trying to familiarize myself with FMS’, and in one of the tutorials I was looking at I saw something similar to:
public interface IState {
//test interface used in a FFSM.
void Update (DummyClass target);
}
Now this was all fine and good, but I was left wondering about 2 things:
Is there a way to implement some sort of generic parameters for the method? Something like:
public interface IState {
//test interface used in a FFSM.
void Update (AnyClass anythingIWant);
}
→ For a case where you either don’t know what type you’ll end up working with or just want a large variety of types to be useable.
Is there a way to overload the parameters? Something like:
public interface IState {
//test interface used in a FFSM.
void Update (DummyClass target);
void Update ();
}
→ Since each time I add a method, I have to keep adding implementations that may not make any sense in the class that implements them.
Any insights are appreciated, and I apologize if my questions are outright stupid. [Also, anyone else have the TAGS for posts keep disappearing when entering new ones? Really annoying…]
i’d just like to throw this in to see if it helps:
public interface IState {
//test interface used in a FFSM.
void Update (DummyClass target);
}
public class State : MonoBehaviour, IState
{
void Update() {
// If you want to call Update(DummyClass)
Update(default(DummyClass));
}
void Update(DummyClass dummy)
{
// do something with DummyClass
}
}
Note the use of default(DummyClass) assigning null to a Complex Type is invalid so use default instead which just so happens to return null in this case.