I have an object which needs to tie into the editor's update loop to keep itself up to date. I thus added this code to it's primary JS script:
#if UNITY_EDITOR
function OnEnable() {
EditorApplication.update = Update;
}
#endif
I also need to have multiple object's of it's type in a scene, so I modified the code to this:
#if UNITY_EDITOR
function OnEnable() {
EditorApplication.update += Update;
}
function OnDisable() {
EditorApplication.update -= Update;
}
#endif
Unfortunately, Unity's compiler balks at the syntax:
BCE0051: Operator '+' cannot be used with a left hand side of type 'function(): void' and a right hand side of type 'function(): void'.
Isn't this a basic feature of delegates? Am I doing something wrong, or is Unity's js implementation totally screwed up? (I know we couldn't create multidimensional arrays for quite a while, is this a similar type of issue?) If so, what's the best way to work around it?
Here's some similar topics:
http://answers.unity3d.com/questions/15889/editorapplication-update-resetting
http://forum.unity3d.com/threads/9679
http://msdn.microsoft.com/en-us/library/ms173175(v=vs.80).aspx