From 321a67c90ba5572819b5521355aa9525d63de69d Mon Sep 17 00:00:00 2001 From: soupday <79094830+soupday@users.noreply.github.com> Date: Tue, 16 Aug 2022 13:11:54 +0100 Subject: [PATCH] 1.3.7 Backported function to mid release 2020.3 and 2021.1 SaveAssetIfDirty removed. --- CHANGELOG.md | 4 ++++ Editor/AnimRetargetGUI.cs | 8 +++----- Editor/Pipeline.cs | 2 +- Editor/QuickAnimProcess.cs | 16 ++++++++++------ Editor/Util.cs | 8 ++++++++ Runtime/PhysicsSettingsStore.cs | 14 ++++++++++++-- package.json | 2 +- 7 files changed, 39 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 630c0ef..114016a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ Changelog ========= +### v 1.3.7 +- Backported function to mid release 2020.3 and 2021.1 SaveAssetIfDirty removed. +- GUIDFromAssetPath Unity 2019 fix for built-in pipeline. + ### v 1.3.6 - Runtime components Build fix. diff --git a/Editor/AnimRetargetGUI.cs b/Editor/AnimRetargetGUI.cs index 5736e7c..9a05d5e 100644 --- a/Editor/AnimRetargetGUI.cs +++ b/Editor/AnimRetargetGUI.cs @@ -57,9 +57,7 @@ public static class AnimRetargetGUI private static Vector3 animatorPosition; private static Quaternion animatorRotation; - - // Function variables - const string emptyGuid = "00000000000000000000000000000000"; + // Function variables public const string ANIM_FOLDER_NAME = "Animations"; public const string RETARGET_FOLDER_NAME = "Retargeted"; public const string RETARGET_SOURCE_PREFIX = "Imported"; @@ -1252,13 +1250,13 @@ static string GenerateClipAssetPath(AnimationClip originalClip, GameObject fbxAs if (!overwrite) { - if (!AssetDatabase.GUIDFromAssetPath(assetPath).ToString().Equals(emptyGuid)) + if (!Util.AssetPathIsEmpty(assetPath)) { for (int i = 0; i < 999; i++) { string extension = string.Format("{0:000}", i); assetPath = Path.Combine(animFolder, animName + "_" + extension + ".anim"); - if (AssetDatabase.GUIDFromAssetPath(assetPath).ToString().Equals(emptyGuid)) break; + if (Util.AssetPathIsEmpty(assetPath)) break; } } } diff --git a/Editor/Pipeline.cs b/Editor/Pipeline.cs index 1362096..c54d8f9 100644 --- a/Editor/Pipeline.cs +++ b/Editor/Pipeline.cs @@ -40,7 +40,7 @@ public enum MaterialQuality { None, Default, High, Baked } public static class Pipeline { - public const string VERSION = "1.3.6"; + public const string VERSION = "1.3.7"; #if HDRP_10_5_0_OR_NEWER // version diff --git a/Editor/QuickAnimProcess.cs b/Editor/QuickAnimProcess.cs index eaaddf9..b6b3fc3 100644 --- a/Editor/QuickAnimProcess.cs +++ b/Editor/QuickAnimProcess.cs @@ -88,7 +88,6 @@ public static bool ATValidateInitAssetProcessingForce() return IsModel(Selection.activeObject); } - private static string emptyGuid = "00000000000000000000000000000000"; private static string[] modelFileExtensions = new string[] { ".fbx", ".blend", ".dae", ".obj" }; public static bool IsModel(Object o) @@ -224,16 +223,14 @@ private static void WriteAnimationClip(Object o, AnimationClip animationClip) string animName = SanitizeName(o.name + " - " + animationClip.name); string fullOutputPath = workingDirectory + "/" + animName + ".anim"; - if (!AssetDatabase.GUIDFromAssetPath(fullOutputPath).ToString().Equals(emptyGuid)) + + if (AssetPathIsEmpty(fullOutputPath)) { for (int i = 0; i < 999; i++) { string extension = string.Format("{0:000}", i); fullOutputPath = workingDirectory + "/" + animName + "." + extension + ".anim"; - if (AssetDatabase.GUIDFromAssetPath(fullOutputPath).ToString().Equals(emptyGuid)) - { - break; - } + if (AssetPathIsEmpty(fullOutputPath)) break; } } Debug.Log("Writing Asset: " + fullOutputPath); @@ -247,4 +244,11 @@ private static string SanitizeName(string inputName) Regex r = new Regex(string.Format("[{0}]", Regex.Escape(invalid))); return r.Replace(inputName, " - "); } + + public static bool AssetPathIsEmpty(string assetPath) + { + const string emptyGuid = "00000000000000000000000000000000"; + + return AssetDatabase.AssetPathToGUID(assetPath).Equals(emptyGuid); + } } diff --git a/Editor/Util.cs b/Editor/Util.cs index 8f6b4bc..5f92c80 100644 --- a/Editor/Util.cs +++ b/Editor/Util.cs @@ -20,6 +20,7 @@ using System.Collections.Generic; using UnityEngine; using UnityEditor; +using Object = UnityEngine.Object; namespace Reallusion.Import { @@ -895,6 +896,13 @@ public static void FindSceneObjects(Transform root, string search, List= 2) diff --git a/Runtime/PhysicsSettingsStore.cs b/Runtime/PhysicsSettingsStore.cs index ba3f37a..3b98a0f 100644 --- a/Runtime/PhysicsSettingsStore.cs +++ b/Runtime/PhysicsSettingsStore.cs @@ -97,7 +97,11 @@ public static PhysicsSettingsStore SaveColliderSettings(ColliderManager collider { settings.colliderSettings = workingSettings; EditorUtility.SetDirty(settings); +#if UNITY_2021_2_OR_NEWER AssetDatabase.SaveAssetIfDirty(AssetDatabase.GUIDFromAssetPath(AssetDatabase.GetAssetPath(settings))); +#else + AssetDatabase.SaveAssets(); +#endif Debug.Log("Collider settings stored."); @@ -161,8 +165,14 @@ public static PhysicsSettingsStore SaveClothSettings(WeightMapper weightMapper) settings.clothSettings.Add(s); } } + EditorUtility.SetDirty(settings); +#if UNITY_2021_2_OR_NEWER AssetDatabase.SaveAssetIfDirty(AssetDatabase.GUIDFromAssetPath(AssetDatabase.GetAssetPath(settings))); +#else + AssetDatabase.SaveAssets(); +#endif + Debug.Log("Cloth physics settings stored."); @@ -252,7 +262,7 @@ private static bool TryGetSavedIndex(List savedClothSettings, P return true; return false; - } + } #endif - } + } } diff --git a/package.json b/package.json index b432200..ce69d63 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "com.soupday.cc3_unity_tools", - "version": "1.3.6", + "version": "1.3.7", "displayName": "CC/iC Unity Tools HDRP", "description": "Unity importer for Character Creator 3 & 4 and iClone 7 and 8.", "unity": "2020.3",