private void OnDestroyScene()
        {
            _delayedWindows.Clear();
            _openedWindows.Clear();

            _sceneHelper.DestroyEvent.RemoveListener(OnDestroyScene);
            _sceneHelper = null;
        }
        public IWindow ShowWindow(string windowId, object[] args = null, bool isUnique = false, bool overlap = false)
        {
            if (!_windowsMap.TryGetValue(windowId, out var prefab))
            {
                Debug.LogErrorFormat("Window with Id {0} isn't registered in Manager.", windowId);
                return(null);
            }

            if (!_sceneHelper)
            {
                _sceneHelper = new GameObject(@"WindowManagerLocalSceneHelper",
                                              typeof(WindowManagerLocalSceneHelper))
                               .GetComponent <WindowManagerLocalSceneHelper>();
                _sceneHelper.DestroyEvent.AddListener(OnDestroyScene);
            }

            var instance = Instantiate(prefab, Vector3.zero, Quaternion.identity);

            instance.name = windowId;

            var window = instance.GetComponent <IWindow>();

            Assert.IsNotNull(window, "Window prefab must implements IWindow.");

            InitWindow(window, args ?? new object[0]);

            if (_isUnique || isUnique && _openedWindows.Count > 0)
            {
                window.Canvas.gameObject.SetActive(false);
                _delayedWindows.Add(new DelayedWindow(window, isUnique, overlap));
            }
            else
            {
                DoApplyWindow(window, isUnique, overlap);
            }

            return(window);
        }