fullinspector icon indicating copy to clipboard operation
fullinspector copied to clipboard

Add 64-bit enum flags support

Open jacobdufault opened this issue 10 years ago • 2 comments

[Flags]
public enum MyEnum : ulong {
    A = 1 << 0,
    B = 1 << 1,
    C = 1 << 2,
    D = 1 << 60,
}

This will require rewriting EditorGUI.EnumMaskField as internally it casts the enum to a 32-bit integer.

jacobdufault avatar Feb 11 '15 21:02 jacobdufault

The issue is really with Unity (or Mono?)

using UnityEngine; using System.Collections;

public class Test1 : MonoBehaviour {

//      The following WILL NOT appear in the Inspector
public System.Int16 SignedInt16 = 0;
public System.Int64 SignedInt64 = 0;

public System.UInt16 UnsignedInt16 = 0;
public System.UInt32 UnsignedInt32 = 0;
public System.UInt64 UnsignedInt64 = 0;

public System.SByte SignedByte = 0;


//      The following throw errors in the Inspector
public MyEnum3 myEnum3 = MyEnum3.None;
public MyEnum4 myEnum4 = MyEnum4.None;
public MyEnum5 myEnum5 = MyEnum5.None;

public enum MyEnum3 : long
{
    None = 0,
    One = 1,
    Two = 2
}

[System.Flags]
public enum MyEnum4 : long
{
    None = 0,
    One = 1,
    Two = 2,
    Four = 4
}

[System.Flags]
public enum MyEnum5 : ulong
{
    None = 0,
    One = 1,
    Two = 2,
    Four = 4
}


//      The following DO NOT show up in the Inspector
public decimal SignedDecimal = 0;
public short SignedShort = 0;
public long SignedLong = 0;

public uint UnsignedInteger = 0;
public ushort UnsignedShort = 0;
public ulong UnsignedLong = 0;

// The following DO appear in the Inspector
public MyEnum1 myEnum1 = MyEnum1.None;
public MyEnum2 myEnum2 = MyEnum2.None;

public enum MyEnum1
{
    None = 0,
    One = 1,
    Two = 2
}

// Flags attribute is ignored, single choice only
[System.Flags]
public enum MyEnum2 : int
{
    None = 0,
    One = 1,
    Two = 2,
    Four = 4
}


public float SignedFloat = 0;
public int SignedInteger = 0;
public byte UnsignedByte = 0;
public double SignedDouble = 0;

public System.Int32 SignedInt32 = 0;

// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {

}

}

MrGadget1024 avatar Feb 12 '15 00:02 MrGadget1024

Update, I had someone with latest Unity 5 load up the above script, and most of the issues are better, but enum : long and enum : ulong are still throwing errors. I've filed a bug report with Unity about it.

MrGadget1024 avatar Feb 20 '15 01:02 MrGadget1024