private static void OnFindingAssets() { var file = Files[Index]; var path = PathsUtility.ConvertFullAbsolutePathToAssetPath(file); var isCancel = EditorUtility.DisplayCancelableProgressBar(FindingAssetsStr, file, (float)Index / Files.Length); if (Regex.IsMatch(File.ReadAllText(file), Guid)) { FoundAssets.Add(AssetDatabase.LoadAssetAtPath <Object>(path)); } Index++; if (isCancel) { FoundAssets.Clear(); } if (Index >= Files.Length) { OnFindAssetsCompleted(FoundAssets); } if (isCancel || Index >= Files.Length) { EditorUtility.ClearProgressBar(); EditorApplication.update -= OnFindingAssets; Index = 0; } }
private static void OnMatchingAssets() { var file = Files[Index]; var path = PathsUtility.ConvertFullAbsolutePathToAssetPath(file); var isCancel = EditorUtility.DisplayCancelableProgressBar(MatchingAssetsStr, file, (float)Index / Files.Length); if (Regex.IsMatch(Text, AssetDatabase.AssetPathToGUID(path))) { MatchedAssets.Add(AssetDatabase.LoadAssetAtPath(path, typeof(Object))); } Index++; if (isCancel) { MatchedAssets.Clear(); } if (Index >= Files.Length) { OnMatchAssetsCompleted(MatchedAssets); } if (isCancel || Index >= Files.Length) { EditorUtility.ClearProgressBar(); EditorApplication.update -= OnMatchingAssets; Index = 0; } }
public static void MoveAssets(string movePath, params Object[] assetObjects) { if (!string.IsNullOrEmpty(movePath)) { MovePath = PathsUtility.ConvertFullAbsolutePathToAssetPath(movePath); MoveAssetObjects = assetObjects; EditorApplication.update += OnMovingAssets; } else { OnMoveAssetsCanceled(); } }
public static void CreateAssetWithSavePrompt <T>(T asset, string defaultName = "New ScriptableObject", System.Func <T, bool> postCreated = null) where T : ScriptableObject { var path = EditorUtility.SaveFilePanel("Save 'ScriptableObject' file to folder", PathsUtility.TryGetSelectedFolderPathInProjectsTab(), defaultName, "asset"); if (!string.IsNullOrEmpty(path)) { if (path.Contains(Application.dataPath)) { var savePath = path.Replace(Application.dataPath, "Assets"); CreateAsset(asset, savePath); if (postCreated != null && !postCreated(asset)) { } else { ProjectWindowUtil.ShowCreatedAsset(AssetDatabase.LoadAssetAtPath <ScriptableObject>(savePath)); } } else { Debug.LogError("Sorry, we cannot save 'ScriptableObject' file out of 'Assets' folder!"); } } }