public void Off() { if (!IsOn) { return; } IsOn = false; if (selectionWasMade) { return; } if (selection.HasSelected()) { selection.Clear(); SceneView.RepaintAll(); } }
public void Off() { if (!IsOn) { return; } IsOn = false; if (selectionWasMade) { return; } if (selection.HasSelected()) { selection.Clear(); EditorUtility.SetDirty(curve); } else { BGCurveEditor.OverlayMessage.Display("The Scene view is locked.\r\n Set 'Lock View' (in the BGCurve Editor) to false to unlock."); } }
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(); } }