public void DoDeinit(System.Action callback)
        {
            if (this.instance != null)
            {
                this.instance.DoDeinit(callback);
            }

            this.instance   = null;
            this.components = null;
        }
        public void Create(WindowBase window, Transform root, float depth, int raycastPriority, int orderInLayer, System.Action callback, bool async)
        {
            if (this.stopped == true)
            {
                return;
            }

            this.window = window;

            System.Action <WindowLayout> onLoaded = (layout) => {
                if (this.stopped == true)
                {
                    return;
                }

                var instance = layout.Spawn(activeByDefault: false);
                instance.transform.SetParent(root);
                instance.transform.localPosition = Vector3.zero;
                instance.transform.localRotation = Quaternion.identity;
                instance.transform.localScale    = Vector3.one;

                var rect = instance.transform as RectTransform;
                rect.sizeDelta        = (layout.transform as RectTransform).sizeDelta;
                rect.anchoredPosition = (layout.transform as RectTransform).anchoredPosition;

                var layoutPreferences = this.layoutPreferences;
                if (this.allowCustomLayoutPreferences == true)
                {
                    layoutPreferences = WindowSystem.GetCustomLayoutPreferences() ?? this.layoutPreferences;
                }

                instance.Setup(window);
                instance.Init(depth, raycastPriority, orderInLayer);
                instance.SetLayoutPreferences(this.scaleMode, this.fixedScaleResolution, layoutPreferences);

                this.instance = instance;

                ME.Utilities.CallInSequence(() => {
                    if (this.stopped == true)
                    {
                        return;
                    }

                    instance.gameObject.SetActive(true);
                    callback.Invoke();
                }, this.components, (component, c) => {
                    component.Create(window, instance.GetRootByTag(component.tag), (comp) => c.Invoke(), async);
                }, waitPrevious: true);
            };

            WindowLayout loadedComponent = null;

            if (this.layoutResource.IsLoadable() == true)
            {
                WindowSystemResources.LoadRefCounter <WindowLayout>(this, (layout) => {
                    loadedComponent = layout;
                    onLoaded.Invoke(loadedComponent);

                    WindowSystemResources.Unload(this, this.GetResource(), resetController: false);
                }, () => {
                                        #if UNITY_EDITOR
                    Debug.LogWarningFormat("[ Layout ] Resource request failed {0} [{1}].", UnityEditor.AssetDatabase.GetAssetPath(this.layout.GetInstanceID()), window.name);
                                        #endif
                }, async);
                return;
            }
            else
            {
                loadedComponent = this.layoutNoResource;
                                #if UNITY_EDITOR
                if (loadedComponent != null)
                {
                    Debug.LogWarningFormat("[ Layout ] Resource `{0}` [{1}] should be placed in `Resources` folder to be loaded/unloaded automaticaly. Window `{2}` requested this resource. This warning shown in editor only.", loadedComponent.name, UnityEditor.AssetDatabase.GetAssetPath(loadedComponent.GetInstanceID()), window.name);
                }
                                #endif
            }

            onLoaded.Invoke(loadedComponent);
        }