Strange default value + namespace issue in Unity3D

When developing DanmakuX, I've noticed that it seems the mono C# runtime in Unity3D has some issues dealing with functions with default parameter value when the class is inherited from ScriptableObject and in a namespace.

I have a base class like this

class DMKNode: ScriptableObject {

    public virtual void OnEditorGUI(bool showHint = false) { }


And multiple classes are inherited from this base class. It was fine until I moved all my classes into a namespace. Then Unity starts to report some 'DuplicateKey' errors when compiling the scripts. And even it compiles, the serialization/deserialization of the sub-class instances fails without error.

I was able to save the scene with my objects, but when loaded again, the value of those objects became null. Some search over the Internet and found out someone already noticed the same issue.

When the default value is removed, everything become fine and works as expected.

blog comments powered by Disqus