x


Nested enum shows as int in Inspector

I have the following class structures:

public class NodeOwner : ScriptableObject
{
    public Node Root = new Node();
}

[System.Serializable]
public class Node
{
   public NodeType Type = NodeType.None;
   public Node[] Children = null;
}

public enum NodeType
{
   None,
   Type1,
   Type2
}

I have an editor script to create an instance of the NodeOwner. When I select the asset, the Root node appear fine in the inspector, with its Type set to None, but when I add children, their type defaults to 0 and I cannot choose node types via the inspector.

All help appreciated. I found this post but this doesn't seem to work for me:

http://answers.unity3d.com/questions/61073/enum-drop-down-menu-in-inspector-for-nested-arrays.html

Thanks Bovine

more ▼

asked Oct 26 '11 at 11:12 AM

Bovine gravatar image

Bovine
1.6k 26 30 47

have you tried to move the enum inside your Node class ?

also your array of children should be of type NodeOwner instead of Node, no ?

Oct 31 '11 at 03:37 AM oxium

Make the NodeType enum serializable as well.

Oct 31 '11 at 03:53 AM syclamoth

@syclamoth making the NodeType serializable didn't have any effect, but it was working at the top level.

@Oxium - sadly I have too much code in place elsewhere to try this, but in fairness I have moved the enum so often I've probably tried it.

The issue is somewhat moot as I hav a custom editor anyway now...

Nov 02 '11 at 02:24 PM Bovine
(comments are locked)
10|3000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x468
x130
x67
x36
x31

asked: Oct 26 '11 at 11:12 AM

Seen: 1023 times

Last Updated: Nov 02 '11 at 02:24 PM