예제 #1
0
        public static BGCurvePoint CreatePointBetween(BGCurve curve, BGCurvePointI previousPoint, BGCurvePointI nextPoint, int parts, BGCurvePoint.ControlTypeEnum controlType,
                                                      Vector3 position, Vector3 tangent)
        {
            var scaledTangent = tangent * DistanceToTangentMultiplier * BGEditorUtility.CalculateDistance(previousPoint, nextPoint, parts);

            return(curve.CreatePointFromLocalPosition(curve.ToLocal(position), controlType, curve.ToLocalDirection(-scaledTangent), curve.ToLocalDirection(scaledTangent)));
        }
예제 #2
0
 private static void AssighStyles()
 {
     BGEditorUtility.Assign(ref nameStyle, () => new GUIStyle("Label")
     {
         alignment = TextAnchor.MiddleCenter,
         clipping  = TextClipping.Clip,
         wordWrap  = true,
         fontStyle = FontStyle.Bold,
         normal    =
         {
             textColor  = Color.black,
             background = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGBoxWithBorder123)
         }
     });
     BGEditorUtility.Assign(ref disabledStyle, () => new GUIStyle("Label")
     {
         alignment = TextAnchor.MiddleCenter,
         normal    =
         {
             textColor  = Color.red,
             background = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGBoxWithBorder123)
         }
     });
     BGEditorUtility.Assign(ref filterStyle, () => new GUIStyle("Label")
     {
         fontStyle = FontStyle.Bold,
         normal    =
         {
             textColor = Color.red
         }
     });
     BGEditorUtility.Assign(ref headerImage, () => BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGCurveComponents123));
     BGEditorUtility.Assign(ref boxWithBorderImage, () => BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGBoxWithBorder123));
 }
예제 #3
0
            protected AbstractMenu(BGSceneViewOverlay overlay, BGCurveEditorPointsSelection editorSelection, string title)
                : base(title)
            {
                EditorSelection = editorSelection;

                Add(new MenuItemButton(BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGControlAbsent123), "Convert point control to Absent",
                                       () => { SetControl(BGCurvePoint.ControlTypeEnum.Absent); }));

                Add(new MenuItemButton(BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGControlBezierSymmetrical123), "Convert point control to Bezier Symmetrical",
                                       () => { SetControl(BGCurvePoint.ControlTypeEnum.BezierSymmetrical); }));

                Add(new MenuItemButton(BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGControlBezierIndependent123), "Convert point control to Bezier Independent",
                                       () => { SetControl(BGCurvePoint.ControlTypeEnum.BezierIndependant); }));


                AdditionalMenuItems();


                Add(new LockMenuItem(() =>
                {
                    BGCurveSettingsForEditor.LockView = !BGCurveSettingsForEditor.LockView;
                    EditorUtility.SetDirty(overlay.Editor.Curve);
                }));

                Add(new MenuSeparator());

                Add(new MenuItemButton(BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGPointDelete123), "Delete a point", Delete));
            }
예제 #4
0
        public virtual void On(Vector3 position)
        {
            if (Active)
            {
                return;
            }

            Active = true;

            onTransition    = new BGTransition.SimpleTransition(.2, false);
            Point3DPosition = position;
            Point2DPosition = BGEditorUtility.GetSceneViewPosition(Point3DPosition);

            //target size (go first)
            height = width = 0;
            foreach (var size in items.Where(item => !item.Disabled).Select(item => item.Size))
            {
                if (height < size.y * 2)
                {
                    height = size.y * 2;
                }
                width += size.x;
            }
            targetRect.size = new Vector2(width, height + HeaderHeight);


            //target position (go second)
            targetRect.x = Point2DPosition.x - targetRect.size.x * .5f;
            targetRect.y = Point2DPosition.y - targetRect.size.y * .75f;
        }
        public void Process(Event currentEvent)
        {
            if (currentEvent.type == EventType.mouseDown)
            {
                if (currentEvent.button == 0)
                {
                    if ((!currentEvent.control && currentEvent.shift) || BGCurveSettingsForEditor.LockView)
                    {
                        eventCanceller = new BGEditorUtility.EventCanceller();

                        if (!BGCurveSettingsForEditor.DisableRectangularSelection)
                        {
                            selectionRectangle.On();
                        }
                    }
                }
                else if (currentEvent.button == 1 && selectionRectangle.IsOn)
                {
                    //glitch with right click
                    GUIUtility.hotControl = GUIUtility.GetControlID(FocusType.Passive);
                }
            }
            else if (currentEvent.type == EventType.mouseUp)
            {
                SceneView.RepaintAll();
                selectionRectangle.Off();
                BGEditorUtility.Release(ref eventCanceller);
            }


            selectionRectangle.Process(currentEvent);
        }
