static void RunTimeInit() { if (GameObject.FindObjectOfType <UIRoot>() == null) { var prefab = BuiltInAssets.LoadPrefab("UIRoot"); var instance = GameObject.Instantiate(prefab); instance.name = "UIRoot"; DontDestroyOnLoad(instance); } }
public static void CreateUIRoot() { var uiroot = GameObject.FindObjectOfType <UIRoot>(); if (uiroot == null) { var prefab = BuiltInAssets.LoadPrefab("UIRoot"); var instance = GameObject.Instantiate(prefab); instance.name = "UIRoot"; uiroot = instance.GetComponent <UIRoot>(); var windowRoot = uiroot.transform.GetChildTransformDeeply("WindowRoot"); if (windowRoot != null) { Selection.activeObject = windowRoot; } var uicamera = uiroot.GetComponentInChildren <Camera>(true); uicamera.clearFlags = CameraClearFlags.SolidColor; } }
private void OnEnable() { if (!Application.isPlaying) { var uiroot = GameObject.FindObjectOfType <UIRoot>(); if (uiroot == null) { var prefab = BuiltInAssets.LoadPrefab("UIRoot"); var instance = GameObject.Instantiate(prefab); instance.name = "UIRoot"; uiroot = instance.GetComponent <UIRoot>(); var uicamera = uiroot.GetComponentInChildren <Camera>(true); uicamera.clearFlags = CameraClearFlags.SolidColor; } var windowRoot = uiroot.transform.GetChildTransformDeeply("WindowRoot"); if (windowRoot != null) { (this.transform as RectTransform).MatchWhith(windowRoot as RectTransform); } } }