Search code examples
dictionaryunity-game-engineenumskinectface

C# Dictionary - Access Value by Enum Key in Unity / Kinect Project


I'm trying to access a

RootSystem.Collections.Generic.Dictionary<Microsoft.Kinect.Face.FaceProperty, Windows.Kinect.DetectionResult> FaceProperties

in Unity with the Kinect Plugin.

Thus, FaceProperty and DetectionResult are Enums:

public enum FaceProperty : int
{
    Happy                                    =0,
    Engaged                                  =1,
    WearingGlasses                           =2,
    LeftEyeClosed                            =3,
    RightEyeClosed                           =4,
    MouthOpen                                =5,
    MouthMoved                               =6,
    LookingAway                              =7,
}

and

public enum DetectionResult : int
{
    Unknown                                  =0,
    No                                       =1,
    Maybe                                    =2,
    Yes                                      =3,
}

Then in the debug mode, I was trying to access the FaceProperties:

FaceProperties                        // Count = 8
FaceProperties[0]                     // Incorrect types or number of arguments
FaceProperties[FaceProperty.Happy]    // The name 'FaceProperties[global::Microsoft.Kinect.Face.FaceProperty.Happy]' 
                                      // does not exist in the current context. 

Do you have any ideas how could I possibly access the values of the dictionary FaceProperties?

Thanks in advance, bertiooo


Solution

  • You probably are missing the namespace:

    using Microsoft.Kinect.Face;