예제 #6
0
        public virtual void DrawCurve()
        {
            if (transformMonitor != null)
            {
                transformMonitor.Check();
            }

            var settings = BGPrivateField.GetSettings(Math.Curve);

            BGEditorUtility.SwapGizmosColor(settings.LineColor, () =>
            {
                //========================================  Draw section
                for (var i = 0; i < Math.SectionsCount; i++)
                {
                    DrawSection(Math[i]);
                }
            });


            //========================================  Draw spheres
            if (settings.ShowSpheres)
            {
                BGEditorUtility.SwapGizmosColor(settings.SphereColor, () =>
                {
                    BeforeDrawingSpheres(settings);
                    for (var i = 0; i < Math.Curve.PointsCount; i++)
                    {
                        DrawSphere(settings, Math.GetPosition(i), settings.SphereRadius);
                    }
                    AfterDrawingSpheres();
                });
            }
        }
예제 #7
0
        public static void DrawGizmos(BGCcCollider2DBox collider2DBox, GizmoType gizmoType)
        {
            if (!collider2DBox.ShowIfNotSelected)
            {
                return;
            }

            collider2DBox.FillChildrenColliders(TempColliders);

            if (TempColliders.Count == 0)
            {
                return;
            }

            BGEditorUtility.SwapGizmosColor(collider2DBox.CollidersColor, () =>
            {
                foreach (var collider in TempColliders)
                {
                    var colliderTransform = collider.transform;

                    var oldMatrix  = Gizmos.matrix;
                    Gizmos.matrix *= Matrix4x4.TRS(colliderTransform.position, colliderTransform.rotation, colliderTransform.lossyScale);
                    Gizmos.DrawWireCube(collider.offset, collider.size);
                    Gizmos.matrix = oldMatrix;
                }
            });

            TempColliders.Clear();
        }
        protected override void AdditionalParams()
        {
            var updateEveryFrameProperty = serializedObject.FindProperty("updateEveryFrame");

            EditorGUILayout.PropertyField(updateEveryFrameProperty);
            EditorGUILayout.PropertyField(serializedObject.FindProperty("flip"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("scaleUV"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("offsetUV"));
            BGEditorUtility.VerticalBox(() =>
            {
                var doubleSidedProperty = serializedObject.FindProperty("doubleSided");
                EditorGUILayout.PropertyField(doubleSidedProperty);
                if (doubleSidedProperty.boolValue)
                {
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("scaleBackUV"));
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("offsetBackUV"));
                }
            });

            //launch coroutine
            if (updateEveryFrameProperty.boolValue != Triangulate2D.UpdateEveryFrame && Application.isPlaying && updateEveryFrameProperty.boolValue)
            {
                Triangulate2D.UpdateEveryFrame = true;
            }
        }
        protected override void InternalOnInspectorGUI()
        {
            if (!listenersAdded)
            {
                InternalOnEnable();
            }

            EditorGUI.BeginChangeCheck();


            BGEditorUtility.VerticalBox(() =>
            {
                EditorGUILayout.PropertyField(serializedObject.FindProperty("splitMode"));

                switch (LineRenderer.SplitMode)
                {
                case BGCcVisualizationLineRenderer.SplitModeEnum.PartsTotal:
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("partsTotal"));
                    break;

                case BGCcVisualizationLineRenderer.SplitModeEnum.PartsPerSection:
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("partsPerSection"));
                    break;
                }
            });


            EditorGUILayout.PropertyField(serializedObject.FindProperty("doNotOptimizeStraightLines"));

            updateUi = EditorGUI.EndChangeCheck();
        }
