From 41b411a461b7223e8ef8429efcfd7b4647dc0dcb Mon Sep 17 00:00:00 2001 From: ousttrue Date: Thu, 20 May 2021 17:24:27 +0900 Subject: [PATCH] =?UTF-8?q?Default=20=E3=81=AE=20Asset=20=E3=82=92?= =?UTF-8?q?=E3=82=B5=E3=83=BC=E3=83=81=E3=81=97=E3=81=A6=E3=81=BE=E3=81=A8?= =?UTF-8?q?=E3=82=81=E3=81=A6=20Reimport=20=E3=82=92=E7=99=BA=E5=8B=95?= =?UTF-8?q?=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ScriptedImporter/GlbScriptedImporter.cs | 2 +- .../ScriptedImporter/GltfScriptedImporter.cs | 2 +- .../Editor/UniGLTF/UniGLTFPreference.cs | 34 +++++++++++++++++++ 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/Assets/UniGLTF/Editor/UniGLTF/ScriptedImporter/GlbScriptedImporter.cs b/Assets/UniGLTF/Editor/UniGLTF/ScriptedImporter/GlbScriptedImporter.cs index f76e12bd5..b733d413c 100644 --- a/Assets/UniGLTF/Editor/UniGLTF/ScriptedImporter/GlbScriptedImporter.cs +++ b/Assets/UniGLTF/Editor/UniGLTF/ScriptedImporter/GlbScriptedImporter.cs @@ -13,7 +13,7 @@ namespace UniGLTF public class GlbScriptedImporter : ScriptedImporter { [SerializeField] - ScriptedImporterAxes m_reverseAxis; + public ScriptedImporterAxes m_reverseAxis; public override void OnImportAsset(AssetImportContext ctx) { diff --git a/Assets/UniGLTF/Editor/UniGLTF/ScriptedImporter/GltfScriptedImporter.cs b/Assets/UniGLTF/Editor/UniGLTF/ScriptedImporter/GltfScriptedImporter.cs index 6a079cda2..0ed062141 100644 --- a/Assets/UniGLTF/Editor/UniGLTF/ScriptedImporter/GltfScriptedImporter.cs +++ b/Assets/UniGLTF/Editor/UniGLTF/ScriptedImporter/GltfScriptedImporter.cs @@ -13,7 +13,7 @@ namespace UniGLTF public class GltfScriptedImporter : ScriptedImporter { [SerializeField] - ScriptedImporterAxes m_reverseAxis = default; + public ScriptedImporterAxes m_reverseAxis = default; public override void OnImportAsset(AssetImportContext ctx) { diff --git a/Assets/UniGLTF/Editor/UniGLTF/UniGLTFPreference.cs b/Assets/UniGLTF/Editor/UniGLTF/UniGLTFPreference.cs index 65b0fd8db..514bb609d 100644 --- a/Assets/UniGLTF/Editor/UniGLTF/UniGLTFPreference.cs +++ b/Assets/UniGLTF/Editor/UniGLTF/UniGLTFPreference.cs @@ -2,11 +2,38 @@ using UnityEngine; using UnityEditor; using System.Linq; using System; +using System.IO; +using System.Collections.Generic; namespace UniGLTF { public static class UniGLTFPreference { + static IEnumerable GetReimportPaths() + { + String[] guids = AssetDatabase.FindAssets("t:GameObject", null); + foreach (var guid in guids) + { + var assetPath = AssetDatabase.GUIDToAssetPath(guid); + if (AssetImporter.GetAtPath(assetPath) is GlbScriptedImporter glb) + { + if (glb.m_reverseAxis == ScriptedImporterAxes.Default) + { + Debug.Log($"[reimport] {assetPath}"); + yield return assetPath; + } + } + else if (AssetImporter.GetAtPath(assetPath) is GltfScriptedImporter gltf) + { + if (gltf.m_reverseAxis == ScriptedImporterAxes.Default) + { + Debug.Log($"[reimport] {assetPath}"); + yield return assetPath; + } + } + } + } + [PreferenceItem("UniGLTF")] private static void OnPreferenceGUI() { @@ -20,7 +47,14 @@ namespace UniGLTF EditorGUILayout.HelpBox($"Default invert axis when glb/gltf import/export", MessageType.Info, true); if (EditorGUI.EndChangeCheck()) { + // global setting GltfIOAxis = gltfIOAxis; + + // apply assets + foreach (var path in GetReimportPaths().ToArray()) + { + AssetDatabase.ImportAsset(path, default); + } } }