C# 字典 - 在 Unity / Kinect 项目中通过枚举键访问值
C# Dictionary - Access Value by Enum Key in Unity / Kinect Project
我正在尝试访问
RootSystem.Collections.Generic.Dictionary<Microsoft.Kinect.Face.FaceProperty, Windows.Kinect.DetectionResult> FaceProperties
在 Unity 中使用 Kinect 插件。
因此,FaceProperty 和 DetectionResult 是枚举:
public enum FaceProperty : int
{
Happy =0,
Engaged =1,
WearingGlasses =2,
LeftEyeClosed =3,
RightEyeClosed =4,
MouthOpen =5,
MouthMoved =6,
LookingAway =7,
}
和
public enum DetectionResult : int
{
Unknown =0,
No =1,
Maybe =2,
Yes =3,
}
然后在调试模式下,我试图访问 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.
你有什么想法我怎么可能访问字典 FaceProperties 的值?
提前致谢,
bertiooo
您可能缺少命名空间:
using Microsoft.Kinect.Face;
我正在尝试访问
RootSystem.Collections.Generic.Dictionary<Microsoft.Kinect.Face.FaceProperty, Windows.Kinect.DetectionResult> FaceProperties
在 Unity 中使用 Kinect 插件。
因此,FaceProperty 和 DetectionResult 是枚举:
public enum FaceProperty : int
{
Happy =0,
Engaged =1,
WearingGlasses =2,
LeftEyeClosed =3,
RightEyeClosed =4,
MouthOpen =5,
MouthMoved =6,
LookingAway =7,
}
和
public enum DetectionResult : int
{
Unknown =0,
No =1,
Maybe =2,
Yes =3,
}
然后在调试模式下,我试图访问 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.
你有什么想法我怎么可能访问字典 FaceProperties 的值?
提前致谢, bertiooo
您可能缺少命名空间:
using Microsoft.Kinect.Face;