jacksondunstan / UnityNativeScripting

Unity Scripting in C++
https://jacksondunstan.com/articles/3938
MIT License
1.33k stars 135 forks source link

Declare an enum in NativeScriptTypes.json #64

Closed stonfute closed 3 years ago

stonfute commented 3 years ago

I've declared a class in C# which contains a public enum (see code below). How can I declare this enum in NativeScriptTypes.json ?

public class Node
    {
        public enum NodeType_typ
        {
            Type1,
            Type2
        }
        public NodeType_typ nodeType { get; set; }
        public string name { get; set; }
    }

I've declared my Node class as follows :

"Name": "MyNamespace.Node",
"Properties": [
    {
        "Name": "nodeType",
        "Get": {},
        "Set": {}
    },
    {
        "Name": "name",
        "Get": {},
        "Set": {}
    }
],
"Constructors": [
    {
        "ParamTypes": []
    }
]

And I've tried to declare NodeType_typ enum as follows, but without any luck

"Name": "MyNameSpace.Node.NodeType_typ",
"Constructors": [
    {
        "ParamTypes": []
    }
]

I know it works great if NodeType_typ enum is declared outside Node class (MyNameSpace.NodeType_typ), but I don't really to access this enum outside my Node class.

So, is there a way to declare an enum inside a class ?

jacksondunstan commented 3 years ago

Unfortunately, as mentioned in the README, the code generator does not yet support nested types. If you'd like to implement this, I'd happily accept a PR.