如果自己定义的宏,先走自己的宏,如果注释掉,就走后面的判断。
如下定义2个,只走第1个
//Unity-宏使用
//如果自己定义的宏,先走自己的宏,如果注释掉,就走后面的判断。
//如下定义2个,只走第1个
#define MYDEVICE
#define MYDEVICE2
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Demo : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
#if MYDEVICE
print("MYDEVICE");
#elif UNITY_EDITOR
print("UNITY_EDITOR");
#else
print("else");
#endif
}
}
#define MYDEVICE3
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Demo2 : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
#if MYDEVICE3
print("MYDEVICE3");
#elif UNITY_EDITOR
print("UNITY_EDITOR");
#else
print("else");
#endif
}
}