public static AssetDeleteResult OnWillDeleteAsset(string assetPath, RemoveAssetOptions rao) { if (Path.GetExtension(assetPath.ToLower()) != ".abc") { return(AssetDeleteResult.DidNotDelete); } var streamingAssetPath = AlembicImporter.MakeShortAssetPath(assetPath); AlembicStream.DisconnectStreamsWithPath(streamingAssetPath); try { var fullStreamingAssetPath = Application.streamingAssetsPath + streamingAssetPath; File.SetAttributes(fullStreamingAssetPath, FileAttributes.Normal); File.Delete(fullStreamingAssetPath); File.SetAttributes(fullStreamingAssetPath + ".meta", FileAttributes.Normal); File.Delete(fullStreamingAssetPath + ".meta"); } catch (System.Exception e) { Debug.LogWarning(e); } return(AssetDeleteResult.DidNotDelete); }
public static AssetMoveResult OnWillMoveAsset(string from, string to) { if (Path.GetExtension(from.ToLower()) != ".abc") { return(AssetMoveResult.DidNotMove); } var streamDstPath = AlembicImporter.MakeShortAssetPath(to); var streamSrcPath = AlembicImporter.MakeShortAssetPath(from); AlembicStream.DisconnectStreamsWithPath(streamSrcPath); AlembicStream.RemapStreamsWithPath(streamSrcPath, streamDstPath); var dstPath = Application.streamingAssetsPath + streamDstPath; var srcPath = Application.streamingAssetsPath + streamSrcPath; try { var directoryPath = Path.GetDirectoryName(dstPath); if (File.Exists(dstPath)) { File.SetAttributes(dstPath + ".meta", FileAttributes.Normal); File.Delete(dstPath); } else if (!Directory.Exists(directoryPath)) { Directory.CreateDirectory(directoryPath); } if (File.Exists(dstPath)) { File.SetAttributes(dstPath, FileAttributes.Normal); } File.Move(srcPath, dstPath); if (File.Exists(dstPath + ".meta")) { File.SetAttributes(dstPath + ".meta", FileAttributes.Normal); File.Move(srcPath + ".meta", dstPath + ".meta"); } AssetDatabase.Refresh(ImportAssetOptions.Default); AlembicStream.ReconnectStreamsWithPath(streamDstPath); } catch (System.Exception e) { Debug.LogWarning(e); } return(AssetMoveResult.DidNotMove); }