예제 #1
0
        public void OnSceneGUI(ItemInspector inspector)
        {
            if (!EditingEnabled)
            {
                return;
            }

            RemapControlPoints();
            UpdateDragPointsLock();

            DragPointsHandler.OnSceneGUI(Event.current, OnDragPointPositionChange);

            // right mouse button clicked?
            if (Event.current.type == EventType.MouseDown && Event.current.button == 1)
            {
                var nearestControlPoint = DragPointsHandler.ControlPoints.Find(cp => cp.ControlId == HandleUtility.nearestControl);

                if (nearestControlPoint != null)
                {
                    var command = new MenuCommand(inspector, nearestControlPoint.ControlId);
                    EditorUtility.DisplayPopupMenu(new Rect(Event.current.mousePosition.x, Event.current.mousePosition.y, 0, 0), DragPointMenuItems.ControlPointsMenuPath, command);
                    Event.current.Use();
                }
                else if (DragPointsHandler.CurveTravellerVisible && HandleUtility.nearestControl == DragPointsHandler.CurveTravellerControlId)
                {
                    var command = new MenuCommand(inspector, 0);
                    EditorUtility.DisplayPopupMenu(new Rect(Event.current.mousePosition.x, Event.current.mousePosition.y, 0, 0), DragPointMenuItems.CurveTravellerMenuPath, command);
                    Event.current.Use();
                }
            }
        }
예제 #2
0
        public void OnInspectorGUI(ItemInspector inspector)
        {
            if (_mainComponent.IsLocked)
            {
                EditorGUILayout.LabelField("Drag Points are Locked");
                return;
            }

            _foldoutControlPoints = EditorGUILayout.BeginFoldoutHeaderGroup(_foldoutControlPoints, "Drag Points");
            if (_foldoutControlPoints)
            {
                EditorGUI.indentLevel++;
                for (var i = 0; i < DragPointsHandler.ControlPoints.Count; ++i)
                {
                    var controlPoint = DragPointsHandler.ControlPoints[i];
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField($"#{i} ({controlPoint.DragPoint.Center.X},{controlPoint.DragPoint.Center.Y},{controlPoint.DragPoint.Center.Z})");
                    if (GUILayout.Button("Copy"))
                    {
                        CopyDragPoint(controlPoint.ControlId);
                    }
                    else if (GUILayout.Button("Paste"))
                    {
                        PasteDragPoint(controlPoint.ControlId);
                    }
                    EditorGUILayout.EndHorizontal();
                    EditorGUI.indentLevel++;
                    if (HasDragPointExposure(DragPointExposure.SlingShot))
                    {
                        inspector.ItemDataField("Slingshot", ref controlPoint.DragPoint.IsSlingshot);
                    }
                    if (HasDragPointExposure(DragPointExposure.Smooth))
                    {
                        inspector.ItemDataField("Smooth", ref controlPoint.DragPoint.IsSmooth);
                    }
                    if (HasDragPointExposure(DragPointExposure.Texture))
                    {
                        inspector.ItemDataField("Has AutoTexture", ref controlPoint.DragPoint.HasAutoTexture);
                        inspector.ItemDataSlider("Texture Coord", ref controlPoint.DragPoint.TextureCoord, 0.0f, 1.0f);
                    }
                    EditorGUI.indentLevel--;
                }
                EditorGUI.indentLevel--;
            }
            EditorGUILayout.EndFoldoutHeaderGroup();
        }