interface unity practical example

Example 1: unity interface

//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);
    
    }

}

Example 2: How to create an interface unity

//This code is in a seperate class

public interface ISomethingable<T>
{
	
	int RandomVar {get; set} // This is not needed, you can use any variable
    
    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);
    
    }

}