kingBook

导航

C# 定义宏

#define ENABLE_TEST // 必须在 using 的上方定义

using System.Collections;
using UnityEngine;

public class TestDefine : MonoBehaviour {

    void Start () {
#if ENABLE_TEST
        Debug.Log("Test");
#else
        Debug.Log("Hello");
#endif
    }


}
  • 在 Unity 中,也可以在 Edit -> Project Settings -> Other Settings 选项中的 Scripting Define Symbols 定义宏

posted on 2022-03-24 09:23  kingBook  阅读(2371)  评论(0编辑  收藏  举报