Ejemplo n.º 1
0
            /// <summary>
            /// Draw the control point onto Scene view
            /// </summary>
            public void DrawHandles()
            {
#if UNITY_EDITOR
                bool isCtrlKeyHold  = Event.current != null && Event.current.control;
                bool isShiftKeyHold = Event.current != null && Event.current.shift;

                //drag to move control point's position
                EditorHandles.color = Color.blue;
                Vector3 oldPosition = Position;
                Vector3 newPosition = EditorHandles.FreeMoveHandle(
                    Position,
                    Quaternion.identity,
                    HandleUtility.GetHandleSize(Position) * 0.2f,
                    Vector3.zero,
                    EditorHandles.CircleHandleCap);
                newPosition.y = oldPosition.y; //restrict Y-axis movement
                if (newPosition != oldPosition)
                {
                    if (isShiftKeyHold)
                    {
                        newPosition = SnapPosition(newPosition);
                    }
                    if (isCtrlKeyHold)
                    {
                        Translate(newPosition - oldPosition);
                    }
                    else
                    {
                        Position = newPosition;
                    }
                }

                //drag to move handle's position
                EditorHandles.color = Color.red;
                for (int i = 0; i < Handles.Length; ++i)
                {
                    Vector3 handleOldPosition = Handles[i];
                    Vector3 handleNewPosition = EditorHandles.FreeMoveHandle(
                        Handles[i],
                        Quaternion.identity,
                        HandleUtility.GetHandleSize(Handles[i]) * 0.1f,
                        Vector3.zero,
                        EditorHandles.RectangleHandleCap);
                    handleNewPosition.y = handleOldPosition.y; //restrict Y-axis movement

                    if (Handles[i] != handleNewPosition)
                    {
                        if (isShiftKeyHold)
                        {
                            handleNewPosition = SnapHandle(handleNewPosition);
                        }
                        SetHandle(i, handleNewPosition);
                        if (isCtrlKeyHold)
                        {
                            Vector3 reflectedPosition = handleNewPosition + 2 * (Position - handleNewPosition);
                            SetHandle(Handles.Length - 1 - i, reflectedPosition);
                        }
                    }
                    EditorHandles.DrawLine(Handles[i], Position);
                }
#endif
            }
