public static void SortSmartNext() { Events.Pause("On Hierarchy Changed"); int index = DataBehaviour.processIndex; var sorting = DataBehaviour.sorting; bool canceled = true; if (index < DataBehaviour.sorting.Length - 1) { var current = DataBehaviour.sorting[index]; float total = (float)index / sorting.Length; string message = index + " / " + sorting.Length + " -- " + current.GetPath(); canceled = EditorUI.DrawProgressBar("Sorting All Components", message, total); current.PauseValidate(); DataBehaviour.SortSmartTarget(current); current.ResumeValidate(); } DataBehaviour.processIndex += 1; if (canceled || index + 1 > sorting.Length - 1) { EditorUI.ClearProgressBar(); Events.Remove("On Editor Update", DataBehaviour.SortSmartNext); Events.Resume("On Hierarchy Changed"); } }
public static void SortSmartSelected() { foreach (var target in Selection.gameObjects) { DataBehaviour.SortSmartTarget(target); } }
public static void ApplyPrefabSelected() { Debug.Log("[DataBehaviour] Applying prefab"); foreach (var target in Selection.gameObjects) { DataBehaviour.ApplyPrefabTarget(target); } }
//=============== // Shared //=============== public static void SortSmartTarget(GameObject target) { Component[] components = target.GetComponents <Component>().ToList().OrderBy(x => x.GetAlias()).ToArray(); DataBehaviour.Sort(components); var controller = components.Find(x => x.GetType().Name.Contains("State")); if (!controller.IsNull()) { controller.MoveToTop(); } }
public void ApplyPrefab() { DataBehaviour.ApplyPrefabTarget(this.gameObject); }
public void SortSmart() { DataBehaviour.SortSmartTarget(this.gameObject); }
public void SortByAlias() { Component[] components = this.GetComponents <Component>().ToList().OrderBy(x => x.GetAlias()).ToArray(); DataBehaviour.Sort(components); }