Пример #1
0
        void Remove(EditorPopupContent epc)
        {
            var beforeCount = _contents.Count;

            for (int i = 0; i < _contents.Count; ++i)
            {
                if (_contents[i] == epc)
                {
                    // _contents.RemoveRange(i, _contents.Count - i);
                    for (int j = _contents.Count - 1; j >= i; --j)
                    {
                        _contents[j].OnClose();
                        _contents.RemoveAt(j);
                    }
                    break;
                }
            }

            if (_contents.Count == 0)
            {
                Close();
                GUIUtility.ExitGUI();
            }
            else if (_contents.Count != beforeCount)
            {
                Repaint();
            }
        }
Пример #2
0
 internal static void Close(EditorPopupContent windowContent)
 {
     if (_inst == null)
     {
         return;
     }
     _inst._removeBuf.Add(windowContent);
 }
Пример #3
0
        internal static void Show(EditorPopupContent windowContent)
        {
            if (_inst == null)
            {
                _inst = ScriptableObject.CreateInstance <EditorPopupHolderWindow>();
                // _ShowAsDropDownFitToScreen = typeof(EditorWindow).GetMethod("ShowAsDropDownFitToScreen", BindingFlags.Instance | BindingFlags.NonPublic);
            }

            if (_inst._contents.Count == 0)
            {
                _coveredResolution = new Rect(0, 0, Screen.currentResolution.width, Screen.currentResolution.height);
                _bgWindows         = Resources.FindObjectsOfTypeAll <EditorWindow>();
                foreach (var window in _bgWindows)
                {
                    // Debug.LogFormat("{0} {1}", window.GetType().Name, window.name);
                    if (_inst == window)
                    {
                        continue;
                    }
                    _coveredResolution.xMin = Mathf.Min(_coveredResolution.xMin, window.position.xMin);
                    _coveredResolution.yMin = Mathf.Min(_coveredResolution.yMin, window.position.yMin);
                    _coveredResolution.xMax = Mathf.Max(_coveredResolution.xMax, window.position.xMax);
                    _coveredResolution.yMax = Mathf.Max(_coveredResolution.yMax, window.position.yMax);
                }
                // Debug.Log(res);

                if (_texBuf == null || _texBuf.width != _coveredResolution.width || _texBuf.height != _coveredResolution.height)
                {
                    _texBuf           = new Texture2D((int)_coveredResolution.width, (int)_coveredResolution.height);
                    _texBuf.hideFlags = HideFlags.DontSave;
                }

                var pixels = UnityEditorInternal.InternalEditorUtility.ReadScreenPixel(_coveredResolution.position, (int)_coveredResolution.width, (int)_coveredResolution.height);
                _texBuf.SetPixels(pixels);
                _texBuf.Apply();
                // var rect = new Rect(0, 0, res.width, res.height);
                var rect = _coveredResolution;
                // rect.position = GUIUtility.GUIToScreenPoint(rect.position);
                _inst.minSize  = new Vector2(rect.width, rect.height);
                _inst.maxSize  = new Vector2(rect.width, rect.height);
                _inst.position = rect;
            }

            // _inst.ShowPopup();
            _inst.Add(windowContent);
            if (focusedWindow != _inst)
            {
                _inst.Focus();
            }
            GUIUtility.ExitGUI();
        }
Пример #4
0
        void Add(EditorPopupContent epc)
        {
            if (_contents.Contains(epc))
            {
                return;                          // ?
            }
            epc._lastSize      = epc.GetWindowSize();
            epc._activatorRect = GUIToScreenRect(epc._activatorRect);
            // ar.position = GUIUtility.GUIToScreenPoint(ar.position);
            var contentRect = GetPopupRect(epc._activatorRect, epc._lastSize);

            // contentRect.position = GUIUtility.ScreenToGUIPoint(contentRect.position);
            epc._position = contentRect;
            epc.OnOpen();
            ShowPopup();
            _contents.Add(epc);
        }