예제 #1
0
 static void RunTimeInit()
 {
     if (GameObject.FindObjectOfType <UIRoot>() == null)
     {
         var prefab   = BuiltInAssets.LoadPrefab("UIRoot");
         var instance = GameObject.Instantiate(prefab);
         instance.name = "UIRoot";
         DontDestroyOnLoad(instance);
     }
 }
예제 #2
0
    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;
        }
    }
예제 #3
0
    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);
            }
        }
    }