#if UNITY_EDITORusing System.Collections;using System.Collections.Generic;using UnityEngine;using UnityEditor;namespace GM{ public class GMTools { private const string ShowLogMenuPath = "Tools/GM/显示Log"; [MenuItem("Tools/GM/显示Log")] public static void ShowLogTool() { Menu.SetChecked(ShowLogMenuPath, !Menu.GetChecked(ShowLogMenuPath)); } public static bool ShouldShowLog{ get { return Menu.GetChecked(ShowLogMenuPath); } } }}#endifusing System.Collections;using System.Collections.Generic;using UnityEngine;public class Test : MonoBehaviour{ // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { if (UnityEngine.Input.GetKeyDown(KeyCode.Space)) { ShowLog("显示log111"); Debug.Log("显示log222"); } } public void ShowLog(string str) {#if UNITY_EDITOR if (GM.GMTools.ShouldShowLog) { Debug.Log(str); } }#endif}