public bool DragControlPoint(bool extend) { PositionHandle positionHandle = m_editor.Tools.ActiveTool as PositionHandle; if (m_picker.IsControlPointSelected && positionHandle != null && positionHandle.IsDragging) { if (extend) { ControlPointPicker picker = m_editor.Selection.activeGameObject.GetComponent <ControlPointPicker>(); BaseSpline spline = picker.Selection.GetSpline(); BaseSplineState oldState = spline.GetState(); PickResult oldSelection = picker.Selection != null ? new PickResult(picker.Selection) : null; m_picker.Drag(true); spline = picker.Selection.GetSpline(); BaseSplineState newState = spline.GetState(); PickResult newSelection = picker.Selection != null ? new PickResult(picker.Selection) : null; RecordState(spline.gameObject, oldState, newState, picker, oldSelection, newSelection); } else { m_picker.Drag(false); } return(true); } return(false); }
/// <summary> /// Determine which spline to follow. /// </summary> private void FindNextSpline() { m_isFollowing = false; m_tValue = 0; // CurSpline = null; CurSpline = m_splineController.FindNextSpline(); }
public bool CanAppend() { ControlPointPicker picker = m_editor.Selection.activeGameObject.GetComponent <ControlPointPicker>(); BaseSpline spline = picker.Selection.GetSpline(); return(picker.Selection.Index == spline.SegmentsCount + 1 || picker.Selection.Index == spline.SegmentsCount + 2 || picker.Selection.Index == 0 || picker.Selection.Index == 1); }
public void Remove() { ControlPointPicker picker = m_editor.Selection.activeGameObject.GetComponent <ControlPointPicker>(); BaseSpline spline = picker.Selection.GetSpline(); BaseSplineState oldState = spline.GetState(); PickResult oldSelection = picker.Selection != null ? new PickResult(picker.Selection) : null; picker.Remove(); PickResult newSelection = picker.Selection != null ? new PickResult(picker.Selection) : null; spline = picker.Selection.GetSpline(); BaseSplineState newState = spline.GetState(); RecordState(spline.gameObject, oldState, newState, picker, oldSelection, newSelection); }
protected override void Awake() { m_spline = GetComponents <BaseSpline>().Where(c => c != this).FirstOrDefault(); if (m_spline == null) { m_spline = gameObject.AddComponent <CatmullRomSpline>(); m_spline.IsLooping = false; m_initialize = true; } else { m_initialize = m_spline.SegmentsCount == 0; } m_spline.IsSelectable = false; }
public void Append() { ControlPointPicker picker = m_editor.Selection.activeGameObject.GetComponent <ControlPointPicker>(); BaseSpline spline = picker.Selection.GetSpline(); BaseSplineState oldState = spline.GetState(); PickResult oldSelection = picker.Selection != null ? new PickResult(picker.Selection) : null; if (picker.Selection.Index == 0 || picker.Selection.Index == 1) { picker.Prepend(); } else { picker.Append(); } spline = picker.Selection.GetSpline(); BaseSplineState newState = spline.GetState(); PickResult newSelection = picker.Selection != null ? new PickResult(picker.Selection) : null; RecordState(spline.gameObject, oldState, newState, picker, oldSelection, newSelection); }
/// <summary> /// Awake this instance. /// </summary> public void Awake() { CurSpline = m_splineController.m_treeRoot.m_spline; }
public void SelectControlPoint(Camera camera, Vector2 point) { if (m_selectionComponentState == null) { return; } if (m_selectionComponentState.Component.IsPositionHandleEnabled) { BaseSpline spline = m_controlPointPicker.Selection != null?m_controlPointPicker.Selection.GetSpline() : null; if (spline != null && !(spline is Deformer)) { return; } m_editor.Undo.BeginRecord(); PickResult oldSelection = m_controlPointPicker.Selection != null ? new PickResult(m_controlPointPicker.Selection) : null; PickResult newSelection = m_controlPointPicker.Pick(camera, point); if (newSelection != null && newSelection.Spline != null && newSelection.Spline.GetComponent <Deformer>() == null) { newSelection = null; } GameObject deformerGo = null; if (newSelection == null) { RaycastHit hit; if (Physics.Raycast(camera.ScreenPointToRay(point), out hit)) { Segment segment = hit.collider.GetComponent <Segment>(); if (segment != null) { Deformer deformer = segment.GetComponentInParent <Deformer>(); if (deformer != null) { deformerGo = deformer.gameObject; } } } } if (deformerGo != null) { m_editor.Selection.Select(deformerGo, new[] { deformerGo }); } m_controlPointPicker.ApplySelection(newSelection, true); newSelection = newSelection != null ? new PickResult(newSelection) : null; m_editor.Undo.CreateRecord(record => { m_controlPointPicker.Selection = newSelection; if (deformerGo != null) { m_editor.Selection.Select(deformerGo, new[] { deformerGo }); } return(true); }, record => { m_controlPointPicker.Selection = oldSelection; if (deformerGo != null) { m_editor.Selection.Select(deformerGo, new[] { deformerGo }); } return(true); }); m_editor.Undo.EndRecord(); } }