예제 #10
0
        public override void OnApply()
        {
            if (closeChanged)
            {
                Curve.FireChange(Curve.UseEventsArgs ? new BGCurveChangedArgs(Curve, BGCurveChangedArgs.ChangeTypeEnum.Points) : null);
            }

            if (mode2DChanged)
            {
                //force points recalc
                Curve.Apply2D(Curve.Mode2D);

                if (BGEditorUtility.Confirm("Editor handles change", "Do you want to adjust configurable Editor handles (in Scene View) to chosen mode? This affects only current curve.", "Yes"))
                {
                    var settings = Settings;
                    if (Curve.Mode2D != BGCurve.Mode2DEnum.Off)
                    {
                        Apply2D(settings.HandlesSettings);
                        Apply2D(settings.ControlHandlesSettings);
                    }
                    else
                    {
                        Apply3D(settings.HandlesSettings);
                        Apply3D(settings.ControlHandlesSettings);
                    }
                }
            }
        }
예제 #11
0
        protected void MeshGenerationToggle()
        {
            BGEditorUtility.Horizontal(() =>
            {
                EditorGUILayout.PropertyField(serializedObject.FindProperty("isMeshGenerationOn"));
                if (!GUILayout.Button(new GUIContent("Remove meshes", "Remove MeshFilter and MeshRenderer components from all child GameObjects with colliders attached"),
                                      GUILayout.Width(120)))
                {
                    return;
                }

                if (MeshColliderAbstract.IsMeshGenerationOn)
                {
                    BGEditorUtility.Inform("Error", "Please, turn off 'isMeshGenerationOn' toggle first.");
                    return;
                }

                var renderer = MeshColliderAbstract.GetComponent <MeshRenderer>();
                if (renderer != null)
                {
                    BGCurve.DestroyIt(renderer);
                }
                var filter = MeshColliderAbstract.GetComponent <MeshFilter>();
                if (filter != null)
                {
                    BGCurve.DestroyIt(filter);
                }
            });
        }
        protected override void InternalOnSceneGUI()
        {
            var objectRotate = (BGCcCursorObjectRotate)cc;

            var cursor = objectRotate.Cursor;

            if (cursor == null)
            {
                return;
            }

            var math = cursor.Math;

            if (math == null || !math.IsCalculated(BGCurveBaseMath.Field.Tangent))
            {
                return;
            }

            var position = cursor.CalculatePosition();
            var tangent  = cursor.CalculateTangent();

            if (Vector3.SqrMagnitude(tangent) > 0.0001)
            {
                var handleSize = BGEditorUtility.GetHandleSize(position, BGPrivateField.Get <float>(ObjectRotate, "handlesScale"));
                BGEditorUtility.SwapHandlesColor(BGPrivateField.Get <Color>(ObjectRotate, "handlesColor"), () => { Handles.ArrowCap(0, position, Quaternion.LookRotation(tangent), handleSize); });
            }
        }
        protected override void InternalOnInspectorGUI()
        {
            base.InternalOnInspectorGUI();

            BGEditorUtility.VerticalBox(() =>
            {
                EditorGUILayout.PropertyField(serializedObject.FindProperty("rotationInterpolation"));

                switch (ObjectRotate.RotationInterpolation)
                {
                case BGCcCursorObjectRotate.RotationInterpolationEnum.Lerp:
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("lerpSpeed"));
                    break;

                case BGCcCursorObjectRotate.RotationInterpolationEnum.Slerp:
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("slerpSpeed"));
                    break;
                }
            });

            BGEditorUtility.VerticalBox(() =>
            {
                EditorGUILayout.PropertyField(serializedObject.FindProperty("upMode"));
                switch (ObjectRotate.UpMode)
                {
                case BGCcCursorObjectRotate.RotationUpEnum.WorldCustom:
                case BGCcCursorObjectRotate.RotationUpEnum.LocalCustom:
                case BGCcCursorObjectRotate.RotationUpEnum.TargetParentUpCustom:
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("upCustom"));
                    break;
                }
            });
        }
