UnityEditor.ContainerWindow.SetMinMaxSizes C# (CSharp) Method

SetMinMaxSizes() public method

public SetMinMaxSizes ( Vector2 min, Vector2 max ) : void
min Vector2
max Vector2
return void
        public void SetMinMaxSizes(Vector2 min, Vector2 max)
        {
            this.m_MinSize = min;
            this.m_MaxSize = max;
            Rect position = this.position;
            Rect rect2 = position;
            rect2.width = Mathf.Clamp(position.width, min.x, max.x);
            rect2.height = Mathf.Clamp(position.height, min.y, max.y);
            if ((rect2.width != position.width) || (rect2.height != position.height))
            {
                this.position = rect2;
            }
            this.Internal_SetMinMaxSizes(min, max);
        }

Usage Example

        internal void ShowWithMode(ShowMode mode)
        {
            if (m_Parent == null)
            {
                SavedGUIState oldState = SavedGUIState.Create();

                ContainerWindow cw = ScriptableObject.CreateInstance <ContainerWindow>();
                cw.title = titleContent.text;
                HostView host = ScriptableObject.CreateInstance <HostView>();
                host.actualView = this; // Among other things, this sets m_Parent to host

                Rect r = m_Parent.borderSize.Add(new Rect(position.x, position.y, position.width, position.height));
                // Order is important here: first set rect of container, then assign main view, then apply various settings, then show.
                // Otherwise the rect won't be set until first resize happens.
                cw.position = r;
                cw.rootView = host;
                MakeParentsSettingsMatchMe();
                cw.Show(mode, loadPosition: true, displayImmediately: false, setFocus: true);
                // set min/max size now that native window is not null so that it will e.g., use proper styleMask on macOS
                cw.SetMinMaxSizes(minSize, maxSize);

                oldState.ApplyAndForget();
            }
        }