预定义类型


Edit—> projectsetting—> Player
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Debuger//日志输出类
{
//预定义
#if Debug
static bool debug = true;
#else
static bool debug = false;
#endif
public static void Log(string value)
{
if (debug)
{
Debug.Log(value);
}
}
public static void LogError(string value)
{
if (debug)
{
Debug.LogError(value);
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TestDebug : MonoBehaviour
{
public GameObject obj;
// Start is called before the first frame update
void Start()
{
Debuger.Log(“Start==========在调试”);
}

// Update is called once per frame
void Update()
{
    
    if(obj == null)
    {
        Debuger.LogError("obj reference is null");
    }
    else
    {
        string str = obj.name;
    }
}

}

猜你喜欢

转载自blog.csdn.net/bellainvan/article/details/108991503
今日推荐