예제 #14
0
        private static BGCurvePoint CreatePointBetween(BGCurve curve, BGCurvePointI previousPoint, BGCurvePointI nextPoint, int parts, BGCurvePoint.ControlTypeEnum controlType)
        {
            var newPos  = BGEditorUtility.CalculatePosition(previousPoint, nextPoint, .5f);
            var tangent = BGEditorUtility.CalculateTangent(previousPoint, nextPoint, .5f);

            return(CreatePointBetween(curve, previousPoint, nextPoint, parts, controlType, newPos, tangent));
        }
        protected override void InternalOnInspectorGUI()
        {
            if (!listenersAdded)
            {
                InternalOnEnable();
            }

            paramsChanged = false;
            BGEditorUtility.ChangeCheck(() =>
            {
                BGEditorUtility.VerticalBox(() =>
                {
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("splitMode"));

                    switch (Splitter.SplitMode)
                    {
                    case BGCcSplitterPolyline.SplitModeEnum.PartsTotal:
                        EditorGUILayout.PropertyField(serializedObject.FindProperty("partsTotal"));
                        break;

                    case BGCcSplitterPolyline.SplitModeEnum.PartsPerSection:
                        EditorGUILayout.PropertyField(serializedObject.FindProperty("partsPerSection"));
                        break;
                    }
                });

                EditorGUILayout.PropertyField(serializedObject.FindProperty("doNotOptimizeStraightLines"));

                AdditionalParams();
            }, () => paramsChanged = true);
        }
예제 #16
0
            protected override void AdditionalMenuItems()
            {
                Add(new MenuSeparator());

                //add before
                Add(new MenuItemButton(BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGPointInsertBefore123), "Insert a point before this point",
                                       () =>
                {
                    var curve    = point.Curve;
                    var settings = BGPrivateField.GetSettings(curve);
                    var index    = curve.IndexOf(point);
                    curve.AddPoint(BGNewPointPositionManager.InsertBefore(curve, index, settings.ControlType, settings.Sections), index);
                }));

                //add after
                Add(new MenuItemButton(BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGPointInsertAfter123), "Insert a point after this point",
                                       () =>
                {
                    var curve    = point.Curve;
                    var settings = BGPrivateField.GetSettings(curve);
                    var index    = curve.IndexOf(point);
                    curve.AddPoint(BGNewPointPositionManager.InsertAfter(curve, index, settings.ControlType, settings.Sections), index + 1);
                }));


                //add remove to selection
                addToSelectionItem = new MenuItemButton(BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGSelectionAdd123), "Add this point to selection",
                                                        () => EditorSelection.Add(point));

                removeFromSelectionItem = new MenuItemButton(BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGSelectionRemove123), "Remove this point from selection",
                                                             () => EditorSelection.Remove(point));

                Add(addToSelectionItem);
                Add(removeFromSelectionItem);
            }
        protected override void InternalOnSceneGUI()
        {
            var splitter = Splitter;

            if (splitter == null)
            {
                return;
            }

            var positions = splitter.Positions;

            if (positions == null || positions.Count == 0)
            {
                return;
            }

            var sphereScale = BGPrivateField.Get <float>(splitter, "spheresScale");

            BGEditorUtility.SwapHandlesColor(BGPrivateField.Get <Color>(splitter, "spheresColor"), () =>
            {
                var count = Mathf.Min(positions.Count, BGPrivateField.Get <int>(splitter, "spheresCount"));

                var localToWorldMatrix = splitter.transform.localToWorldMatrix;
                for (var i = 0; i < count; i++)
                {
                    var position = positions[i];
                    if (splitter.UseLocal)
                    {
                        position = localToWorldMatrix.MultiplyPoint(position);
                    }

                    Handles.SphereCap(0, position, Quaternion.identity, sphereScale * BGEditorUtility.GetHandleSize(position, .07f));
                }
            });
        }
예제 #18
0
        internal static void Open(Component current, Action <Component> action)
        {
            BGChoseComponentWindow.action  = action;
            BGChoseComponentWindow.current = current;

            instance = BGEditorUtility.ShowPopupWindow <BGChoseComponentWindow>(WindowSize);
        }
