你好,这是我在stackoverflow上的第一个问题,请谅解如果我做了什么愚蠢的事情。我的问题是我正在开发一个关卡编辑器,并且想使用PropertyGrid控件来编辑瓷砖/实体等的属性。到目前为止一切都正常,值正确显示,在代码中更改后也能更新,但我遇到的问题是,除非是布尔值,否则我无法更改值,我搜索了很多资料,但没有找到解决方案。
以下是我定义属性的代码:
[Description("Defines the Position on the screen")]
public Vector2 screenpos { get; set; }
Vector2 WorldPos;
[Description("Defines the texture of the selected tile")]
public string texture { get; set; }
[Description("Defines if the player can collide with this tile")]
public bool IsCollidable { get; set; }
[Description("Defines on what layer this tile is drawn (1-3)")]
public int Layer { get; set; }
[Description("Shows if the tile is currently visible on the screen")]
public bool OnScreen { get; private set; }
我可以编辑IsCollidable,如果我从OnScreen的set中删除private,我也可以编辑它,但我不能编辑其他任何内容。噢,如果你能用更简单的语言回答我的问题,我会很感激的,因为我不是很有经验的程序员。提前感谢。