private void OnSelectedSplineChanged(SplineBase oldSpline, SplineBase newSpline) { if (Application.isPlaying) { if (oldSpline != null) { oldSpline.Unselect(); if (RuntimeSelection.activeGameObject != null && RuntimeSelection.activeGameObject.GetComponentInParent <SplineBase>() == oldSpline) { RuntimeSelection.activeGameObject = null; } } if (newSpline != null) { RuntimeSelection.activeGameObject = newSpline.gameObject; } m_hierarchy.SelectedItem = newSpline; } else { if (oldSpline != null) { oldSpline.Unselect(); } } }
public void OnClosed() { if (RuntimeSelection.gameObjects == null) { return; } GameObject[] gameObjects = RuntimeSelection.gameObjects.OfType <GameObject>().ToArray(); for (int i = 0; i < gameObjects.Length; ++i) { GameObject go = gameObjects[i]; if (go == null) { continue; } SplineBase spline = go.GetComponentInParent <SplineBase>(); if (spline == null) { continue; } spline.Unselect(); } }
private void OnHierarchySelectionChanged(object sender, SelectionChangedEventArgs e) { if (e.NewItem != null && e.NewItem is SplineBase) { SplineBase newSpline = (SplineBase)e.NewItem; if (!newSpline.IsSelected) { newSpline.Select(); } #if UNITY_EDITOR if (UnityEditor.Selection.activeGameObject == null || UnityEditor.Selection.activeGameObject.GetComponentInParent <SplineBase>() != m_hierarchy.SelectedItem) { UnityEditor.Selection.activeObject = m_hierarchy.SelectedItem; } #endif } else if (e.OldItem != null && e.OldItem is SplineBase) { SplineBase oldSpline = (SplineBase)e.OldItem; if (oldSpline.IsSelected) { oldSpline.Unselect(); } #if UNITY_EDITOR if (UnityEditor.Selection.activeObject == (UnityEngine.Object)e.OldItem) { UnityEditor.Selection.activeObject = null; } #endif } }
public static void Separate(SplineBase spline, int controlPointIndex) { RecordHierarchy(spline.Root, "Battlehub.Spline.Separate"); spline.Unselect(); spline.Disconnect(controlPointIndex); spline.Select(); EditorUtility.SetDirty(spline.Root); }
private void OnDisable() { OnDisableOverride(); SplineBase spline = GetTarget(); if (spline) { spline.Unselect(); } }
public static void Separate(SplineBase spline, int controlPointIndex) { spline.Unselect(); spline.Disconnect(controlPointIndex); spline.Select(); }
private void OnRuntimeSelectionChanged(UnityEngine.Object[] unselected) { SplineBase minSpline = null; int minIndex = -1; float minDistance = float.PositiveInfinity; if (unselected != null) { GameObject[] gameObjects = unselected.OfType <GameObject>().ToArray(); for (int i = 0; i < gameObjects.Length; ++i) { GameObject go = gameObjects[i]; if (go == null) { continue; } SplineBase spline = go.GetComponentInParent <SplineBase>(); if (spline == null) { continue; } spline.Select(); float distance = minDistance; SplineBase hitSpline; int selectedIndex = HitTestRecursive(spline.Root, minDistance, out hitSpline, out distance); if (distance < minDistance && selectedIndex != -1) { minDistance = distance; minIndex = selectedIndex; minSpline = hitSpline; } spline.Unselect(); } if (minSpline != null) { SplineControlPoint ctrlPoint = minSpline.GetSplineControlPoints().Where(p => p.Index == minIndex).FirstOrDefault(); if (ctrlPoint != null) { RuntimeSelection.activeObject = ctrlPoint.gameObject; } minSpline.Select(); return; } } if (RuntimeSelection.gameObjects != null) { GameObject[] gameObjects = RuntimeSelection.gameObjects; if (gameObjects != null) { for (int i = 0; i < gameObjects.Length; ++i) { SplineBase spline = gameObjects[i].GetComponentInParent <SplineBase>(); if (spline != null) { spline.Select(); } } } } }