예제 #19
0
        protected override void AdditionalParams()
        {
            EditorGUILayout.PropertyField(serializedObject.FindProperty("lengthExtends"));

            EditorGUILayout.PropertyField(serializedObject.FindProperty("height"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("heightOffset"));


#if UNITY_5_6_OR_NEWER
            EditorGUILayout.PropertyField(serializedObject.FindProperty("usedByComposite"));
            if (!Collider2DBox.UsedByComposite)
            {
                MiscParams();
            }
#else
            MiscParams();
#endif

            BGEditorUtility.VerticalBox(() =>
            {
                EditorGUILayout.PropertyField(serializedObject.FindProperty("generateKinematicRigidbody"));
                if (!Collider2DBox.GenerateKinematicRigidbody)
                {
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("Rigidbody"));
                }
            });


            base.AdditionalParams();
        }
        protected static void PreviewControl(BGCurveSettings settings, Vector3 position, Vector3 controlWorld)
        {
            var size = BGEditorUtility.GetHandleSize(position, ScalePreviewPoint * .8f);

            Handles.SphereCap(0, controlWorld, Quaternion.identity, size);
            Handles.DrawLine(position, controlWorld);
        }
        public static void DrawGizmos(BGCcCollider2DEdge collider2DEdge, GizmoType gizmoType)
        {
            if (!collider2DEdge.ShowIfNotSelected)
            {
                return;
            }

            var collider = collider2DEdge.GetComponent <EdgeCollider2D>();

            if (collider == null)
            {
                return;
            }

            var points = collider.points;

            if (points == null || points.Length < 2)
            {
                return;
            }

            BGEditorUtility.SwapGizmosColor(collider2DEdge.CollidersColor, () =>
            {
                var matrix    = collider2DEdge.transform.localToWorldMatrix;
                var prevPoint = matrix.MultiplyPoint(points[0]);
                for (var i = 1; i < points.Length; i++)
                {
                    var nextPoint = matrix.MultiplyPoint(points[i]);
                    Gizmos.DrawLine(prevPoint, nextPoint);
                    prevPoint = nextPoint;
                }
            });
        }
        // preview
        protected void Preview(Vector3 position, BGCurve curve, ref float toLast, ref float toFirst)
        {
            var settings = overlay.Editor.Settings;

            //show point
            BGEditorUtility.SwapHandlesColor(settings.SphereColor, () => Handles.SphereCap(0, position, Quaternion.identity, BGEditorUtility.GetHandleSize(position, ScalePreviewPoint)));

            //create a point
            var newPoint = BGNewPointPositionManager.CreatePoint(position, curve, settings.ControlType, settings.Sections, out toLast, out toFirst, false);

            //show controls
            if (newPoint.ControlType != BGCurvePoint.ControlTypeEnum.Absent)
            {
                PreviewControls(settings, position, newPoint.ControlFirstWorld, newPoint.ControlSecondWorld);
            }

            if (curve.PointsCount == 0)
            {
                return;
            }

            BGEditorUtility.SwapHandlesColor(BGCurveSettingsForEditor.ColorForNewSectionPreview, () =>
            {
                // last To new
                DrawSection(curve[curve.PointsCount - 1], newPoint, settings.Sections);

                AdditionalPreview(newPoint);

                // new To zero
                if (curve.Closed)
                {
                    DrawSection(newPoint, curve[0], settings.Sections);
                }
            });
        }
예제 #23
0
        public void OnSceneGUI()
        {
            var settings = BGPrivateField.GetSettings(Curve);

            AdjustMath(settings, Math);

            if (Curve.ForceChangedEventMode != BGCurve.ForceChangedEventModeEnum.Off)
            {
                Math.Recalculate(true);
            }


            if (settings.HandlesSettings != null && settings.HandlesType == BGCurveSettings.HandlesTypeEnum.Configurable ||
                settings.ControlHandlesSettings != null && settings.ControlHandlesType == BGCurveSettings.HandlesTypeEnum.Configurable)
            {
                BGEditorUtility.ReloadSnapSettings();
            }


            OverlayMessage.OnSceneGui();

            var frustum = GeometryUtility.CalculateFrustumPlanes(SceneView.currentDrawingSceneView.camera);

            // process all editors
            foreach (var editor in editors)
            {
                editor.OnSceneGui(frustum);
            }

            editorSelection.Process(Event.current);


            transformMonitor.CheckForChange();
        }
