public ValueReference(Object obj, object value, SceneAsset scene, string path) { Obj = obj; Value = value; Scene = scene; Path = path; ValueString = value == null ? "NULL" : value.ToString(); }
public static void PerformActionInScenes(string progressBarTitle, Predicate <string> scenePathFilter, SceneProcessingAction action) { if (EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo()) { string originalScene = UnityEngine.SceneManagement.SceneManager.GetActiveScene().path; try { string[] scenesGUIDs = AssetDatabase.FindAssets("t:Scene"); List <string> scenePaths = new List <string>(); for (int i = 0; i < scenesGUIDs.Length; i++) { string path = AssetDatabase.GUIDToAssetPath(scenesGUIDs[i]); if (path.StartsWith("Assets/") && (scenePathFilter == null || scenePathFilter(path))) { scenePaths.Add(path); } } for (int i = 0; i < scenePaths.Count; i++) { SceneAsset scene = AssetDatabase.LoadAssetAtPath <SceneAsset>(scenePaths[i]); if (EditorUtility.DisplayCancelableProgressBar(progressBarTitle, "(" + (i + 1) + " / " + scenePaths.Count + ") " + scene.name, ((float)i) / scenePaths.Count)) { break; } if (EditorSceneManager.OpenScene(scenePaths[i], OpenSceneMode.Single).IsValid()) { action(scene, scenePaths[i]); } } EditorUtility.ClearProgressBar(); } catch (Exception e) { UnityEngine.Debug.LogException(e); } finally { EditorSceneManager.OpenScene(originalScene, OpenSceneMode.Single); EditorUtility.ClearProgressBar(); } } }
public static List <ValueReference> FindComponentFieldValuesInCurrentScene(Type type, FieldInfo field) { List <ValueReference> references = new List <ValueReference>(); SceneAsset scene = GetCurrentScene(); Object[] usages = Object.FindObjectsOfType(type); for (int i = 0; i < usages.Length; i++) { references.Add(new ValueReference(usages[i], field.GetValue(usages[i]), scene, (usages[i] as Component).gameObject.GetPath())); } return(references); }
public static List <AssetReference> FindPrefabInstancesInCurrentScene(GameObject prefab) { List <AssetReference> references = new List <AssetReference>(); SceneAsset scene = GetCurrentScene(); GameObject[] objects = Object.FindObjectsOfType <GameObject>(); for (int i = 0; i < objects.Length; i++) { if (PrefabUtility.GetPrefabInstanceStatus(objects[i]) == PrefabInstanceStatus.Connected && PrefabUtility.GetCorrespondingObjectFromOriginalSource(objects[i]) == prefab) { references.Add(new AssetReference(objects[i], scene, objects[i].GetPath())); } } return(references); }
public static void PerformActionInScenes(string progressBarTitle, IList <string> scenePaths, SceneProcessingAction action) { if (EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo()) { string originalScene = UnityEngine.SceneManagement.SceneManager.GetActiveScene().path; try { for (int i = 0; i < scenePaths.Count; i++) { SceneAsset scene = AssetDatabase.LoadAssetAtPath <SceneAsset>(scenePaths[i]); if (EditorUtility.DisplayCancelableProgressBar(progressBarTitle, "(" + (i + 1) + "/" + scenePaths.Count + ") " + scene.name, ((float)i) / scenePaths.Count)) { break; } if (EditorSceneManager.OpenScene(scenePaths[i], OpenSceneMode.Single).IsValid()) { action(scene, scenePaths[i]); } } EditorUtility.ClearProgressBar(); } catch (Exception e) { UnityEngine.Debug.LogException(e); } finally { EditorSceneManager.OpenScene(originalScene, OpenSceneMode.Single); EditorUtility.ClearProgressBar(); } } }
public void AsnycLoadLevel(string _levelName, OnLevelLoad onLoad = null) { if (isLoading) { return; } isLoading = true; if (null != sceneAsset) { sceneAsset.Release(); sceneAsset = null; } levelName = _levelName; this.onLoad = onLoad; bool isAdded = string.IsNullOrEmpty(levelName) || AppEnv.IsSceneInBuild(levelName); #if UNITY_EDITOR if (!AppEnv.UseBundleInEditor && !isAdded) { //在编辑器里使用非bundle模式的场景,目前已知必须要在build setting里 Debug.LogError("if use raw asset in editor,you must add scene to buildsetting"); return; } #endif if (isAdded) { StartCoroutine(LoadScene()); } else { sceneAsset = new SceneAsset(); sceneAsset.Load(levelName, () => { StartCoroutine(LoadScene(sceneAsset.asset)); }); } }
public AssetReference(Object obj, SceneAsset scene, string path) { Obj = obj; Scene = scene; Path = path; }