This is doable by using C#, but is this possible by using UnityScript (Considering that we cannot use interface
nor abstract
keywords)?
Edited:
You CAN use interface
, please see below.
This is doable by using C#, but is this possible by using UnityScript (Considering that we cannot use interface
nor abstract
keywords)?
Edited:
You CAN use interface
, please see below.
You can implement the Command Pattern in UnityScript. The interface keyword is available and can be used with UnityScript. The abstract keyword, as far as I know can not be used.
You would create your interface normally, then implement where ever by using the implements keyword, like in Java.
//InterfaceTest.js
#pragma strict
public interface InterfaceTest{
function Command();
}
//MyScript.js
#pragma strict
public class MyScript implements InterfaceTest{
function Command(){}
}
All UnityScript functions are marked virtual by default. So losing one level of abstraction is acceptable to me.