void GetObjects() { string[] guids = AssetDatabase.FindAssets("t:prefab"); string path = ""; GameObject go = null; prefabs = new Keylist <string, GameObject>(); for (int i = 0; i < guids.Length; i++) { // Get the path of the current guid path = AssetDatabase.GUIDToAssetPath(guids[i]); // Load gameObject go = AssetDatabase.LoadAssetAtPath <GameObject>(path); // Continue if (null == go) { continue; } // Add to the key list prefabs.Add(path.Substring(0, path.LastIndexOf("/")), go); } isExpanded = new List <bool>(); for (int k = 0; k < prefabs.KeyCount; k++) { isExpanded.Add(true); } }
void CreateEditors(Keylist <Type, Object> keylist) { // Each editor contains targets which are an array of components by type from different GameObjects editors = new Editor[keylist.KeyCount]; // Create content from key types contents = new string[keylist.KeyCount]; for (int i = 0; i < editors.Length; i++) { // Create editor from array of components of the same type editors[i] = Editor.CreateEditor(keylist.Values[i].ToArray()); // Get name contents[i] = keylist[i].Name; } }
Keylist <Type, Object> GetEditorKeylist(SerializedProperty[] components) { // We are going to organize components by type using a Keylist Keylist <Type, Object> keylist = new Keylist <Type, Object>(); // Current type Type type = null; // Current object reference value Object value = null; for (int i = 0; i < components.Length; i++) { // Get object value value = components[i].objectReferenceValue; // Get type type = value.GetType(); // Add to key list keylist.Add(type, value); } return(keylist); }
void GetEditors() { if (SelectionNULL()) { return; } // Create an editor with the gameObjects Selected editor = Editor.CreateEditor(Selection.gameObjects); // Exit if editor is null if (EditorNULL) { Repaint(); return; } // Get the component array from each target SerializedProperty[] components = GetComponentArray(editor.targets); // Get editor keylist Keylist <Type, Object> keylist = GetEditorKeylist(components); // Create editors CreateEditors(keylist); }