From cb91f66969af3508bcd6f2445ad12ea769ce31a4 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Mon, 4 Feb 2019 15:42:26 +0900 Subject: [PATCH] Skip AssetPostProcessor when file in StreamingAssets folder. #166 --- Assets/VRM/UniGLTF/Editor/gltfAssetPostprocessor.cs | 6 ++++++ Assets/VRM/UniGLTF/Scripts/IO/UnityPath.cs | 13 +++++++++++++ .../VRM/UniHumanoid/Editor/bvhAssetPostprocessor.cs | 13 +++++++++++++ .../UniVRM/Editor/Format/vrmAssetPostprocessor.cs | 7 +++++++ 4 files changed, 39 insertions(+) diff --git a/Assets/VRM/UniGLTF/Editor/gltfAssetPostprocessor.cs b/Assets/VRM/UniGLTF/Editor/gltfAssetPostprocessor.cs index 2ec3b0732f..9b23704ef4 100644 --- a/Assets/VRM/UniGLTF/Editor/gltfAssetPostprocessor.cs +++ b/Assets/VRM/UniGLTF/Editor/gltfAssetPostprocessor.cs @@ -15,6 +15,12 @@ static void OnPostprocessAllAssets(string[] importedAssets, { foreach (string path in importedAssets) { + if (UnityPath.FromUnityPath(path).IsStreamingAsset) + { + Debug.LogFormat("Skip StreamingAssets: {0}", path); + continue; + } + var ext = Path.GetExtension(path).ToLower(); switch (ext) { diff --git a/Assets/VRM/UniGLTF/Scripts/IO/UnityPath.cs b/Assets/VRM/UniGLTF/Scripts/IO/UnityPath.cs index 38975f7742..ed7be4fed4 100644 --- a/Assets/VRM/UniGLTF/Scripts/IO/UnityPath.cs +++ b/Assets/VRM/UniGLTF/Scripts/IO/UnityPath.cs @@ -44,6 +44,19 @@ public bool IsUnderAssetsFolder } } + public bool IsStreamingAsset + { + get + { + if (IsNull) + { + return false; + } + + return FullPath.StartsWith(Application.streamingAssetsPath + "/"); + } + } + public string FileNameWithoutExtension { get { return Path.GetFileNameWithoutExtension(Value); } diff --git a/Assets/VRM/UniHumanoid/Editor/bvhAssetPostprocessor.cs b/Assets/VRM/UniHumanoid/Editor/bvhAssetPostprocessor.cs index 17574bf029..4f08f26a60 100644 --- a/Assets/VRM/UniHumanoid/Editor/bvhAssetPostprocessor.cs +++ b/Assets/VRM/UniHumanoid/Editor/bvhAssetPostprocessor.cs @@ -8,10 +8,23 @@ namespace UniHumanoid { public class bvhAssetPostprocessor : AssetPostprocessor { + static bool IsStreamingAsset(string path) + { + var baseFullPath = Path.GetFullPath(Application.dataPath + "/..").Replace("\\", "/"); + path = Path.Combine(baseFullPath, path).Replace("\\", "/"); + return path.StartsWith(Application.streamingAssetsPath + "/"); + } + static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths) { foreach (string path in importedAssets) { + if (IsStreamingAsset(path)) + { + Debug.LogFormat("Skip StreamingAssets: {0}", path); + continue; + } + var ext = Path.GetExtension(path).ToLower(); if (ext == ".bvh") { diff --git a/Assets/VRM/UniVRM/Editor/Format/vrmAssetPostprocessor.cs b/Assets/VRM/UniVRM/Editor/Format/vrmAssetPostprocessor.cs index d7ed06e489..7f47ea5203 100644 --- a/Assets/VRM/UniVRM/Editor/Format/vrmAssetPostprocessor.cs +++ b/Assets/VRM/UniVRM/Editor/Format/vrmAssetPostprocessor.cs @@ -3,6 +3,7 @@ using System.Linq; using UniGLTF; using UnityEditor; +using UnityEngine; namespace VRM @@ -14,6 +15,12 @@ static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAsse { foreach (string path in importedAssets) { + if (UnityPath.FromUnityPath(path).IsStreamingAsset) + { + Debug.LogFormat("Skip StreamingAssets: {0}", path); + continue; + } + var ext = Path.GetExtension(path).ToLower(); if (ext == ".vrm") {