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;
}
}
}