Ejemplo n.º 2
0
        internal static void RuleMatrixOnGUI(RuleTile tile, Rect rect, RuleTile.TilingRule tilingRule)
        {
            Handles.color = EditorGUIUtility.isProSkin ? new Color(1f, 1f, 1f, 0.2f) : new Color(0f, 0f, 0f, 0.2f);
            int   index = 0;
            float w     = rect.width / 3f;
            float h     = rect.height / 3f;

            for (int y = 0; y <= 3; y++)
            {
                float top = rect.yMin + y * h;
                Handles.DrawLine(new Vector3(rect.xMin, top), new Vector3(rect.xMax, top));
            }
            for (int x = 0; x <= 3; x++)
            {
                float left = rect.xMin + x * w;
                Handles.DrawLine(new Vector3(left, rect.yMin), new Vector3(left, rect.yMax));
            }
            Handles.color = Color.white;

            for (int y = 0; y <= 2; y++)
            {
                for (int x = 0; x <= 2; x++)
                {
                    Rect r = new Rect(rect.xMin + x * w, rect.yMin + y * h, w - 1, h - 1);
                    if (x != 1 || y != 1)
                    {
                        tile.RuleOnGUI(r, new Vector2Int(x, y), tilingRule.m_Neighbors[index]);
                        if (Event.current.type == EventType.MouseDown && r.Contains(Event.current.mousePosition))
                        {
                            int change = 1;
                            if (Event.current.button == 1)
                            {
                                change = -1;
                            }

                            var allConsts = tile.m_NeighborType.GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy);
                            var neighbors = allConsts.Select(c => (int)c.GetValue(null)).ToList();
                            neighbors.Sort();

                            int oldIndex = neighbors.IndexOf(tilingRule.m_Neighbors[index]);
                            int newIndex = (int)Mathf.Repeat(oldIndex + change, neighbors.Count);
                            tilingRule.m_Neighbors[index] = neighbors[newIndex];
                            GUI.changed = true;
                            Event.current.Use();
                        }

                        index++;
                    }
                    else
                    {
                        switch (tilingRule.m_RuleTransform)
                        {
                        case RuleTile.TilingRule.Transform.Rotated:
                            GUI.DrawTexture(r, autoTransforms[0]);
                            break;

                        case RuleTile.TilingRule.Transform.MirrorX:
                            GUI.DrawTexture(r, autoTransforms[1]);
                            break;

                        case RuleTile.TilingRule.Transform.MirrorY:
                            GUI.DrawTexture(r, autoTransforms[2]);
                            break;
                        }

                        if (Event.current.type == EventType.MouseDown && r.Contains(Event.current.mousePosition))
                        {
                            tilingRule.m_RuleTransform = (RuleTile.TilingRule.Transform)(((int)tilingRule.m_RuleTransform + 1) % 4);
                            GUI.changed = true;
                            Event.current.Use();
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
        protected void DrawInspectedRect(Rect instructionRect)
        {
            var totalRect = GUILayoutUtility.GetRect(0, 100);

            var reserveTopFieldHeight    = Mathf.CeilToInt(EditorGUI.kSingleLineHeight * 2 + EditorGUI.kControlVerticalSpacing);
            var reserveBottomFieldHeight = Mathf.CeilToInt(EditorGUI.kSingleLineHeight);
            var reserveFieldWidth        = 100;
            var fieldsArea = new RectOffset(50, reserveFieldWidth, reserveTopFieldHeight, reserveBottomFieldHeight);
            var visualRect = fieldsArea.Remove(totalRect);

            float aspectRatio  = instructionRect.width / instructionRect.height;
            var   aspectedRect = new Rect();
            var   dummy        = new Rect();

            GUI.CalculateScaledTextureRects(visualRect, ScaleMode.ScaleToFit, aspectRatio, ref aspectedRect, ref dummy);
            visualRect        = aspectedRect;
            visualRect.width  = Mathf.Max(80, visualRect.width);
            visualRect.height = Mathf.Max(EditorGUI.kSingleLineHeight + 10, visualRect.height);

            var startPointFieldRect = new Rect();

            startPointFieldRect.height = EditorGUI.kSingleLineHeight;
            startPointFieldRect.width  = fieldsArea.left * 2;
            startPointFieldRect.y      = visualRect.y - fieldsArea.top;
            startPointFieldRect.x      = visualRect.x - startPointFieldRect.width / 2f;

            var endPointFieldRect = new Rect
            {
                height = EditorGUI.kSingleLineHeight,
                width  = fieldsArea.right * 2,
                y      = visualRect.yMax
            };

            endPointFieldRect.x = visualRect.xMax - endPointFieldRect.width / 2f;

            var widthMarkersArea = new Rect
            {
                x      = visualRect.x,
                y      = startPointFieldRect.yMax + EditorGUI.kControlVerticalSpacing,
                width  = visualRect.width,
                height = EditorGUI.kSingleLineHeight
            };

            var widthFieldRect = widthMarkersArea;

            widthFieldRect.width = widthMarkersArea.width / 3;
            widthFieldRect.x     = widthMarkersArea.x + (widthMarkersArea.width - widthFieldRect.width) / 2f;

            var heightMarkerArea = visualRect;

            heightMarkerArea.x     = visualRect.xMax;
            heightMarkerArea.width = EditorGUI.kSingleLineHeight;

            var heightFieldRect = heightMarkerArea;

            heightFieldRect.height = EditorGUI.kSingleLineHeight;
            heightFieldRect.width  = fieldsArea.right;
            heightFieldRect.y      = heightFieldRect.y + (heightMarkerArea.height - heightFieldRect.height) / 2f;

            //Draw TopLeft point
            GUI.Label(startPointFieldRect, UnityString.Format("({0},{1})", instructionRect.x, instructionRect.y), Styles.centeredLabel);

            Handles.color = new Color(1, 1, 1, 0.5f);
            //Draw Width markers and value
            var startP = new Vector3(widthMarkersArea.x, widthFieldRect.y);
            var endP   = new Vector3(widthMarkersArea.x, widthFieldRect.yMax);

            Handles.DrawLine(startP, endP);

            startP.x = endP.x = widthMarkersArea.xMax;
            Handles.DrawLine(startP, endP);

            startP.x = widthMarkersArea.x;
            startP.y = endP.y = Mathf.Lerp(startP.y, endP.y, .5f);
            endP.x   = widthFieldRect.x;
            Handles.DrawLine(startP, endP);

            startP.x = widthFieldRect.xMax;
            endP.x   = widthMarkersArea.xMax;
            Handles.DrawLine(startP, endP);

            GUI.Label(widthFieldRect, instructionRect.width.ToString(), Styles.centeredLabel);

            //Draw Height markers and value
            startP = new Vector3(heightMarkerArea.x, heightMarkerArea.y);
            endP   = new Vector3(heightMarkerArea.xMax, heightMarkerArea.y);
            Handles.DrawLine(startP, endP);

            startP.y = endP.y = heightMarkerArea.yMax;
            Handles.DrawLine(startP, endP);

            startP.x = endP.x = Mathf.Lerp(startP.x, endP.x, .5f);
            startP.y = heightMarkerArea.y;
            endP.y   = heightFieldRect.y;
            Handles.DrawLine(startP, endP);

            startP.y = heightFieldRect.yMax;
            endP.y   = heightMarkerArea.yMax;
            Handles.DrawLine(startP, endP);

            GUI.Label(heightFieldRect, instructionRect.height.ToString());

            GUI.Label(endPointFieldRect, UnityString.Format("({0},{1})", instructionRect.xMax, instructionRect.yMax), Styles.centeredLabel);

            //Draws the rect
            GUI.Box(visualRect, GUIContent.none);
        }
        private void OnGUI()
        {
            HandleContextMenu();

            EditorGUILayout.BeginVertical();
            GUILayout.Space(10f);
            EditorGUILayout.BeginHorizontal();
            float leftMargin = (Screen.width / EditorGUIUtility.pixelsPerPoint - Styles.toolbarWidth) * 0.5f;

            GUILayout.Space(leftMargin);
            EditMode.DoInspectorToolbar(Styles.sceneViewEditModes, Styles.toolContents, GridPaintingState.instance);
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();
            GUILayout.Space(leftMargin);
            DoActiveTargetsGUI();
            EditorGUILayout.EndHorizontal();
            GUILayout.Space(6f);
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical();
            Rect clipboardToolbarRect = EditorGUILayout.BeginHorizontal(GUIContent.none, "Toolbar");

            DoClipboardHeader();
            EditorGUILayout.EndHorizontal();
            Rect  dragRect           = new Rect(k_DropdownWidth + k_ResizerDragRectPadding, 0, position.width - k_DropdownWidth - k_ResizerDragRectPadding, k_ToolbarHeight);
            float brushInspectorSize = m_PreviewResizer.ResizeHandle(position, k_MinBrushInspectorHeight, k_MinClipboardHeight, k_ToolbarHeight, dragRect);
            float clipboardHeight    = position.height - brushInspectorSize - k_TopAreaHeight;
            Rect  clipboardRect      = new Rect(0f, clipboardToolbarRect.yMax, position.width, clipboardHeight);

            OnClipboardGUI(clipboardRect);
            EditorGUILayout.EndVertical();

            GUILayout.Space(clipboardRect.height);

            EditorGUILayout.BeginVertical();
            EditorGUILayout.BeginHorizontal(GUIContent.none, "Toolbar");
            DoBrushesDropdown();
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();
            m_BrushScroll = GUILayout.BeginScrollView(m_BrushScroll, false, false);
            GUILayout.Space(5f);
            OnBrushInspectorGUI();
            GUILayout.EndScrollView();
            EditorGUILayout.EndVertical();

            Color oldColor = Handles.color;

            Handles.color = Color.black;
            Handles.DrawLine(new Vector3(0, clipboardRect.yMax + 0.5f, 0), new Vector3(Screen.width, clipboardRect.yMax + 0.5f, 0));
            Handles.color = Color.black.AlphaMultiplied(0.33f);
            Handles.DrawLine(new Vector3(0, GUILayoutUtility.GetLastRect().yMax + 0.5f, 0), new Vector3(Screen.width, GUILayoutUtility.GetLastRect().yMax + 0.5f, 0));
            Handles.color = oldColor;

            EditorGUILayout.BeginVertical();

            GUILayout.Space(2f);

            EditorGUILayout.EndVertical();

            // Keep repainting until all previews are loaded
            if (AssetPreview.IsLoadingAssetPreviews(GetInstanceID()))
            {
                Repaint();
            }

            // Release keyboard focus on click to empty space
            if (Event.current.type == EventType.MouseDown)
            {
                GUIUtility.keyboardControl = 0;
            }
        }
Ejemplo n.º 5
0
        private static void RuleMatrixOnGUI(Rect rect, RuleTile.TilingRule tilingRule)
        {
            Handles.color = EditorGUIUtility.isProSkin ? new Color(1f, 1f, 1f, 0.2f) : new Color(0f, 0f, 0f, 0.2f);
            int   index = 0;
            float w     = rect.width / 3f;
            float h     = rect.height / 3f;

            for (int y = 0; y <= 3; y++)
            {
                float top = rect.yMin + y * h;
                Handles.DrawLine(new Vector3(rect.xMin, top), new Vector3(rect.xMax, top));
            }
            for (int x = 0; x <= 3; x++)
            {
                float left = rect.xMin + x * w;
                Handles.DrawLine(new Vector3(left, rect.yMin), new Vector3(left, rect.yMax));
            }
            Handles.color = Color.white;

            for (int y = 0; y <= 2; y++)
            {
                for (int x = 0; x <= 2; x++)
                {
                    Rect r = new Rect(rect.xMin + x * w, rect.yMin + y * h, w - 1, h - 1);
                    if (x != 1 || y != 1)
                    {
                        switch (tilingRule.m_Neighbors[index])
                        {
                        case RuleTile.TilingRule.Neighbor.This:
                            GUI.DrawTexture(r, arrows[y * 3 + x]);
                            break;

                        case RuleTile.TilingRule.Neighbor.NotThis:
                            GUI.DrawTexture(r, arrows[9]);
                            break;
                        }
                        if (Event.current.type == EventType.MouseDown && r.Contains(Event.current.mousePosition))
                        {
                            int change = 1;
                            if (Event.current.button == 1)
                            {
                                change = -1;
                            }
                            tilingRule.m_Neighbors[index] = (RuleTile.TilingRule.Neighbor)(((int)tilingRule.m_Neighbors[index] + change) % 3);
                            GUI.changed = true;
                            Event.current.Use();
                        }

                        index++;
                    }
                    else
                    {
                        switch (tilingRule.m_RuleTransform)
                        {
                        case RuleTile.TilingRule.Transform.Rotated:
                            GUI.DrawTexture(r, autoTransforms[0]);
                            break;

                        case RuleTile.TilingRule.Transform.MirrorX:
                            GUI.DrawTexture(r, autoTransforms[1]);
                            break;

                        case RuleTile.TilingRule.Transform.MirrorY:
                            GUI.DrawTexture(r, autoTransforms[2]);
                            break;
                        }

                        if (Event.current.type == EventType.MouseDown && r.Contains(Event.current.mousePosition))
                        {
                            tilingRule.m_RuleTransform = (RuleTile.TilingRule.Transform)(((int)tilingRule.m_RuleTransform + 1) % 4);
                            GUI.changed = true;
                            Event.current.Use();
                        }
                    }
                }
            }
        }
        public void DrawMuscleHandle(Transform t, int humanId)
        {
            Animator   animator    = base.gameObject.GetComponent(typeof(Animator)) as Animator;
            Avatar     avatar      = animator.avatar;
            int        num         = HumanTrait.MuscleFromBone(humanId, 0);
            int        num2        = HumanTrait.MuscleFromBone(humanId, 1);
            int        num3        = HumanTrait.MuscleFromBone(humanId, 2);
            float      axisLength  = avatar.GetAxisLength(humanId);
            Quaternion quaternion  = avatar.GetPreRotation(humanId);
            Quaternion quaternion2 = avatar.GetPostRotation(humanId);

            quaternion  = t.parent.rotation * quaternion;
            quaternion2 = t.rotation * quaternion2;
            Color      b         = new Color(1f, 1f, 1f, 0.5f);
            Quaternion zYRoll    = avatar.GetZYRoll(humanId, Vector3.zero);
            Vector3    limitSign = avatar.GetLimitSign(humanId);
            Vector3    vector    = quaternion2 * Vector3.right;
            Vector3    p         = t.position + vector * axisLength;

            Handles.color = Color.white;
            Handles.DrawLine(t.position, p);
            if (num != -1)
            {
                Quaternion zYPostQ = avatar.GetZYPostQ(humanId, t.parent.rotation, t.rotation);
                float      num4    = this.m_MuscleMinEdit[num];
                float      num5    = this.m_MuscleMaxEdit[num];
                vector = quaternion2 * Vector3.right;
                Vector3 vector2 = zYPostQ * Vector3.forward;
                Handles.color = Color.black;
                Vector3 vector3 = t.position + vector * axisLength * 0.75f;
                vector = quaternion2 * Vector3.right * limitSign.x;
                Quaternion rotation = Quaternion.AngleAxis(num4, vector);
                vector2       = rotation * vector2;
                Handles.color = Color.yellow;
                Handles.color = Handles.xAxisColor * b;
                Handles.DrawSolidArc(vector3, vector, vector2, num5 - num4, axisLength * 0.25f);
                vector2       = quaternion2 * Vector3.forward;
                Handles.color = Handles.centerColor;
                Handles.DrawLine(vector3, vector3 + vector2 * axisLength * 0.25f);
            }
            if (num2 != -1)
            {
                float num6 = this.m_MuscleMinEdit[num2];
                float num7 = this.m_MuscleMaxEdit[num2];
                vector = quaternion * Vector3.up * limitSign.y;
                Vector3 vector2 = quaternion * zYRoll * Vector3.right;
                Handles.color = Color.black;
                Quaternion rotation2 = Quaternion.AngleAxis(num6, vector);
                vector2       = rotation2 * vector2;
                Handles.color = Color.yellow;
                Handles.color = Handles.yAxisColor * b;
                Handles.DrawSolidArc(t.position, vector, vector2, num7 - num6, axisLength * 0.25f);
            }
            if (num3 != -1)
            {
                float num8 = this.m_MuscleMinEdit[num3];
                float num9 = this.m_MuscleMaxEdit[num3];
                vector = quaternion * Vector3.forward * limitSign.z;
                Vector3 vector2 = quaternion * zYRoll * Vector3.right;
                Handles.color = Color.black;
                Quaternion rotation3 = Quaternion.AngleAxis(num8, vector);
                vector2       = rotation3 * vector2;
                Handles.color = Color.yellow;
                Handles.color = Handles.zAxisColor * b;
                Handles.DrawSolidArc(t.position, vector, vector2, num9 - num8, axisLength * 0.25f);
            }
        }
Ejemplo n.º 7
0
        public void DrawMuscleHandle(Transform t, int humanId)
        {
            Vector3    vector2;
            Animator   component    = base.gameObject.GetComponent(typeof(Animator)) as Animator;
            Avatar     avatar       = component.avatar;
            int        index        = HumanTrait.MuscleFromBone(humanId, 0);
            int        num2         = HumanTrait.MuscleFromBone(humanId, 1);
            int        num3         = HumanTrait.MuscleFromBone(humanId, 2);
            float      axisLength   = avatar.GetAxisLength(humanId);
            Quaternion preRotation  = avatar.GetPreRotation(humanId);
            Quaternion postRotation = avatar.GetPostRotation(humanId);

            preRotation  = t.parent.rotation * preRotation;
            postRotation = t.rotation * postRotation;
            Color      color     = new Color(1f, 1f, 1f, 0.5f);
            Quaternion zYRoll    = avatar.GetZYRoll(humanId, Vector3.zero);
            Vector3    limitSign = avatar.GetLimitSign(humanId);
            Vector3    axis      = (Vector3)(postRotation * Vector3.right);
            Vector3    vector4   = t.position + ((Vector3)(axis * axisLength));

            Handles.color = Color.white;
            Handles.DrawLine(t.position, vector4);
            if (index != -1)
            {
                Quaternion quaternion4 = avatar.GetZYPostQ(humanId, t.parent.rotation, t.rotation);
                float      angle       = this.m_MuscleMinEdit[index];
                float      num6        = this.m_MuscleMaxEdit[index];
                axis          = (Vector3)(postRotation * Vector3.right);
                vector2       = (Vector3)(quaternion4 * Vector3.forward);
                Handles.color = Color.black;
                Vector3 center = t.position + ((Vector3)((axis * axisLength) * 0.75f));
                axis          = (Vector3)((postRotation * Vector3.right) * limitSign.x);
                vector2       = (Vector3)(Quaternion.AngleAxis(angle, axis) * vector2);
                Handles.color = Color.yellow;
                Handles.color = Handles.xAxisColor * color;
                Handles.DrawSolidArc(center, axis, vector2, num6 - angle, axisLength * 0.25f);
                vector2       = (Vector3)(postRotation * Vector3.forward);
                Handles.color = Handles.centerColor;
                Handles.DrawLine(center, center + ((Vector3)((vector2 * axisLength) * 0.25f)));
            }
            if (num2 != -1)
            {
                float num7 = this.m_MuscleMinEdit[num2];
                float num8 = this.m_MuscleMaxEdit[num2];
                axis          = (Vector3)((preRotation * Vector3.up) * limitSign.y);
                vector2       = (Vector3)((preRotation * zYRoll) * Vector3.right);
                Handles.color = Color.black;
                vector2       = (Vector3)(Quaternion.AngleAxis(num7, axis) * vector2);
                Handles.color = Color.yellow;
                Handles.color = Handles.yAxisColor * color;
                Handles.DrawSolidArc(t.position, axis, vector2, num8 - num7, axisLength * 0.25f);
            }
            if (num3 != -1)
            {
                float num9  = this.m_MuscleMinEdit[num3];
                float num10 = this.m_MuscleMaxEdit[num3];
                axis          = (Vector3)((preRotation * Vector3.forward) * limitSign.z);
                vector2       = (Vector3)((preRotation * zYRoll) * Vector3.right);
                Handles.color = Color.black;
                vector2       = (Vector3)(Quaternion.AngleAxis(num9, axis) * vector2);
                Handles.color = Color.yellow;
                Handles.color = Handles.zAxisColor * color;
                Handles.DrawSolidArc(t.position, axis, vector2, num10 - num9, axisLength * 0.25f);
            }
        }
Ejemplo n.º 8
0
        public bool DoGUI(bool hasFocus)
        {
            bool enabled = GUI.enabled;

            if (ASHistoryWindow.ms_Style == null)
            {
                ASHistoryWindow.ms_Style           = new ASHistoryWindow.Constants();
                ASHistoryWindow.ms_Style.entryEven = new GUIStyle(ASHistoryWindow.ms_Style.entryEven);
                ASHistoryWindow.ms_Style.entryEven.padding.left = 3;
                ASHistoryWindow.ms_Style.entryOdd = new GUIStyle(ASHistoryWindow.ms_Style.entryOdd);
                ASHistoryWindow.ms_Style.entryOdd.padding.left = 3;
                ASHistoryWindow.ms_Style.label                    = new GUIStyle(ASHistoryWindow.ms_Style.label);
                ASHistoryWindow.ms_Style.boldLabel                = new GUIStyle(ASHistoryWindow.ms_Style.boldLabel);
                ASHistoryWindow.ms_Style.label.padding.left       = 3;
                ASHistoryWindow.ms_Style.boldLabel.padding.left   = 3;
                ASHistoryWindow.ms_Style.boldLabel.padding.top    = 0;
                ASHistoryWindow.ms_Style.boldLabel.padding.bottom = 0;
                this.DoLocalSelectionChange();
            }
            EditorGUIUtility.SetIconSize(ASHistoryWindow.ms_IconSize);
            if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Escape)
            {
                this.CancelShowCustomDiff();
                Event.current.Use();
            }
            SplitterGUILayout.BeginHorizontalSplit(this.m_HorSplit, new GUILayoutOption[0]);
            GUILayout.BeginVertical(new GUILayoutOption[0]);
            Rect rect = GUILayoutUtility.GetRect(0f, 0f, new GUILayoutOption[]
            {
                GUILayout.ExpandWidth(true),
                GUILayout.ExpandHeight(true)
            });

            this.m_FileViewWin.DoGUI(this, rect, hasFocus);
            GUILayout.EndVertical();
            GUILayout.BeginVertical(new GUILayoutOption[0]);
            this.WebLikeHistory(hasFocus);
            GUILayout.EndVertical();
            SplitterGUILayout.EndHorizontalSplit();
            if (Event.current.type == EventType.Repaint)
            {
                Handles.color = Color.black;
                Handles.DrawLine(new Vector3((float)(this.m_HorSplit.realSizes[0] - 1), rect.y, 0f), new Vector3((float)(this.m_HorSplit.realSizes[0] - 1), rect.yMax, 0f));
                Handles.DrawLine(new Vector3(0f, rect.yMax, 0f), new Vector3((float)Screen.width, rect.yMax, 0f));
            }
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUI.enabled = (this.m_FileViewWin.SelType == ASHistoryFileView.SelectionType.DeletedItems && enabled);
            if (GUILayout.Button(EditorGUIUtility.TextContent("Recover"), ASHistoryWindow.ms_Style.button, new GUILayoutOption[0]))
            {
                this.m_FileViewWin.DoRecover();
            }
            GUILayout.FlexibleSpace();
            if (this.m_InRevisionSelectMode)
            {
                GUI.enabled = enabled;
                GUILayout.Label(EditorGUIUtility.TextContent("Select revision to compare to"), ASHistoryWindow.ms_Style.boldLabel, new GUILayoutOption[0]);
            }
            GUILayout.Space(10f);
            GUI.enabled = (this.IsComparableAssetSelected() && enabled);
            if (GUILayout.Button(EditorGUIUtility.TextContent("Compare to Local Version"), ASHistoryWindow.ms_Style.button, new GUILayoutOption[0]))
            {
                this.DoShowDiff(false, this.ChangeLogSelectionRev, -1);
                GUIUtility.ExitGUI();
            }
            GUI.enabled = (this.ChangeLogSelectionRev > 0 && this.m_ChangeLogSelectionGUID != string.Empty && enabled);
            if (GUILayout.Button(EditorGUIUtility.TextContent("Download Selected File"), ASHistoryWindow.ms_Style.button, new GUILayoutOption[0]))
            {
                this.DownloadFile();
            }
            GUILayout.Space(10f);
            GUI.enabled = (this.ChangeLogSelectionRev > 0 && enabled);
            if (GUILayout.Button((this.ChangeLogSelectionRev <= 0) ? "Revert Entire Project" : ("Revert Entire Project to " + this.ChangeLogSelectionRev), ASHistoryWindow.ms_Style.button, new GUILayoutOption[0]))
            {
                this.DoRevertProject();
            }
            GUI.enabled = enabled;
            GUILayout.EndHorizontal();
            GUILayout.Space(10f);
            if (!this.m_SplittersOk && Event.current.type == EventType.Repaint)
            {
                this.m_SplittersOk = true;
                HandleUtility.Repaint();
            }
            EditorGUIUtility.SetIconSize(Vector2.zero);
            return(true);
        }
Ejemplo n.º 9
0
        protected void DrawInspectedRect(Rect instructionRect)
        {
            Rect       rect          = GUILayoutUtility.GetRect((float)0f, (float)100f);
            int        top           = Mathf.CeilToInt(34f);
            int        bottom        = Mathf.CeilToInt(16f);
            int        right         = 100;
            RectOffset offset        = new RectOffset(50, right, top, bottom);
            Rect       position      = offset.Remove(rect);
            float      imageAspect   = instructionRect.width / instructionRect.height;
            Rect       outScreenRect = new Rect();
            Rect       outSourceRect = new Rect();

            GUI.CalculateScaledTextureRects(position, ScaleMode.ScaleToFit, imageAspect, ref outScreenRect, ref outSourceRect);
            position        = outScreenRect;
            position.width  = Mathf.Max(80f, position.width);
            position.height = Mathf.Max(26f, position.height);
            Rect rect5 = new Rect {
                height = 16f,
                width  = offset.left * 2,
                y      = position.y - offset.top
            };

            rect5.x = position.x - (rect5.width / 2f);
            Rect rect7 = new Rect {
                height = 16f,
                width  = offset.right * 2,
                y      = position.yMax
            };
            Rect rect6 = rect7;

            rect6.x = position.xMax - (rect6.width / 2f);
            rect7   = new Rect {
                x      = position.x,
                y      = rect5.yMax + 2f,
                width  = position.width,
                height = 16f
            };
            Rect rect8 = rect7;
            Rect rect9 = rect8;

            rect9.width = rect8.width / 3f;
            rect9.x     = rect8.x + ((rect8.width - rect9.width) / 2f);
            Rect rect10 = position;

            rect10.x     = position.xMax;
            rect10.width = 16f;
            Rect rect11 = rect10;

            rect11.height = 16f;
            rect11.width  = offset.right;
            rect11.y     += (rect10.height - rect11.height) / 2f;
            GUI.Label(rect5, $"({instructionRect.x},{instructionRect.y})", this.styles.centeredLabel);
            Handles.color = new Color(1f, 1f, 1f, 0.5f);
            Vector3 vector  = new Vector3(rect8.x, rect9.y);
            Vector3 vector2 = new Vector3(rect8.x, rect9.yMax);

            Handles.DrawLine(vector, vector2);
            vector.x = vector2.x = rect8.xMax;
            Handles.DrawLine(vector, vector2);
            vector.x  = rect8.x;
            vector.y  = vector2.y = Mathf.Lerp(vector.y, vector2.y, 0.5f);
            vector2.x = rect9.x;
            Handles.DrawLine(vector, vector2);
            vector.x  = rect9.xMax;
            vector2.x = rect8.xMax;
            Handles.DrawLine(vector, vector2);
            GUI.Label(rect9, instructionRect.width.ToString(), this.styles.centeredLabel);
            vector  = new Vector3(rect10.x, rect10.y);
            vector2 = new Vector3(rect10.xMax, rect10.y);
            Handles.DrawLine(vector, vector2);
            vector.y = vector2.y = rect10.yMax;
            Handles.DrawLine(vector, vector2);
            vector.x  = vector2.x = Mathf.Lerp(vector.x, vector2.x, 0.5f);
            vector.y  = rect10.y;
            vector2.y = rect11.y;
            Handles.DrawLine(vector, vector2);
            vector.y  = rect11.yMax;
            vector2.y = rect10.yMax;
            Handles.DrawLine(vector, vector2);
            GUI.Label(rect11, instructionRect.height.ToString());
            GUI.Label(rect6, $"({instructionRect.xMax},{instructionRect.yMax})", this.styles.centeredLabel);
            GUI.Box(position, GUIContent.none);
        }
Ejemplo n.º 10
0
 public static void DrawLine(float x1, float y1, float x2, float y2, Color col)
 {
     Handles.color = col;
     Handles.DrawLine(new Vector3(x1, y1, 0), new Vector3(x2, y2, 0));
 }