// When you use an interface, you can use two diferent objects to perform one
// action in common that executes diferently in each of theme.
Interface IDrivable {
void Drive(); //just the sentence
//....
}
// Examples of uses:
class Car1 : IDrivable
{
void Drive() {
//actions to drive the first Car
}
}
class Car2 : IDrivable
{
void Drive() {
//actions to drive the second Car
}
}
// In this example Car1 and Car2 are diferent classes and each of theme
// drives diferently, but can be used in something like this:
public IDrivable CarToDrive;
CarToDrive.Drive() // this executes Drive() in the selected car, no methers
// what car is.
//This code is in a seperate class
public interface ISomethingable<T>
{
int RandomVar {get; set} // This is not needed, you can use any variable
// need to be present in classes, which use this interface
void Function(T Arg);
}
//This Code is in a seperate class
public class Thingy : MonoBehaviour, ISomethingable<T>
{
public void Function(int Arg)
{
Debug.Log(Arg);
}
}