Unity小知识

2019-12-03  本文已影响0人  super41

编辑器相关

public class GameRoot
{
    [RuntimeInitializeOnLoadMethod]
    private static void GameStar()
    {
        Debug.Log("------Game Star------");
    }
  //运行游戏后即可看到Game Star打印出来。
  //注意:方法必须为static才能被回调。类可以不继承MonoBehaviour,不影响
}
  public enum PanelLayer
    {
        Low,
        Mid,
        High,
        Top,
    }
for 遍历
  Array panelArray = Enum.GetValues(typeof(PanelLayer));
  for (int i = 0; i < panelArray.Length; i++)
   {
      PanelLayer item = (PanelLayer) panelArray.GetValue(i);
      Debug.Log(item.ToString() +" "+(int)item);
   }
foreach 遍历
  foreach (PanelLayer item in Enum.GetValues(typeof(PanelLayer)))
  {
    Debug.Log(item.ToString() +" "+(int)item);
  }
上一篇下一篇

猜你喜欢

热点阅读