/// <summary> /// Show the selection wizard. /// </summary> static public void Show <T> (OnSelectionCallback cb, int?index) where T : Object { System.Type type = typeof(T); XfgjComponentSelector comp = ScriptableWizard.DisplayWizard <XfgjComponentSelector>("Select a " + GetName(type)); comp.mType = type; comp.mCallback = cb; comp.index = index; if (type == typeof(UIAtlas) || type == typeof(UIFont)) { BetterList <T> list = new BetterList <T>(); string[] paths = AssetDatabase.GetAllAssetPaths(); for (int i = 0; i < paths.Length; ++i) { string path = paths[i]; if (path.EndsWith(".prefab", System.StringComparison.OrdinalIgnoreCase)) { GameObject obj = AssetDatabase.LoadMainAssetAtPath(path) as GameObject; if (obj != null && PrefabUtility.GetPrefabType(obj) == PrefabType.Prefab) { T t = obj.GetComponent(typeof(T)) as T; if (t != null) { list.Add(t); } } } } comp.mObjects = list.ToArray(); } else if (type == typeof(SceneAsset)) { BetterList <Object> list = new BetterList <Object>(); string[] paths = AssetDatabase.GetAllAssetPaths(); for (int i = 0; i < paths.Length; ++i) { string path = paths[i]; if (path.EndsWith(XfgjEditor.SCENE_EXT, System.StringComparison.OrdinalIgnoreCase) && path.Contains(XfgjEditor.SCENE_FOLDER)) { SceneAsset sceneAsset = SceneAsset.CreateInstance <SceneAsset>(); sceneAsset.assetPath = path; list.Add(sceneAsset); } } comp.mObjects = list.ToArray(); } else { comp.mObjects = Resources.FindObjectsOfTypeAll(typeof(T)); } }