예제 #24
0
        private static void ShowButtons()
        {
            BGEditorUtility.Vertical(BGEditorUtility.Assign(ref boxStyle, () => new GUIStyle("Box")
            {
                padding = new RectOffset(8, 8, 8, 8)
            }), () =>
            {
                for (var i = 0; i < availableList.Length; i++)
                {
                    var cc = (BGCc)availableList[i];

                    BGEditorUtility.DisableGui(() =>
                    {
                        if (!GUILayout.Button(cc.CcName))
                        {
                            return;
                        }


                        action(cc);
                        instance.Close();
                    }, cc == current);
                }
            });
        }
        private void UpdatePoints(Rect rect)
        {
            var sceneViewHeight = BGEditorUtility.GetSceneViewHeight();

            var math = editor.Math;

            curve.ForEach((point, index, count) =>
            {
                //add or remove from selection
                if (rect.Contains(BGEditorUtility.GetSceneViewPosition(math.GetPosition(index), sceneViewHeight)))
                {
                    selection.Add(point);
                }
                else
                {
                    selection.Remove(point);
                }
            });

            if (!selection.Changed)
            {
                return;
            }

            selection.Reset();
        }
예제 #26
0
                internal CcNode(Tree tree, BGCc cc) : base(tree)
                {
                    Cc         = cc;
                    descriptor = cc.Descriptor;

                    var editor = UnityEditor.Editor.CreateEditor(cc);

                    if (!(editor is BGCcEditor))
                    {
                        throw new BGCc.CcException("Unable to init an Editor for " + cc.GetType() + ": editor does not extend from BGCcEditor.");
                    }

                    ccEditor = (BGCcEditor)editor;
                    ccEditor.ChangedParent += ChangedParent;
//                    UnityEditor.Editor.CreateCachedEditor(cc, null, ref ccEditor);

                    onSceneGuiMethod = ccEditor.GetType().GetMethod("OnSceneGUI", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);

                    enabledTexture    = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGTickYes123);
                    disabledTexture   = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGTickNo123);
                    helpTexture       = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGHelp123);
                    deleteTexture     = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGDelete123);
                    addTexture        = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGAdd123);
                    changeNameTexture = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGCcEditName123);

                    parentType = cc.GetParentClass();
                }
예제 #27
0
        internal override bool Seize(Event currentEvent, ref Vector3 position, ref string message)
        {
            if (menu.Active)
            {
                menu.OnGui(currentEvent);
                DrawActiveAnimatedTexture(menu.Point2DPosition);

                var okMessage = menu.ActiveItem != null && menu.ActiveItem.Description != null
                    ? "Release Ctrl to " + menu.ActiveItem.Description
                    : "Hover over an option and release Ctrl.";

                //out params
                position = menu.Point3DPosition;
                message  = BGSceneViewOverlay.ToOk(okMessage) + "\r\n" + menu.Details;
                //============== Ok
                return(true);
            }

            if (!(currentEvent.type == EventType.Repaint && currentEvent.control || currentEvent.type == EventType.MouseMove && currentEvent.control))
            {
                return(false);
            }

            if (Process(currentEvent, overlay.Editor.Editor.Math, BGEditorUtility.GetSceneViewHeight(), ref position, ref message))
            {
                return(true);
            }

            pointIndicatorTransition = null;

            //============== No luck
            return(false);
        }
 private static void ShowTangent(Vector3 position, Vector3 tangent, float size)
 {
     if (tangent.sqrMagnitude > 0.0001f)
     {
         Handles.ArrowCap(0, position, Quaternion.LookRotation(tangent), BGEditorUtility.GetHandleSize(position, size));
     }
 }
예제 #29
0
        private void OnGUI()
        {
            BGEditorUtility.SwapLabelWidth(60, () =>
            {
                BGEditorUtility.Horizontal(BGEditorUtility.Assign(ref boxStyle, () => new GUIStyle("Box")
                {
                    padding = new RectOffset(8, 8, 8, 8)
                }), () =>
                {
                    ccName = EditorGUILayout.TextField("Name", ccName);

                    GUILayout.Space(8);

                    if (GUILayout.Button("Save and Close"))
                    {
                        if (!string.Equals(ccName, current.CcName))
                        {
                            Undo.RecordObject(current, "Change name");
                            current.CcName = ccName;
                            EditorUtility.SetDirty(current);
                        }
                        instance.Close();
                    }
                });
            });
        }
예제 #30
0
 public BGPopupMenu(string title)
 {
     this.title      = title;
     backTexture     = BGEditorUtility.Texture1X1(new Color32(46, 144, 168, 80));
     selectedTexture = BGEditorUtility.Texture1X1(new Color32(0, 255, 0, 100));
     currentTexture  = BGEditorUtility.Texture1X1(new Color32(200, 200, 200, 200));
 }