我在 Unity 项目的代码中重复出现以下错误
Assets/App/Models/AnnotationModel.cs(39,17): error CS1644: Feature `dictionary initializer' 不能使用,因为它不是 C# 4.0 语言规范的一部分
触发这些错误块的代码如下
["CameraPose"] = ConvertToken(CameraPose),
["Aspect"] = Aspect,
["Image"] = Image.Id,
["Fov"] = Fov,
["IsAnchored"] = IsAnchored,
["AnchorPosition"] = ConvertToken(AnchorPosition),
["DrawLines"] = ConvertToken(DrawLines),
["SurfaceDrawLines"] = ConvertToken(SurfaceDrawLines)
初始化 C# 字典的新方法是什么?我已尝试(未成功)在 C# 4.0 语言规范中找到初始化的更新版本。
如果有帮助,下面的代码显示了这些对象是什么
public Pose CameraPose;
public float Aspect;
public ImageModel Image;
[Range(0, 120)] public float Fov = 60;
public bool IsAnchored;
public Vector3 AnchorPosition;
public List<List<Vector2>> DrawLines;
public List<List<Vector3>> SurfaceDrawLines;
任何帮助将不胜感激!我对 Unity 和 C# 完全陌生。