|
|
|
|
|
|
selectionHistory = null; |
|
|
|
} |
|
|
|
|
|
|
|
List<GameObject[]> selectionHistory; |
|
|
|
List<GameObject[]> lockedObjects; |
|
|
|
List<GameObject> selectionHistory; |
|
|
|
List<GameObject> lockedObjects; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void OnSelectionChange() |
|
|
|
{ |
|
|
|
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
if (selectionHistory == null) selectionHistory = new List<GameObject[]>(); |
|
|
|
if (lockedObjects == null) lockedObjects = new List<GameObject[]>(); |
|
|
|
if (selectionHistory == null) selectionHistory = new List<GameObject>(); |
|
|
|
if (lockedObjects == null) lockedObjects = new List<GameObject>(); |
|
|
|
|
|
|
|
foreach(var go in Selection.gameObjects) |
|
|
|
{ |
|
|
|
if (!selectionHistory.Contains(go)) |
|
|
|
selectionHistory.Add(go); |
|
|
|
} |
|
|
|
|
|
|
|
selectionHistory.RemoveAt(0); |
|
|
|
selectionHistory.Take(maxHistoryCount); |
|
|
|
if (selectionHistory.Count == 0 || CompareArray(selectionHistory[selectionHistory.Count - 1], Selection.gameObjects)) ; |
|
|
|
selectionHistory.Add(Selection.gameObjects); |
|
|
|
Repaint(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
return a.SequenceEqual(b); |
|
|
|
} |
|
|
|
|
|
|
|
private static bool CheckObjects(GameObject[] objs) |
|
|
|
{ |
|
|
|
if (objs == null) return false; |
|
|
|
|
|
|
|
foreach (var obj in objs) |
|
|
|
{ |
|
|
|
if (obj == null) return false; |
|
|
|
} |
|
|
|
return true; |
|
|
|
if (selectionHistory == null) selectionHistory = new List<GameObject[]>(); |
|
|
|
if (lockedObjects == null) lockedObjects = new List<GameObject[]>(); |
|
|
|
if (selectionHistory == null) selectionHistory = new List<GameObject>(); |
|
|
|
if (lockedObjects == null) lockedObjects = new List<GameObject>(); |
|
|
|
|
|
|
|
using (new EditorGUILayout.HorizontalScope()) |
|
|
|
{ |
|
|
|
if (GUILayout.Button("Unselect All")) |
|
|
|
{ |
|
|
|
Selection.activeObject = null; |
|
|
|
ignoreNextSelection = true; |
|
|
|
Repaint(); |
|
|
|
} |
|
|
|
} |
|
|
|
GUILayout.Label("Retained", EditorStyles.boldLabel); |
|
|
|
GUILayout.Label("Favorites", EditorStyles.boldLabel); |
|
|
|
if (obj == null || obj.Length == 0 || !CheckObjects(obj)) |
|
|
|
if (obj == null) |
|
|
|
{ |
|
|
|
using (new EditorGUILayout.HorizontalScope()) |
|
|
|
{ |
|
|
|
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
bool highlight = Selection.gameObjects.Contains(obj); |
|
|
|
Color backup = GUI.color; |
|
|
|
|
|
|
|
if (highlight) |
|
|
|
GUI.color = Styles.highlightColor; |
|
|
|
|
|
|
|
GUILayout.Label(Contents.star, GUILayout.Width(24)); |
|
|
|
string label = obj.Length > 1 ? "Multiple (" + obj.Length + ") : " + obj[0].name + " ..." : obj[0].name; |
|
|
|
if (GUILayout.Button(label)) |
|
|
|
GUILayout.Label(Contents.star, EditorStyles.miniLabel, GUILayout.Width(24)); |
|
|
|
string label = obj.name; |
|
|
|
|
|
|
|
if (GUILayout.Button(label, EditorStyles.foldout)) |
|
|
|
Selection.objects = obj; |
|
|
|
Selection.activeObject = obj; |
|
|
|
if (GUILayout.Button("F", GUILayout.Width(24))) |
|
|
|
if (GUILayout.Button("Focus", EditorStyles.miniButton, GUILayout.Width(40))) |
|
|
|
Selection.objects = obj; |
|
|
|
Selection.activeObject = obj; |
|
|
|
if (GUILayout.Button("X", GUILayout.Width(24))) |
|
|
|
if (GUILayout.Button("X", EditorStyles.miniButton, GUILayout.Width(24))) |
|
|
|
var rect = GUILayoutUtility.GetLastRect(); |
|
|
|
EditorGUI.DrawRect(rect, new Color(0.2f, 0.2f, 0.2f, 0.5f)); |
|
|
|
|
|
|
|
GUI.color = backup; |
|
|
|
} |
|
|
|
i++; |
|
|
|
} |
|
|
|
|
|
|
selectionHistory.Clear(); |
|
|
|
Repaint(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
GUILayout.Space(8); |
|
|
|
var reversedHistory = selectionHistory.Reverse<GameObject[]>().ToArray(); |
|
|
|
var reversedHistory = selectionHistory.Reverse<GameObject>().ToArray(); |
|
|
|
if (obj == null || obj.Length == 0 || !CheckObjects(obj)) |
|
|
|
if (obj == null) |
|
|
|
{ |
|
|
|
using (new EditorGUILayout.HorizontalScope()) |
|
|
|
{ |
|
|
|
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
bool highlight = Selection.gameObjects.Contains(obj); |
|
|
|
Color backup = GUI.color; |
|
|
|
|
|
|
|
if (highlight) |
|
|
|
GUI.color = Styles.highlightColor; |
|
|
|
|
|
|
|
GUILayout.Space(24); |
|
|
|
string label = obj.Length > 1 ? "Multiple (" + obj.Length + ") : " + obj[0].name + " ..." : obj[0].name; |
|
|
|
if (GUILayout.Button(label)) |
|
|
|
|
|
|
|
GUILayout.Space(16); |
|
|
|
string label = obj.name; |
|
|
|
if (GUILayout.Button(label, EditorStyles.foldout)) |
|
|
|
Selection.objects = obj; |
|
|
|
Selection.activeObject = obj; |
|
|
|
if (GUILayout.Button("F", GUILayout.Width(24))) |
|
|
|
if (GUILayout.Button("Focus", Styles.historyButton, GUILayout.Width(40))) |
|
|
|
Selection.objects = obj; |
|
|
|
Selection.activeObject = obj; |
|
|
|
if (GUILayout.Button("+", GUILayout.Width(24))) |
|
|
|
if (GUILayout.Button(Contents.star, Styles.historyButton, GUILayout.Width(24))) |
|
|
|
var rect = GUILayoutUtility.GetLastRect(); |
|
|
|
EditorGUI.DrawRect(rect, new Color(0.2f,0.2f,0.2f,0.5f)); |
|
|
|
|
|
|
|
GUI.color = backup; |
|
|
|
} |
|
|
|
|
|
|
|
i++; |
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
static class Styles |
|
|
|
{ |
|
|
|
public static GUIStyle historyButton; |
|
|
|
public static GUIStyle highlight; |
|
|
|
public static Color highlightColor = new Color(2.0f, 2.0f, 2.0f); |
|
|
|
|
|
|
|
static Styles() |
|
|
|
{ |
|
|
|
historyButton = new GUIStyle(EditorStyles.miniButton); |
|
|
|
historyButton.alignment = TextAnchor.MiddleLeft; |
|
|
|
highlight = new GUIStyle(EditorStyles.miniLabel); |
|
|
|
highlight.onNormal.background = Texture2D.whiteTexture; |
|
|
|
highlight.onHover.background = Texture2D.whiteTexture; |
|
|
|
highlight.onActive.background = Texture2D.whiteTexture; |
|
|
|
highlight.onFocused.background = Texture2D.whiteTexture; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public static GUIContent title = new GUIContent("Select History"); |
|
|
|
public static GUIContent title = new GUIContent("Selection History"); |
|
|
|
public static GUIContent star = EditorGUIUtility.IconContent("CustomSorting"); |
|
|
|
} |
|
|
|
} |