protected override void OnReset()
        {
            Type type = this.GetType();
            LayoutViewDisplayAttributeAttribute settings = AttributeUtility.FindAttribute <LayoutViewDisplayAttributeAttribute>(type);

            if (settings == null)
            {
                throw new MissingReferenceException("Missing [LayoutSceneViewDisplay] attribute declaration for the class '" + type.Name + "'");
            }

            SceneView sceneView = SceneView.currentDrawingSceneView;

            if (sceneView == null)
            {
                StratusDebug.Log("No scene view?");
                return;
            }

            // Read and set the properties fron the attribute
            this.title      = settings.GetProperty <string>("title");
            this.size       = new Vector2(settings.GetProperty <float>("width"), settings.GetProperty <float>("height"));
            this.anchor     = settings.GetProperty <StratusGUI.Anchor>("anchor");
            this.dimensions = settings.GetProperty <StratusGUI.Dimensions>("dimensions");
            // If the size is relative...
            if (this.dimensions == StratusGUI.Dimensions.Relative)
            {
                this.scale = this.size;
            }
            // Calcualte the rect

            this.currentSize = this.CalculateSize(sceneView);
            this.rect        = StratusGUI.CalculateAnchoredPositionOnScreen(this.anchor, this.currentSize, sceneView.position.size);
        }
Exemple #2
0
        private void DrawVisualization()
        {
            GUIContent msg  = new GUIContent($"<color=#{debugTextColorHex}>{label}.{currentSegment.label}</color>");
            Vector2    size = StratusGUIStyles.header.CalcSize(msg);
            Rect       rect = StratusGUI.CalculateAnchoredPositionOnScreen(windowAnchor, size);

            GUILayout.BeginArea(rect);
            GUILayout.Label(msg, StratusGUIStyles.header);
            GUILayout.EndArea();
        }
        /// <summary>
        /// Invoked by the Unity's Scene window. This is where we hook in our own drawing code
        /// </summary>
        /// <param name="sceneView"></param>
        protected override void OnSceneGUI(SceneView sceneView)
        {
            //if (!hasCalculatedDimensions && dimensions == StratusGUI.Dimensions.Relative)
            //{
            //  size = StratusGUI.FindRelativeDimensions(scale, sceneView.position.size);
            //  hasCalculatedDimensions = true;
            //}

            // What size to use
            if (dimensions == StratusGUI.Dimensions.Absolute)
            {
                currentSize = size;
            }
            else if (dimensions == StratusGUI.Dimensions.Relative)
            {
                currentSize = StratusGUI.FindRelativeDimensions(scale, sceneView.position.size);
            }

            // Draw the default GUI
            OnGUI(sceneView.position);

            // Draw the provided layout 2D GUI Block
            Rect layoutPosition = StratusGUI.CalculateAnchoredPositionOnScreen(anchor, currentSize, sceneView.position.size);

            Handles.BeginGUI();
            {
                GUILayout.BeginArea(layoutPosition, title, GUI.skin.window);
                {
                    //GUILayout.Label(layoutPosition, "+");
                    scrollPos = GUILayout.BeginScrollView(scrollPos, false, false);
                    this.OnGUILayout(layoutPosition);
                    GUILayout.EndScrollView();
                }
                GUILayout.EndArea();
                //if (StratusEditorUtility.IsMousedOver(layoutPosition) && !StratusEditorUtility.currentEventUsed)
                //{
                //  System.Action onRightClick = () =>
                //  {
                //    var menu = new GenericMenu();
                //    menu.AddItem(new GUIContent("Select"), false, () => { Trace.Script("Boop"); });
                //  };
                //  StratusEditorUtility.OnMouseClick(null, onRightClick, null);
                //
                //}
                //StratusEditorUtility.DisableMouseSelection(layoutPosition);
            }
            Handles.EndGUI();

            //if (StratusEditorUtility.IsMousedOver(layoutPosition))
            //{
            //  int control = GUIUtility.GetControlID(FocusType.Passive);
            //}
            //
            //GUIUtility.hotControl = control;
        }
        private void DrawRow(Rect rowRect, int index)
        {
            if (this.list.currentEntries[index].index == this.selectedIndex)
            {
                StratusGUI.GUIBox(rowRect, selectedColor, SelectionStyle);
            }
            else if (index == this.hoverIndex)
            {
                StratusGUI.GUIBox(rowRect, defaultColor, SelectionStyle);
            }

            rowRect.xMin += rowIndent;
            GUI.Label(rowRect, this.list.currentEntries[index].item.value);
        }
Exemple #5
0
        private void OnGUI()
        {
            if (!draw)
            {
                return;
            }

            Rect layoutPosition = StratusGUI.CalculateAnchoredPositionOnScreen(anchor, size, screenSize);

            GUILayout.BeginArea(layoutPosition, title, StratusGUIStyles.skin.window);
            scrollPos = GUILayout.BeginScrollView(scrollPos, false, false);
            OnGUILayout(layoutPosition);
            GUILayout.EndScrollView();
            GUILayout.EndArea();
        }
        private Vector2 CalculateSize(SceneView sceneView)
        {
            Vector2 size = new Vector2();

            switch (this.dimensions)
            {
            case StratusGUI.Dimensions.Relative:
                size = StratusGUI.CalculateRelativeDimensions(this.scale, sceneView.position.size);
                break;

            case StratusGUI.Dimensions.Absolute:
                size = this.size;
                break;
            }
            return(size);
        }
        private void Draw_Old(SceneView sceneView)
        {
            Rect layoutPosition = StratusGUI.CalculateAnchoredPositionOnScreen(this.anchor, this.currentSize, sceneView.position.size);

            Handles.BeginGUI();
            {
                GUILayout.BeginArea(layoutPosition, this.title, GUI.skin.window);
                {
                    this.scrollPos = GUILayout.BeginScrollView(this.scrollPos, false, false);
                    this.OnGUILayout(layoutPosition);
                    GUILayout.EndScrollView();
                }
                GUILayout.EndArea();
            }
            Handles.EndGUI();
        }