public void OnToggleBenchmarkCallBack() { this.Destroy(); MonoBenchmarkSwitches switches = UnityEngine.Object.FindObjectOfType <MonoBenchmarkSwitches>(); if (switches == null) { GameObject target = new GameObject(); UnityEngine.Object.DontDestroyOnLoad(target); target.name = "__Benchmark"; target.AddComponent <MonoBenchmarkSwitches>(); } else { UnityEngine.Object.Destroy(switches.gameObject); } }
public void OnBenchmarkToggle(bool isOn) { MonoBenchmarkSwitches switches = UnityEngine.Object.FindObjectOfType <MonoBenchmarkSwitches>(); if (switches == null) { if (isOn) { System.Type[] components = new System.Type[] { typeof(MonoBenchmarkSwitches) }; new GameObject("__benchmark", components); } } else { switches.gameObject.SetActive(isOn); } }