예제 #1
0
 protected virtual void Draw(Rect drawPosition)
 {
     drawer.Draw(drawPosition);
 }
예제 #2
0
        public void UpdateDimensions(bool drawOnScreen, bool drawOffscreen, Rect inspectorWindowRect, float toolbarHeight, float previewAreaHeight)
        {
                        #if DEV_MODE && DEBUG_UPDATE_DIMENSIONS
            bool windowRectChanged = windowRect != inspectorWindowRect;
                        #endif

            windowRect = inspectorWindowRect;

                        #if DEV_MODE && DEBUG_UPDATE_CONTENT_RECT
            var componentHeights = "";
                        #endif

            float contentHeight = 0f;
            int   goCount       = drawers.Length;
            for (var i = 0; i < goCount; i++)
            {
                var drawer = drawers[i];
                if (drawer != null)
                {
                    if (drawOnScreen)
                    {
                        //this is needed because some Drawer can only calculate their heights during the OnGUI phase
                        GUI.changed = false;
                        drawers.Draw(inspectorWindowRect);
                    }
                    else if (drawOffscreen)
                    {
                        //this is needed because some Drawer can only calculate their heights during the OnGUI phase
                        GUI.changed = false;
                        drawers.Draw(ZeroSizeRect);
                    }

                    float drawerHeight = drawer.Height;
                    contentHeight += drawerHeight;

                                        #if DEV_MODE && DEBUG_UPDATE_CONTENT_RECT
                    var members = (drawer as IParentDrawer).VisibleMembers;
                    componentHeights = "\n" + drawer.ToString() + " " + members.Length + " VisibleMembers:";
                    foreach (var member in (drawer as IParentDrawer).VisibleMembers)
                    {
                        var parent = member as IParentDrawer;
                        if (parent != null)
                        {
                            componentHeights += "\n" + member.Type.Name + " : " + member.Height + " (Unfolded=" + parent.Unfolded + ", Unfoldedness=" + parent.Unfoldedness + ")";
                        }
                        else
                        {
                            componentHeights += "\n" + member.Type.Name + " : " + member.Height;
                        }
                    }
                                        #endif
                }
            }

                        #if DEV_MODE && DEBUG_UPDATE_DIMENSIONS
            if (windowRectChanged)
            {
                Debug.Log("windowRect = " + windowRect);
            }
                        #endif

            bool heightChanged = false;
            if (!Mathf.Approximately(contentRect.height, contentHeight))
            {
                                #if DEV_MODE && DEBUG_UPDATE_CONTENT_RECT
                Debug.Log("contentHeight = " + contentHeight + " ( was " + contentRect.height + "). Event=" + StringUtils.ToString(Event.current) + componentHeights);
                                #endif

                contentRect.height = contentHeight;
                heightChanged      = true;

                                #if DEV_MODE && DEBUG_CAN_HAVE_SCROLLBAR
                if (drawer.Length >= 1)
                {
                    Debug.Log("CanHaveScrollBar: " + StringUtils.ToColorizedString(CanHaveScrollBar()) + " with drawer[0] " + drawer[0] + " is IScrollable: " + StringUtils.ToColorizedString(drawer[0] is IScrollable));
                }
                                #endif
            }

            float setWidth;
            if (CanHaveScrollBar() && toolbarHeight + contentHeight + previewAreaHeight > inspectorWindowRect.height)
            {
                setWidth     = inspectorWindowRect.width - DrawGUI.ScrollBarWidth;
                HasScrollBar = true;
            }
            else
            {
                setWidth     = inspectorWindowRect.width;
                HasScrollBar = false;
            }

            bool widthChanged = false;
            if (!Mathf.Approximately(contentRect.width, setWidth))
            {
                contentRect.width = setWidth;
                widthChanged      = true;
            }

            if (widthChanged && OnWidthChanged != null)
            {
                OnWidthChanged();
            }

            if (heightChanged && OnHeightChanged != null)
            {
                OnHeightChanged(contentHeight);
            }
        }