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); }
private void UpdateFlags() { GameObject[] selected = Editor.Selection.gameObjects; if (selected != null && selected.Length > 0) { m_isMeshDeformerSelected = selected.Where(go => { if (go.GetComponent <Deformer>()) { return(true); } ControlPointPicker picker = go.GetComponentInParent <ControlPointPicker>(); return(picker != null && picker.Selection != null && picker.Selection.GetSpline() is Deformer && picker.Selection.Index >= 0); }).Any(); } else { m_isMeshDeformerSelected = false; } if (m_deformerSettingsSection != null) { m_deformerSettingsSection.SetActive(m_isMeshDeformerSelected); } }
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 bool CanRemove() { ControlPointPicker picker = m_editor.Selection.activeGameObject.GetComponent <ControlPointPicker>(); if (picker == null) { return(false); } return(picker != null && picker.Selection != null && picker.Selection.GetSpline().SegmentsCount > 1 && picker.Selection.Index >= 0); }
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); }
private void RecordState(GameObject spline, BaseSplineState oldState, BaseSplineState newState, ControlPointPicker picker, PickResult oldSelection, PickResult newSelection) { m_editor.Undo.CreateRecord(record => { Deformer deformer = spline.GetComponent <Deformer>(); deformer.SetState(newState); picker.Selection = newSelection; return(true); }, record => { Deformer deformer = spline.GetComponent <Deformer>(); deformer.SetState(oldState); picker.Selection = oldSelection; return(true); }); }
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); }
private void Awake() { m_editor = IOC.Resolve <IRTE>(); m_editor.Tools.ToolChanged += OnEditorToolChanged; IOC.RegisterFallback <IMeshDeformerTool>(this); m_picker = FindObjectOfType <ControlPointPicker>(); if (m_picker == null) { GameObject controlPointPicker = new GameObject("ControlPointPicker"); controlPointPicker.transform.SetParent(transform, false); controlPointPicker.gameObject.SetActive(false); controlPointPicker.hideFlags = HideFlags.HideInHierarchy; ExposeToEditor exposeToEditor = controlPointPicker.AddComponent <ExposeToEditor>(); exposeToEditor.CanInspect = false; controlPointPicker.gameObject.SetActive(true); m_picker = controlPointPicker.AddComponent <ControlPointPicker>(); } m_picker.SelectionChanged += OnPickerSelectionChanged; }