找到这个有用的工具后,我想用它来组织我的脚本。但是,当我添加第三个"类别"时,它会给我以下错误:
attribute 'Header' is not valid on this decleration type. It is only valid on 'field' declerations.
我试过使用" order = x"争论,但没有成功。知道发生了什么事吗?我似乎无法在Unity文档中找到任何相关内容。
[Header("Feedback settings")]
public string gameName = "";
public string sendToEmail = "";
[Space(5)]
[Header("Canvas settings")]
public Sprite emptyStar, fullStar, button;
[Range(20, 100)]
public float canvasSize;
[Range(-1, 1)]
public float canvasXPosition, canvasYPosition;
public float spritePadding, buttonYOffset;
[Header("Rate settings")] //<-- this one is marked with the above error
public enum MarketPlaces {PC, mobileTablet};
public MarketPlaces compileFor = MarketPlaces.PC;
public string rateLink;
Joe Blow的附加代码
[Header("Canvas settings")]
public Sprite emptyStar, fullStar, button;
[Range(20, 100)]
public float canvasSize;
[Range(-1, 1)]
public float canvasXPosition, canvasYPosition;
public float spritePadding, buttonYOffset;
public enum MarketPlaces { PC, mobileTablet };
[Header("Feedback settings")]
public string gameName = "";
public string sendToEmail = "";
[Header("Rate settings")]
public MarketPlaces compileFor = MarketPlaces.PC;
public string rateLink;
[HideInInspector]
public GameObject currentCanvas, tempButton, subCanvas;
private Button[] starButtons;
private Vector2 canvasPosition;
private GameObject rateMeCanvas, rateButton, contactField, openClient;
答案 0 :(得分:3)
Unity完成它的方式,你不能用枚举来跟随它。
幸运的是,解决方案很简单 - 只需移动它后面的枚举!
[Header("Feedback settings")]
public string gameName = "";
public string sendToEmail = "";
[Space(5)]
[Header("Canvas settings")]
// not possible...
// public Sprite emptyStar, fullStar, button;
// you must do this...
public Sprite emptyStar;
public Sprite fullStar;
public Sprite button;
[Range(20, 100)]
public float canvasSize;
[Range(-1, 1)]
public float canvasXPosition, canvasYPosition;
public float spritePadding, buttonYOffset;
public enum MarketPlaces {PC, mobileTablet};
[Header("Rate settings")] // just move to here!
public MarketPlaces compileFor = MarketPlaces.PC;
public string rateLink;