|
4 | 4 |
|
5 | 5 | using System;
|
6 | 6 | using System.Collections.Generic;
|
7 |
| -using System.Globalization; |
8 | 7 | using UnityEngine;
|
9 | 8 | using UnityEditor.VersionControl;
|
10 | 9 | using UnityEditorInternal;
|
@@ -243,6 +242,65 @@ static AssetDeleteResult OnWillDeleteAsset(string assetPath, RemoveAssetOptions
|
243 | 242 | return finalResult;
|
244 | 243 | }
|
245 | 244 |
|
| 245 | + static void OnWillDeleteAssets(string[] assetPaths, AssetDeleteResult[] outPathDeletionResults, RemoveAssetOptions options) |
| 246 | + { |
| 247 | + for (int i = 0; i < outPathDeletionResults.Length; i++) |
| 248 | + outPathDeletionResults[i] = (int)AssetDeleteResult.DidNotDelete; |
| 249 | + |
| 250 | + List<string> nonDeletedPaths = new List<string>(); |
| 251 | + List<int> nonDeletedPathIndices = new List<int>(); |
| 252 | + foreach (var assetModificationProcessorClass in AssetModificationProcessors) |
| 253 | + { |
| 254 | + MethodInfo method = assetModificationProcessorClass.GetMethod("OnWillDeleteAsset", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); |
| 255 | + if (method == null) |
| 256 | + continue; |
| 257 | + |
| 258 | + for (int i = 0; i < assetPaths.Length; i++) |
| 259 | + { |
| 260 | + object[] args = { assetPaths[i], options }; |
| 261 | + if (!CheckArgumentsAndReturnType(args, method, typeof(AssetDeleteResult))) |
| 262 | + continue; |
| 263 | + |
| 264 | + AssetDeleteResult callbackResult = (AssetDeleteResult)method.Invoke(null, args); |
| 265 | + outPathDeletionResults[i] |= callbackResult; |
| 266 | + } |
| 267 | + } |
| 268 | + |
| 269 | + for (int i = 0; i < assetPaths.Length; i++) |
| 270 | + { |
| 271 | + if (outPathDeletionResults[i] == (int)AssetDeleteResult.DidNotDelete) |
| 272 | + { |
| 273 | + nonDeletedPaths.Add(assetPaths[i]); |
| 274 | + nonDeletedPathIndices.Add(i); |
| 275 | + } |
| 276 | + } |
| 277 | + |
| 278 | + if (nonDeletedPaths.Count > 0) |
| 279 | + { |
| 280 | + if (!Provider.enabled || EditorUserSettings.WorkOffline) |
| 281 | + return; |
| 282 | + |
| 283 | + for (int i = 0; i < nonDeletedPaths.Count; i++) |
| 284 | + { |
| 285 | + if (!Provider.PathIsVersioned(nonDeletedPaths[i])) |
| 286 | + { |
| 287 | + nonDeletedPaths.RemoveAt(i); |
| 288 | + nonDeletedPathIndices.RemoveAt(i); |
| 289 | + i--; |
| 290 | + } |
| 291 | + } |
| 292 | + |
| 293 | + var nonDeletedPathDeletionResults = new AssetDeleteResult[nonDeletedPaths.Count]; |
| 294 | + |
| 295 | + AssetModificationHook.OnWillDeleteAssets(nonDeletedPaths.ToArray(), nonDeletedPathDeletionResults, options); |
| 296 | + |
| 297 | + for (int i = 0; i < nonDeletedPathIndices.Count; i++) |
| 298 | + { |
| 299 | + outPathDeletionResults[nonDeletedPathIndices[i]] = nonDeletedPathDeletionResults[i]; |
| 300 | + } |
| 301 | + } |
| 302 | + } |
| 303 | + |
246 | 304 | static MethodInfo[] isOpenForEditMethods = null;
|
247 | 305 | static MethodInfo[] GetIsOpenForEditMethods()
|
248 | 306 | {
|
|
0 commit comments