Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Serialized Struct Won't Show Enum Fields

Discussion in 'Editor & General Support' started by GibTreaty, Jul 7, 2014.

  1. GibTreaty

    GibTreaty

    Joined:
    Aug 25, 2010
    Posts:
    792
    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class MyClass: MonoBehaviour {
    5.    public MyStruct aStruct;
    6. }
    7.  
    8. [System.Serializable]
    9. public struct MyStruct {
    10.  
    11.    //These fields will show up as ints instead of enum popups
    12.    public KeyCode aKey;
    13.    public ForceMode aForce;
    14.  
    15.    public MyStruct(KeyCode aKey, ForceMode aForce) {
    16.      this.aKey = aKey;
    17.      this.aForce = aForce;
    18.    }
    19. }
    Capture.PNG

    As you can see, the fields MyStruct.aKey and MyStruct.aForce will show up as ints in the inspector. Is this intended?
     
    Last edited: Jul 7, 2014
  2. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,613
    Looks like a bug to me. Could you submit a report, with that repro code, and post the bug number here?
     
  3. GibTreaty

    GibTreaty

    Joined:
    Aug 25, 2010
    Posts:
    792
    Thanks, I submitted the report.

    case #618318
     
  4. ElvisAlistar

    ElvisAlistar

    Unity Technologies

    Joined:
    Oct 2, 2013
    Posts:
    226
    Thanks! This is fixed for Unity 4.6, which is currently in beta.
     
    GibTreaty likes this.