public BGCurveEditorPointsSelection(BGCurve curve, BGCurveEditor editor) { this.curve = curve; selectionRectangle = new BGRectangularSelection(editor, this); pointsContainer = new PointsContainer(this); }
protected BGCurveEditorTab(BGCurveEditor editor, SerializedObject serializedObject, Texture2D header2D) { Editor = editor; Curve = editor.Curve; SerializedObject = serializedObject; this.header2D = header2D; }
public BGCurveEditorFields(BGCurveEditor editor, SerializedObject curveObject, BGCurveEditorPointsSelection editorSelection) : base(editor, curveObject, BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGFields123)) { this.editorSelection = editorSelection; addIcon = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGAdd123); deleteIcon = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGDelete123); }
public BGCurveEditorSettings(BGCurveEditor editor, SerializedObject serializedObject) : base(editor, serializedObject, BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGSettings123)) { //anim props showCurveProp = new BGEditorUtility.BoolAnimatedProperty(editor, serializedObject.FindProperty("settings"), "showCurve"); // showControlHandlesProp = new BGEUtil.BoolAnimatedProperty(editor, settings, "showControlHandles"); // showLablesProp = new BGEUtil.BoolAnimatedProperty(editor, settings, "showLabels"); // showSpheresProp = new BGEUtil.BoolAnimatedProperty(editor, settings, "showSpheres"); }
private void PointButtons(BGCurvePointI point, int index, BGCurveSettings settings) { if (!settings.ShowPointMenu) { return; } var curve = point.Curve; //================== Copy if (BGEditorUtility.ButtonWithIcon(BGBinaryResources.BGCopy123, PointCopyPaste.Instance.CopyTooltip)) { PointCopyPaste.Instance.Copy(point); } GUILayout.Space(2); //================== Paste if (BGEditorUtility.ButtonWithIcon(BGBinaryResources.BGPaste123, PointCopyPaste.Instance.PasteTooltip)) { PointCopyPaste.Instance.Paste(point); } GUILayout.Space(2); //================== Add before if (BGEditorUtility.ButtonWithIcon(BGBinaryResources.BGAdd123, "Insert a point before this point")) { BGCurveEditor.AddPoint(curve, BGNewPointPositionManager.InsertBefore(curve, index, settings.ControlType, settings.Sections), index); } GUILayout.Space(2); //=========================== Move Up if (index > 0 && BGEditorUtility.ButtonWithIcon(BGBinaryResources.BGMoveUp123, "Move the point up")) { curve.Swap(index - 1, index); } GUILayout.Space(2); //=========================== Move Down if (index < curve.PointsCount - 1 && BGEditorUtility.ButtonWithIcon(BGBinaryResources.BGMoveDown123, "Move the point down")) { curve.Swap(index, index + 1); } GUILayout.Space(2); //=========================== Delete if (BGEditorUtility.ButtonWithIcon(BGBinaryResources.BGDelete123, "Delete the point")) { BGCurveEditor.DeletePoint(curve, index); if (editorSelection != null) { editorSelection.Remove(point); } GUIUtility.ExitGUI(); } }
public BGRectangularSelection(BGCurveEditor editor, BGCurveEditorPointsSelection selection) { this.editor = editor; this.selection = selection; curve = editor.Curve; borderHorizontal = CreateBorder(false); borderVertical = CreateBorder(true); }
public BGCurveEditorPointsSelection(BGCurve curve, BGCurveEditor editor) { this.curve = curve; selectionRectangle = new BGRectangularSelection(editor, this); tickNoTexture = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGTickNo123); tickYesTexture = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGTickYes123); deleteTexture = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGDelete123); selectAllTexture = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGSelectAll123); deselectAllTexture = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGDeSelectAll123); convertAllTexture = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGConvertAll123); pointsContainer = new PointsContainer(this); }
protected virtual void OnEnable() { point = Point; pointEditor = new BGCurveEditorPoint(() => null, null); if (curveEditor != null) { curveEditor.OnDestroy(); } curveEditor = (BGCurveEditor)CreateEditor(point.Curve); PointSelected = true; }
protected virtual void OnEnable() { point = Point; pointEditor = new BGCurveEditorPoint(() => null, null); if (curveEditor != null) { curveEditor.OnDestroy(); } curveEditor = (BGCurveEditor)CreateEditor(point.Curve); pointSelectedTexture = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGPointSelected123); PointSelected = true; }
public BGCurveEditorPoints(BGCurveEditor editor, SerializedObject serializedObject, BGCurveEditorPointsSelection editorSelection) : base(editor, serializedObject, BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGPoints123)) { this.serializedObject = serializedObject; this.editorSelection = editorSelection; //textures convertAll2D = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGConvertAll123); addPointIcon = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGAdd123); //point editorPoint = new BGCurveEditorPoint(() => Editor.Math, editorSelection); //closed or not closedProperty = serializedObject.FindProperty("closed"); //how points are stored pointsModeProperty = serializedObject.FindProperty("pointsMode"); //2d mode mode2DProperty = serializedObject.FindProperty("mode2D"); //snapping snapTypeProperty = serializedObject.FindProperty("snapType"); snapAxisProperty = serializedObject.FindProperty("snapAxis"); snapDistanceProperty = serializedObject.FindProperty("snapDistance"); snapTriggerInteractionProperty = serializedObject.FindProperty("snapTriggerInteraction"); snapToBackFacesProperty = serializedObject.FindProperty("snapToBackFaces"); snapMonitoringProperty = serializedObject.FindProperty("snapMonitoring"); //force update forceChangedEventModeProperty = serializedObject.FindProperty("forceChangedEventMode"); //event type eventModeProperty = serializedObject.FindProperty("eventMode"); //settings controlTypeProperty = serializedObject.FindProperty("settings").FindPropertyRelative("controlType"); //Context menu overlay = new BGSceneViewOverlay(this, editorSelection); //for GameObjects points which use transforms UpdatePointsTrackers(); }
public bool DeleteSelected() { if (points.Count == 0) { BGEditorUtility.Inform("Error", "Chose at least one point to delete"); return(false); } if (!BGEditorUtility.Confirm("Delete points confirmation", "Are you sure you want to remove " + points.Count + " point(s)?", "Delete")) { return(false); } BGCurveEditor.DeletePoints(curve, points.ToArray()); Clear(); return(true); }
public BGCurveEditorPoints(BGCurveEditor editor, SerializedObject curveObject) : base(editor, curveObject, BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGPoints123)) { //textures convertAll2D = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGConvertAll123); addPointIcon = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGAdd123); //selection editorSelection = new BGCurveEditorPointsSelection(Curve, this); //point editorPoint = new BGCurveEditorPoint(this, editorSelection); //closed or not closedProperty = curveObject.FindProperty("closed"); //2d mode mode2DProperty = curveObject.FindProperty("mode2D"); //settings controlTypeProperty = curveObject.FindProperty("settings").FindPropertyRelative("controlType"); //Context menu overlay = new BGSceneViewOverlay(this, editorSelection); }
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); BGCurveEditor.AddPoint(curve, 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); BGCurveEditor.AddPoint(curve, 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); }
public BGCurveEditorComponents(BGCurveEditor editor, SerializedObject curveObject) : base(editor, curveObject) { tree = new Tree(Curve); }
public BGCurveEditorFields(BGCurveEditor editor, SerializedObject curveObject, BGCurveEditorPointsSelection editorSelection) : base(editor, curveObject) { this.editorSelection = editorSelection; }
public static void DrawGizmos(BGCurveReferenceToPoint point, GizmoType gizmoType) { BGCurveEditor.DrawGizmos(point.Point.Curve, gizmoType); }
protected BGCurveEditorTab(BGCurveEditor editor, SerializedObject serializedObject) { Editor = editor; Curve = editor.Curve; SerializedObject = serializedObject; }
public BGCurveEditorSettings(BGCurveEditor editor, SerializedObject serializedObject) : base(editor, serializedObject) { //anim props showCurveProp = new BGEditorUtility.BoolAnimatedProperty(editor, serializedObject.FindProperty("settings"), "showCurve"); }
//see base class for description internal override bool Seize(Event currentEvent, ref Vector3 position, ref string message) { if (!Comply(currentEvent)) { return(false); } Vector3 intersectionPosition; Plane plane; if (currentEvent.type == EventType.mouseDown && currentEvent.control && currentEvent.button == 0) { //Mouse down for some action var curve = overlay.Editor.Curve; var settings = overlay.Editor.Settings; Cast(currentEvent, HandleUtility.GUIPointToWorldRay(currentEvent.mousePosition), out intersectionPosition, out message, out plane); if (message != null) { BGCurveEditor.OverlayMessage.Display(message); } else { position = intersectionPosition; BGCurveEditor.AddPoint(curve, BGNewPointPositionManager.CreatePoint(intersectionPosition, curve, settings.ControlType, settings.Sections, true), curve.PointsCount); } overlay.EventCanceller = new BGEditorUtility.EventCanceller(); return(true); } if (!(currentEvent.type == EventType.Repaint && currentEvent.control || currentEvent.type == EventType.MouseMove && currentEvent.control)) { return(false); } var ray = HandleUtility.GUIPointToWorldRay(currentEvent.mousePosition); Cast(currentEvent, ray, out intersectionPosition, out message, out plane); position = intersectionPosition; if (message != null) { return(true); } Animation(plane, ray, swayTransition); //preview float toLast = -1, toFirst = -1; Preview(intersectionPosition, overlay.Editor.Curve, ref toLast, ref toFirst); //distance message = BGSceneViewOverlay.ToOk("MouseClick to add a point\r\n") + //to last (toLast < 0 ? "First point is ready to go!" : "Distance to last=" + toLast) + //to first (toFirst < 0 ? "" : ", to first=" + toFirst); return(true); }
// ================================================================================ Inspector public override void OnInspectorGui() { var settings = Settings; editorSelection.Reset(); // ======================================== Top section InspectorTopSection(); // ======================================== Points GUILayout.Space(5); if (Curve.PointsCount > 0) { BGEditorUtility.VerticalBox(() => { var temp = BGCurveSettingsForEditor.DisableInspectorPointMenu; BGCurveSettingsForEditor.DisableInspectorPointMenu = BGEditorUtility.ButtonOnOff(ref temp, "Points menu [" + Curve.PointsCount + "]", "Show points in Editor inspector", HiddenPointMenuColor, new GUIContent("Show", "Click to show points menu"), new GUIContent("Hide", "Click to hide points menu"), () => { const string title = "Reverse points"; if (!GUILayout.Button(new GUIContent(title, "Reverse all points, but keep curve intact"))) { return; } if (Curve.PointsCount < 2) { BGEditorUtility.Inform(title, "There should be at least 2 points. Curve has " + Curve.PointsCount); return; } if (!BGEditorUtility.Confirm(title, "Are you sure you want to reverse the order of " + Curve.PointsCount + " points? Curve will remain intact.", "Reverse")) { return; } Curve.Reverse(); }); //show points! if (!BGCurveSettingsForEditor.DisableInspectorPointMenu) { SwapVector2Labels(Curve.Mode2D, () => Curve.ForEach((point, index, count) => editorPoint.OnInspectorGui(point, index, settings))); } }); // ======================================== Selections operations editorSelection.InspectorSelectionOperations(); //warning BGEditorUtility.HelpBox("Selection mode is on", MessageType.Warning, !editorSelection.Changed && editorSelection.HasSelected()); } else { BGEditorUtility.HorizontalBox(() => { EditorGUILayout.LabelField("No points!"); if (BGEditorUtility.ButtonWithIcon(BGBinaryResources.BGAdd123, "Add new point at (0,0,0) local coordinates")) { BGCurveEditor.AddPoint(Curve, new BGCurvePoint(Curve, Vector3.zero, settings.ControlType, Vector3.right, Vector3.left), 0); } }); } if (!editorSelection.Changed) { return; } Editor.Repaint(); SceneView.RepaintAll(); }
public static void DrawGizmos(BGCurvePointGO point, GizmoType gizmoType) { BGCurveEditor.DrawGizmos(point.Curve, gizmoType); }
public BGCurveEditorComponents(BGCurveEditor editor, SerializedObject curveObject) : base(editor, curveObject, BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGComponents123)) { tree = new Tree(Curve); }
public override void OnApply() { var curve = Editor.Curve; var settings = Settings; // ============================================== Closed if (curve.Closed != closedProperty.boolValue) { Curve.FireBeforeChange(BGCurve.EventClosed); serializedObject.ApplyModifiedProperties(); Curve.FireChange(BGCurveChangedArgs.GetInstance(Curve, BGCurveChangedArgs.ChangeTypeEnum.Points, BGCurve.EventClosed)); } if ((int)curve.ForceChangedEventMode != forceChangedEventModeProperty.enumValueIndex) { Curve.FireBeforeChange(BGCurve.EventForceUpdate); serializedObject.ApplyModifiedProperties(); Curve.FireChange(BGCurveChangedArgs.GetInstance(Curve, BGCurveChangedArgs.ChangeTypeEnum.Curve, BGCurve.EventForceUpdate)); } // ============================================== Points store mode if ((int)Curve.PointsMode != pointsModeProperty.enumValueIndex) { var newPointsMode = (BGCurve.PointsModeEnum)pointsModeProperty.enumValueIndex; //ask for confirmation in case changes may affect something else if ((Curve.PointsMode == BGCurve.PointsModeEnum.Components) && !BGEditorUtility.Confirm("Convert Points", "Are you sure you want to convert points? All existing references to these points will be lost.", "Convert")) { return; } if ((Curve.PointsMode == BGCurve.PointsModeEnum.GameObjectsNoTransform && newPointsMode != BGCurve.PointsModeEnum.GameObjectsTransform || Curve.PointsMode == BGCurve.PointsModeEnum.GameObjectsTransform && newPointsMode != BGCurve.PointsModeEnum.GameObjectsNoTransform) && !BGEditorUtility.Confirm("Convert Points", "Are you sure you want to convert points? All existing GameObjects for points will be deleted.", "Convert")) { return; } editorSelection.Clear(); //invoke convert BGPrivateField.Invoke(Curve, BGCurve.MethodConvertPoints, newPointsMode, BGCurveEditor.GetPointProvider(newPointsMode, Curve), BGCurveEditor.GetPointDestroyer(Curve.PointsMode, Curve)); //this call is not required // serializedObject.ApplyModifiedProperties(); } // ============================================== 2D mode if ((int)curve.Mode2D != mode2DProperty.enumValueIndex) { Curve.FireBeforeChange(BGCurve.Event2D); serializedObject.ApplyModifiedProperties(); var oldEventMode = Curve.EventMode; Curve.EventMode = BGCurve.EventModeEnum.NoEvents; //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")) { if (Curve.Mode2D != BGCurve.Mode2DEnum.Off) { Apply2D(settings.HandlesSettings); Apply2D(settings.ControlHandlesSettings); } else { Apply3D(settings.HandlesSettings); Apply3D(settings.ControlHandlesSettings); } } Curve.EventMode = oldEventMode; Curve.FireChange(BGCurveChangedArgs.GetInstance(Curve, BGCurveChangedArgs.ChangeTypeEnum.Points, BGCurve.Event2D)); } // ============================================== Snapping if ((int)curve.SnapType != snapTypeProperty.enumValueIndex) { SnappingChanged(BGCurve.EventSnapType); } if ((int)curve.SnapAxis != snapAxisProperty.enumValueIndex) { SnappingChanged(BGCurve.EventSnapAxis); } if (Math.Abs((int)curve.SnapDistance - snapDistanceProperty.floatValue) > BGCurve.Epsilon) { SnappingChanged(BGCurve.EventSnapDistance); } if ((int)curve.SnapTriggerInteraction != snapTriggerInteractionProperty.enumValueIndex) { SnappingChanged(BGCurve.EventSnapTrigger); } if (curve.SnapToBackFaces != snapToBackFacesProperty.boolValue) { SnappingChanged(BGCurve.EventSnapBackfaces); } if (curve.SnapMonitoring != snapMonitoringProperty.boolValue) { SnappingChanged(BGCurve.EventSnapMonitoring); } // ============================================== Event mode if ((int)curve.EventMode != eventModeProperty.enumValueIndex) { serializedObject.ApplyModifiedProperties(); } // ============================================== Control Type if ((int)settings.ControlType != controlTypeProperty.enumValueIndex) { serializedObject.ApplyModifiedProperties(); } }
protected override void AddPoint(BGCurve curve, Vector3 intersectionPosition, BGCurveSettings settings) { BGCurveEditor.AddPoint(curve, CreatePoint(curve, settings), pointIndex + 1); }
protected override void Delete() { BGCurveEditor.DeletePoint(point.Curve, point.Curve.IndexOf(point)); }
//default implementation adds a point to the spline's end protected virtual void AddPoint(BGCurve curve, Vector3 intersectionPosition, BGCurveSettings settings) { BGCurveEditor.AddPoint(curve, BGNewPointPositionManager.CreatePoint(intersectionPosition, curve, settings.ControlType, settings.Sections, true), curve.PointsCount); }
public BGCurveEditorFields(BGCurveEditor editor, SerializedObject curveObject) : base(editor, curveObject, BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGFields123)) { }
public static void DrawGizmos(BGCurve curve, GizmoType gizmoType) { BGCurveEditor.DrawGizmos(curve, gizmoType); }