JavaScript Quirks

From Unify Community Wiki
(Difference between revisions)
Jump to: navigation, search
m
m
Line 1: Line 1:
 
*Only Monobehaviours can use print(). This means that if you're using a custom class and need to debug it, you need to use [http://unity3d.com/Documentation/ScriptReference/Debug.Log.html Debug.Log(str)] instead. This will work both inside MonoBehaviours and non-MonoBehaviours alike.
 
*Only Monobehaviours can use print(). This means that if you're using a custom class and need to debug it, you need to use [http://unity3d.com/Documentation/ScriptReference/Debug.Log.html Debug.Log(str)] instead. This will work both inside MonoBehaviours and non-MonoBehaviours alike.
*If a class inherits from another class, and an instance is explicitly declared as the parent class, it will always call the parent's function - even if the child overrides it! The workaround is to make the instance a typeless variable.
+
*If a class inherits from another class, and an instance is explicitly declared as the parent class, it will always call the parent's function - even if the child overrides it! The workaround is to make the instance a typeless variable. This problem will disappear when Unity's JavaSript implements equivalents to the ''new'', ''override'' and ''virtual'' method qualifiers in C#.

Revision as of 08:56, 9 January 2007

  • Only Monobehaviours can use print(). This means that if you're using a custom class and need to debug it, you need to use Debug.Log(str) instead. This will work both inside MonoBehaviours and non-MonoBehaviours alike.
  • If a class inherits from another class, and an instance is explicitly declared as the parent class, it will always call the parent's function - even if the child overrides it! The workaround is to make the instance a typeless variable. This problem will disappear when Unity's JavaSript implements equivalents to the new, override and virtual method qualifiers in C#.
Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox