From ae69797f0a52d9447efe02eb6330a557333b04eb Mon Sep 17 00:00:00 2001 From: soupday <79094830+soupday@users.noreply.github.com> Date: Mon, 31 Jul 2023 22:55:59 +0100 Subject: [PATCH 1/4] 1.5.2 remove rogue usings limit prefab init delete to 2023.1.1-5 --- Editor/Importer.cs | 2 +- Editor/MassProcessingWindow.cs | 2 -- Editor/Pipeline.cs | 2 +- Editor/RL.cs | 29 ++++++++++++------- .../com.soupday.cc3_unity_tools.editor.asmdef | 5 ++++ README.md | 10 +++---- package.json | 2 +- 7 files changed, 32 insertions(+), 20 deletions(-) diff --git a/Editor/Importer.cs b/Editor/Importer.cs index 27c70ba..deaed36 100644 --- a/Editor/Importer.cs +++ b/Editor/Importer.cs @@ -323,7 +323,7 @@ public GameObject Import(bool batchMode = false) // create prefab. string prefabAssetPath = RL.InitCharacterPrefab(characterInfo); - GameObject prefabInstance = RL.InstantiateModelFromSource(characterInfo, fbx); + GameObject prefabInstance = RL.InstantiateModelFromSource(characterInfo, fbx, prefabAssetPath); // setup 2 pass hair in the prefab. if (characterInfo.DualMaterialHair) diff --git a/Editor/MassProcessingWindow.cs b/Editor/MassProcessingWindow.cs index 7be66b7..4266e18 100644 --- a/Editor/MassProcessingWindow.cs +++ b/Editor/MassProcessingWindow.cs @@ -22,8 +22,6 @@ using System; using System.Linq; using System.IO; -using UnityEditor.PackageManager.UI; -using JetBrains.Annotations; namespace Reallusion.Import { diff --git a/Editor/Pipeline.cs b/Editor/Pipeline.cs index 599e05b..5cb459b 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.5.1"; + public const string VERSION = "1.5.2"; #if HDRP_10_5_0_OR_NEWER // version diff --git a/Editor/RL.cs b/Editor/RL.cs index a033718..a8f7e57 100644 --- a/Editor/RL.cs +++ b/Editor/RL.cs @@ -22,8 +22,6 @@ using System; using System.IO; using UnityEditor.Animations; -using Codice.Client.Common; -using System.Diagnostics.Eventing.Reader; namespace Reallusion.Import { @@ -649,27 +647,38 @@ public static string InitCharacterPrefab(CharacterInfo info) string prefabFolder = Util.CreateFolder(info.folder, Importer.PREFABS_FOLDER); string prefabPath = Path.Combine(prefabFolder, info.name + ".prefab"); - // Unity 2023.1 crashes if saving a new instance over an existing prefab, so delete it first +#if UNITY_2023_OR_NEWER + // Unity 2023.1.1 to 2023.1.5 crashes if saving a new instance over an existing prefab, so delete it first +#if UNITY_2023_1_6_OR_NEWER + // prefab bug fixed in 2023.1.6 +#else bool assetExists = Util.AssetPathExists(prefabPath); if (assetExists) { AssetDatabase.DeleteAsset(prefabPath); AssetDatabase.Refresh(); } +#endif +#endif return prefabPath; } - public static GameObject InstantiateModelFromSource(CharacterInfo info, GameObject fbx) - { + public static GameObject InstantiateModelFromSource(CharacterInfo info, GameObject fbx, string assetPath) + { + GameObject prefabInstance = null; + if (info.path.iContains("_lod") && CountLODs(fbx) > 1) { - return CreateLODInstanceFromModel(info, fbx); + prefabInstance = CreateLODInstanceFromModel(info, fbx); } else { - return CreateInstanceFromModel(info, fbx); + prefabInstance = CreateInstanceFromModel(info, fbx); } + + GameObject prefab = PrefabUtility.SaveAsPrefabAssetAndConnect(prefabInstance, assetPath, InteractionMode.AutomatedAction); + return prefabInstance; } /// @@ -769,10 +778,10 @@ public static GameObject CreateLODInstanceFromModel(CharacterInfo info, GameObje public static GameObject SaveAndRemovePrefabInstance(GameObject prefabInstance, string assetPath) { - GameObject prefab = PrefabUtility.SaveAsPrefabAssetAndConnect(prefabInstance, assetPath, - InteractionMode.AutomatedAction); + //GameObject prefab = PrefabUtility.SaveAsPrefabAsset(prefabInstance, assetPath); + PrefabUtility.ApplyPrefabInstance(prefabInstance, InteractionMode.AutomatedAction); UnityEngine.Object.DestroyImmediate(prefabInstance); - return prefab; + return AssetDatabase.LoadAssetAtPath(assetPath); } public static int CountLODs(GameObject fbx) diff --git a/Editor/com.soupday.cc3_unity_tools.editor.asmdef b/Editor/com.soupday.cc3_unity_tools.editor.asmdef index 02c0d8a..2f135d5 100644 --- a/Editor/com.soupday.cc3_unity_tools.editor.asmdef +++ b/Editor/com.soupday.cc3_unity_tools.editor.asmdef @@ -104,6 +104,11 @@ "name": "Unity", "expression": "2023", "define": "UNITY_2023_OR_NEWER" + }, + { + "name": "Unity", + "expression": "2023.1.6", + "define": "UNITY_2023_1_6_OR_NEWER" } ], "noEngineReferences": false diff --git a/README.md b/README.md index 39390a2..6841a75 100644 --- a/README.md +++ b/README.md @@ -17,23 +17,23 @@ Links [HDRP Version](https://github.com/soupday/cc_unity_tools_HDRP) Note: There are two verions of the HDRP package -- [**CC Unity Tools HDRP10**](https://github.com/soupday/cc_unity_tools_HDRP/releases/tag/1.5.1.HDRP10) for Unity 2020.3 to 2021.1 -- [**CC Unity Tools HDRP12**](https://github.com/soupday/cc_unity_tools_HDRP/releases/tag/1.5.1.HDRP12) for Unity 2021.2 and upwards +- [**CC Unity Tools HDRP10**](https://github.com/soupday/cc_unity_tools_HDRP/releases/tag/1.5.2.HDRP10) for Unity 2020.3 to 2021.1 +- [**CC Unity Tools HDRP12**](https://github.com/soupday/cc_unity_tools_HDRP/releases/tag/1.5.2.HDRP12) for Unity 2021.2 and upwards The main repository contains the HDRP10 version. See the releases page for the HDRP12 version. [URP Version](https://github.com/soupday/cc_unity_tools_URP) Note: There are two verions of the URP package -- [**CC Unity Tools URP10**](https://github.com/soupday/cc_unity_tools_URP/releases/tag/1.5.1.URP10) for Unity 2020.3 to 2021.1 -- [**CC Unity Tools URP12**](https://github.com/soupday/cc_unity_tools_URP/releases/tag/1.5.1.URP12) for Unity 2021.2 and upwards +- [**CC Unity Tools URP10**](https://github.com/soupday/cc_unity_tools_URP/releases/tag/1.5.2.URP10) for Unity 2020.3 to 2021.1 +- [**CC Unity Tools URP12**](https://github.com/soupday/cc_unity_tools_URP/releases/tag/1.5.2.URP12) for Unity 2021.2 and upwards The main repository contains the URP10 version. See the releases page for the URP12 version. [3D/Built-in Version](https://github.com/soupday/cc_unity_tools_3D) The built-in pipeline version is for Unity 2019.4 and upwards. -- [**CC Unity Tools 3D**](https://github.com/soupday/cc_unity_tools_3D/releases/tag/1.5.1) for Unity 2019.4 and upwards +- [**CC Unity Tools 3D**](https://github.com/soupday/cc_unity_tools_3D/releases/tag/1.5.2) for Unity 2019.4 and upwards How it works ============ diff --git a/package.json b/package.json index 2e11501..ab1a43e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "com.soupday.cc3_unity_tools", - "version": "1.5.1", + "version": "1.5.2", "displayName": "CC/iC Unity Tools HDRP", "description": "Unity importer for Character Creator 3 & 4 and iClone 7 and 8.", "unity": "2020.3", From 8b53750080651bef53006d5b9a7b5ecc4a9cb9e2 Mon Sep 17 00:00:00 2001 From: soupday <79094830+soupday@users.noreply.github.com> Date: Tue, 1 Aug 2023 13:43:29 +0100 Subject: [PATCH 2/4] 1.5.2 Reset FBX animator on build and animation processing --- Editor/AnimPlayerGUI.cs | 30 ++++++++++++++---------------- Editor/AnimPlayerOverlay.cs | 1 - Editor/AnimPlayerWindow.cs | 8 +++----- Editor/ImporterWindow.cs | 2 +- Editor/Lodify.cs | 2 +- Editor/RL.cs | 23 +++++++++++++++++++---- Editor/WindowManager.cs | 23 +++++------------------ 7 files changed, 43 insertions(+), 46 deletions(-) diff --git a/Editor/AnimPlayerGUI.cs b/Editor/AnimPlayerGUI.cs index 8d020a8..b748e6b 100644 --- a/Editor/AnimPlayerGUI.cs +++ b/Editor/AnimPlayerGUI.cs @@ -123,9 +123,7 @@ public static bool IsPlayerShown() public static void SetCharacter(GameObject scenePrefab) { if (scenePrefab) - Debug.Log("scenePrefab.name: " + scenePrefab.name + " " + PrefabUtility.IsPartOfPrefabInstance(scenePrefab)); - - + Util.LogInfo("scenePrefab.name: " + scenePrefab.name + " " + PrefabUtility.IsPartOfPrefabInstance(scenePrefab)); if (!scenePrefab && WindowManager.IsPreviewScene) scenePrefab = WindowManager.GetPreviewScene().GetPreviewCharacter(); @@ -338,7 +336,7 @@ private static AnimatorController CreateAnimatiorController() { controllerPath = dirString + controllerName + ".controller"; - if (showMessages) Debug.Log("Creating Temporary file " + controllerPath); + Util.LogInfo("Creating Temporary file " + controllerPath); AnimatorController a = AnimatorController.CreateAnimatorControllerAtPath(controllerPath); a.name = controllerName; // play mode parameters @@ -388,7 +386,7 @@ private static void SelectOverrideAnimation(AnimationClip clip, AnimatorOverride foreach (var v in overrides) { - if (showMessages) Debug.Log("Overrides: " + " Key: " + v.Key + " Value: " + v.Value); + Util.LogInfo("Overrides: " + " Key: " + v.Key + " Value: " + v.Value); } overrides[0] = new KeyValuePair(overrides[0].Key, WorkingClip); @@ -439,7 +437,7 @@ public static void ResetToBaseAnimatorController() if (!characterPrefab) return; - Debug.Log(("Attempting to reset: " + characterPrefab.name)); + Util.LogInfo(("Attempting to reset: " + characterPrefab.name)); GameObject basePrefab = PrefabUtility.GetCorrespondingObjectFromSource(characterPrefab); @@ -448,36 +446,36 @@ public static void ResetToBaseAnimatorController() if (true) //(PrefabUtility.IsAnyPrefabInstanceRoot(basePrefab)) { string prefabPath = AssetDatabase.GetAssetPath(basePrefab); - Debug.Log((basePrefab.name + "Prefab instance root found: " + prefabPath)); + Util.LogInfo((basePrefab.name + "Prefab instance root found: " + prefabPath)); - Debug.Log("Loaded Prefab: " + basePrefab.name); + Util.LogInfo("Loaded Prefab: " + basePrefab.name); Animator baseAnimator = basePrefab.GetComponent(); if (!baseAnimator) baseAnimator = basePrefab.GetComponentInChildren(); if (baseAnimator != null) { - Debug.Log("Prefab Animator: " + baseAnimator.name); + Util.LogInfo("Prefab Animator: " + baseAnimator.name); if (baseAnimator.runtimeAnimatorController) { - Debug.Log("Prefab Animator Controller: " + baseAnimator.runtimeAnimatorController.name); + Util.LogInfo("Prefab Animator Controller: " + baseAnimator.runtimeAnimatorController.name); string controllerpath = AssetDatabase.GetAssetPath(baseAnimator.runtimeAnimatorController); - Debug.Log("Prefab Animator Controller Path: " + controllerpath); + Util.LogInfo("Prefab Animator Controller Path: " + controllerpath); AnimatorController baseController = AssetDatabase.LoadAssetAtPath(controllerpath); if (CharacterAnimator.runtimeAnimatorController != null) { // ensure the created override controller is the one on the animator // to avoid wiping user generated controller (it will have to be a disk asset - but nevertheless) - Debug.Log("Current controller on character: " + CharacterAnimator.runtimeAnimatorController.name); + Util.LogInfo("Current controller on character: " + CharacterAnimator.runtimeAnimatorController.name); if (CharacterAnimator.runtimeAnimatorController.GetType() == typeof(AnimatorOverrideController) && CharacterAnimator.runtimeAnimatorController.name == overrideName) { - Debug.Log("Created override controller found: can reset"); + Util.LogInfo("Created override controller found: can reset"); CharacterAnimator.runtimeAnimatorController = baseController; } } } else { - Debug.Log("NO Prefab Animator Controller"); + Util.LogInfo("NO Prefab Animator Controller"); CharacterAnimator.runtimeAnimatorController = null; } } @@ -495,7 +493,7 @@ private static void DestroyAnimationController() { //if (showMessages) - Debug.Log("Override controller: " + controllerPath + " exists -- removing"); + Util.LogInfo("Override controller: " + controllerPath + " exists -- removing"); AssetDatabase.DeleteAsset(controllerPath); } } @@ -1167,7 +1165,7 @@ public static void ResetCharacterPose() } if (!canFindAvatar) { - if (showMessages) Debug.LogWarning("No Avatar found to reset pose to."); + Util.LogWarn("No Avatar found to reset pose to."); return; } diff --git a/Editor/AnimPlayerOverlay.cs b/Editor/AnimPlayerOverlay.cs index 2134b3c..1165e23 100644 --- a/Editor/AnimPlayerOverlay.cs +++ b/Editor/AnimPlayerOverlay.cs @@ -97,7 +97,6 @@ public override void OnWillBeDestroyed() Hide(); createdOverlays.Remove(this); } - Debug.Log("OnWillBeDestroyed"); base.OnWillBeDestroyed(); } diff --git a/Editor/AnimPlayerWindow.cs b/Editor/AnimPlayerWindow.cs index 68a7e8d..cc0246a 100644 --- a/Editor/AnimPlayerWindow.cs +++ b/Editor/AnimPlayerWindow.cs @@ -68,8 +68,7 @@ public static void OnSceneGUI(SceneView sceneView) public static void ShowPlayer() { if (!isShown) - { - Debug.Log("WINDOW: SHOWING PLAYER"); + { SceneView.duringSceneGui -= AnimPlayerWindow.OnSceneGUI; SceneView.duringSceneGui += AnimPlayerWindow.OnSceneGUI; isShown = true; @@ -80,8 +79,7 @@ public static void ShowPlayer() public static void HidePlayer() { if (isShown) - { - Debug.Log("WINDOW: HIDING PLAYER"); + { SceneView.duringSceneGui -= AnimPlayerWindow.OnSceneGUI; AnimPlayerGUI.CleanUp(); @@ -97,7 +95,7 @@ public static void DoWindow(int id) public static void Empty(int id) { - Debug.Log("Showing " + id); + Util.LogInfo("Showing " + id); } } } diff --git a/Editor/ImporterWindow.cs b/Editor/ImporterWindow.cs index 85c1885..df26025 100644 --- a/Editor/ImporterWindow.cs +++ b/Editor/ImporterWindow.cs @@ -815,7 +815,7 @@ private void OnGUIActionArea(Rect actionBlock) if (GUILayout.Button(new GUIContent(iconActionAnims, "Process, extract and rename character animations and create a default animtor controller."), GUILayout.Width(ACTION_BUTTON_SIZE), GUILayout.Height(ACTION_BUTTON_SIZE))) { - RL.DoAnimationImport(contextCharacter, contextCharacter.Fbx); + RL.DoAnimationImport(contextCharacter); AnimRetargetGUI.GenerateCharacterTargetedAnimations(contextCharacter.path, contextCharacter.Fbx, true); List motionGuids = contextCharacter.GetMotionGuids(); if (motionGuids.Count > 0) diff --git a/Editor/Lodify.cs b/Editor/Lodify.cs index 02b5845..c0948c1 100644 --- a/Editor/Lodify.cs +++ b/Editor/Lodify.cs @@ -112,7 +112,7 @@ private void AddLODObject(GameObject lodObj, GameObject boneRootSearch = null) { if (lodObject.polyCount == lodObjects[i].polyCount) { - Debug.LogWarning("LOD level with same poly count detected: skipping " + lodObj.name); + Util.LogWarn("LOD level with same poly count detected: skipping " + lodObj.name); return; } if (lodObject.polyCount > lodObjects[i].polyCount) diff --git a/Editor/RL.cs b/Editor/RL.cs index a8f7e57..6188b2c 100644 --- a/Editor/RL.cs +++ b/Editor/RL.cs @@ -584,13 +584,25 @@ public static void SetupAnimation(ModelImporter importer, CharacterInfo characte characterInfo.animationSetup = true; } - public static void DoAnimationImport(CharacterInfo info, GameObject fbx) + public static void ResetFbxAnimator(GameObject fbx) + { + Animator animator = fbx.GetComponentInChildren(); + if (animator) + { + if (animator.runtimeAnimatorController != null) + { + animator.runtimeAnimatorController = null; + } + } + } + + public static void DoAnimationImport(CharacterInfo info) { string path = info.path; + ResetFbxAnimator(info.Fbx); ModelImporter importer = (ModelImporter)AssetImporter.GetAtPath(path); - HumanoidImportSettings(fbx, importer, info); + HumanoidImportSettings(info.Fbx, importer, info); SetupAnimation(importer, info, true); - AddDefaultAnimatorController(info, fbx); Avatar sourceAvatar = info.GetCharacterAvatar(); @@ -659,7 +671,10 @@ public static string InitCharacterPrefab(CharacterInfo info) AssetDatabase.Refresh(); } #endif -#endif +#endif + + // remove any animator controllers set in the fbx + ResetFbxAnimator(info.Fbx); return prefabPath; } diff --git a/Editor/WindowManager.cs b/Editor/WindowManager.cs index 8def4a3..5205443 100644 --- a/Editor/WindowManager.cs +++ b/Editor/WindowManager.cs @@ -85,15 +85,10 @@ public static void OnPlayModeStateChanged(PlayModeStateChange state) { case PlayModeStateChange.ExitingEditMode: { - Debug.Log(state); - - break; } case PlayModeStateChange.EnteredPlayMode: { - Debug.Log(state); - showPlayerAfterPlayMode = showPlayer; showRetargetAfterPlayMode = showRetarget; showPlayer = false; @@ -105,7 +100,6 @@ public static void OnPlayModeStateChanged(PlayModeStateChange state) { if (val) { - Debug.Log("Reverting Scene Focus"); //GrabLastSceneFocus(); Util.SerializeBoolToEditorPrefs(false, WindowManager.sceneFocus); ShowAnimationPlayer(); @@ -147,7 +141,6 @@ public static void OnPlayModeStateChanged(PlayModeStateChange state) } case PlayModeStateChange.EnteredEditMode: { - Debug.Log(state); showPlayer = showPlayerAfterPlayMode; showRetarget = showRetargetAfterPlayMode; @@ -156,8 +149,7 @@ public static void OnPlayModeStateChanged(PlayModeStateChange state) } /* if (state == PlayModeStateChange.EnteredPlayMode) - { - Debug.Log(state); + { showPlayerAfterPlayMode = showPlayer; showRetargetAfterPlayMode = showRetarget; showPlayer = false; @@ -166,8 +158,7 @@ public static void OnPlayModeStateChanged(PlayModeStateChange state) AnimRetargetGUI.CloseRetargeter(); /* - // original - Debug.Log(state); + // original showPlayerAfterPlayMode = showPlayer; showRetargetAfterPlayMode = showRetarget; showPlayer = false; @@ -179,8 +170,7 @@ public static void OnPlayModeStateChanged(PlayModeStateChange state) if (Util.TryDeSerializeBoolFromEditorPrefs(out bool val, WindowManager.sceneFocus)) { if (val) - { - Debug.Log("Reverting Scene Focus"); + { SceneView.lastActiveSceneView.Focus(); Util.SerializeBoolToEditorPrefs(false, WindowManager.sceneFocus); ShowAnimationPlayer(); @@ -205,8 +195,7 @@ public static void OnPlayModeStateChanged(PlayModeStateChange state) } } else if (state == PlayModeStateChange.EnteredEditMode) - { - Debug.Log(state); + { showPlayer = showPlayerAfterPlayMode; showRetarget = showRetargetAfterPlayMode; } @@ -459,8 +448,6 @@ public static GameObject GetSelectedOrPreviewCharacter() string s = AssetDatabase.GetAssetPath(Selection.activeObject); if (string.IsNullOrEmpty(s)) { - Debug.Log("SELECTED PATH: IsNullOrEmpty"); - GameObject selectedPrefab = Util.GetScenePrefabInstanceRoot(Selection.activeGameObject); if (selectedPrefab && selectedPrefab.GetComponent()) { @@ -507,7 +494,7 @@ public static void ShowAnimationPlayer() } else { - Debug.LogWarning("No compatible animated character!"); + Util.LogWarn("No compatible animated character!"); } } From 3900ef3a2c6e77f65b1b42d4455b3d4e1d2ec866 Mon Sep 17 00:00:00 2001 From: soupday <79094830+soupday@users.noreply.github.com> Date: Tue, 1 Aug 2023 15:27:01 +0100 Subject: [PATCH 3/4] 1.5.2 update existing clip reference in anim retarget. --- Editor/AnimRetargetGUI.cs | 21 +++++++++++++---- Editor/Importer.cs | 6 ++--- Editor/ImporterWindow.cs | 48 +++++++++++++++++++++++++++------------ 3 files changed, 53 insertions(+), 22 deletions(-) diff --git a/Editor/AnimRetargetGUI.cs b/Editor/AnimRetargetGUI.cs index fee8b00..6797565 100644 --- a/Editor/AnimRetargetGUI.cs +++ b/Editor/AnimRetargetGUI.cs @@ -445,7 +445,7 @@ public static void DrawRetargeter() // Lower close, reset and save controls GUILayout.BeginHorizontal(); GUILayout.BeginVertical("box"); // close button - if (GUILayout.Button(new GUIContent(EditorGUIUtility.IconContent("d_winbtn_win_close_a@2x").image, "Close this window."), GUILayout.Width(smallIconDim), GUILayout.Height(smallIconDim))) + if (GUILayout.Button(new GUIContent(EditorGUIUtility.IconContent("d_clear").image, "Close this window."), GUILayout.Width(smallIconDim), GUILayout.Height(smallIconDim))) { CloseRetargeter(); } @@ -1316,11 +1316,24 @@ static AnimationClip WriteAnimationToAssetDatabase(AnimationClip workingClip, st // player/re-tartgeter will be untouched so end users dont see a behaviour change after saving // **End of addition** + } + + AnimationClip asset = AssetDatabase.LoadAssetAtPath(assetPath); + if (asset == null) + { + // New + Util.LogInfo("Writing New Asset: " + assetPath); + AssetDatabase.CreateAsset(outputClip, assetPath); + } + else + { + Util.LogInfo("Updating Existing Asset: " + assetPath); + outputClip.name = asset.name; + EditorUtility.CopySerialized(outputClip, asset); + AssetDatabase.SaveAssets(); } - AssetDatabase.CreateAsset(outputClip, assetPath); - - AnimationClip asset = AssetDatabase.LoadAssetAtPath(assetPath); + asset = AssetDatabase.LoadAssetAtPath(assetPath); Selection.objects = new Object[] { asset }; return asset; } diff --git a/Editor/Importer.cs b/Editor/Importer.cs index deaed36..3799f87 100644 --- a/Editor/Importer.cs +++ b/Editor/Importer.cs @@ -356,8 +356,7 @@ public GameObject Import(bool batchMode = false) int animationRetargeted = characterInfo.DualMaterialHair ? 2 : 1; bool replace = characterInfo.animationRetargeted != animationRetargeted; if (replace) Util.LogInfo("Retargeting all imported animations."); - AnimRetargetGUI.GenerateCharacterTargetedAnimations(fbxPath, prefabInstance, replace); - characterInfo.animationRetargeted = animationRetargeted; + AnimRetargetGUI.GenerateCharacterTargetedAnimations(fbxPath, prefabInstance, replace); // create default animator if there isn't one: // commenting out due to a unity bug in 2022+, @@ -378,6 +377,8 @@ public GameObject Import(bool batchMode = false) } } + characterInfo.animationRetargeted = animationRetargeted; + // save final prefab instance and remove from scene GameObject prefabAsset = RL.SaveAndRemovePrefabInstance(prefabInstance, prefabAssetPath); @@ -2664,7 +2665,6 @@ public void ProcessMotionFbx(string guid, Avatar sourceAvatar, GameObject target bool replace = characterInfo.animationRetargeted != animationRetargeted; if (replace) Util.LogInfo("Retargeting all imported animations: " + motionAssetPath); AnimRetargetGUI.GenerateCharacterTargetedAnimations(motionAssetPath, targetCharacterModel, replace); - characterInfo.animationRetargeted = animationRetargeted; } } } diff --git a/Editor/ImporterWindow.cs b/Editor/ImporterWindow.cs index df26025..c0fb01a 100644 --- a/Editor/ImporterWindow.cs +++ b/Editor/ImporterWindow.cs @@ -58,6 +58,7 @@ public enum Mode { none, single, multi } private bool buildAfterGUI; private bool bakeAfterGUI; private bool bakeHairAfterGUI; + private bool processAnimationsAfterGUI; private bool restoreHairAfterGUI; private bool physicsAfterGUI; public enum ImporterWindowMode { Build, Bake, Settings } @@ -459,6 +460,7 @@ private void OnGUI() bakeHairAfterGUI = false; restoreHairAfterGUI = false; physicsAfterGUI = false; + processAnimationsAfterGUI = false; CheckDragAndDrop(); @@ -511,6 +513,10 @@ private void OnGUI() { EditorApplication.delayCall += RebuildCharacterPhysics; } + else if (processAnimationsAfterGUI) + { + EditorApplication.delayCall += ProcessAnimations; + } } bool doubleClick = false; @@ -815,21 +821,7 @@ private void OnGUIActionArea(Rect actionBlock) if (GUILayout.Button(new GUIContent(iconActionAnims, "Process, extract and rename character animations and create a default animtor controller."), GUILayout.Width(ACTION_BUTTON_SIZE), GUILayout.Height(ACTION_BUTTON_SIZE))) { - RL.DoAnimationImport(contextCharacter); - AnimRetargetGUI.GenerateCharacterTargetedAnimations(contextCharacter.path, contextCharacter.Fbx, true); - List motionGuids = contextCharacter.GetMotionGuids(); - if (motionGuids.Count > 0) - { - Avatar sourceAvatar = contextCharacter.GetCharacterAvatar(); - foreach (string motionGuid in motionGuids) - { - string motionPath = AssetDatabase.GUIDToAssetPath(motionGuid); - AnimRetargetGUI.GenerateCharacterTargetedAnimations(motionPath, contextCharacter.Fbx, true); - } - } - int animationRetargeted = contextCharacter.DualMaterialHair ? 2 : 1; - contextCharacter.animationRetargeted = animationRetargeted; - contextCharacter.Write(); + processAnimationsAfterGUI = true; } EditorGUI.EndDisabledGroup(); // @@ -1407,6 +1399,32 @@ void RebuildCharacterPhysics() Repaint(); } + void ProcessAnimations() + { + RL.DoAnimationImport(contextCharacter); + GameObject characterPrefab = Util.FindCharacterPrefabAsset(contextCharacter.Fbx); + if (characterPrefab == null) + { + Util.LogWarn("Could not find character prefab for retargeting, using FBX instead."); + characterPrefab = contextCharacter.Fbx; + } + + AnimRetargetGUI.GenerateCharacterTargetedAnimations(contextCharacter.path, characterPrefab, true); + List motionGuids = contextCharacter.GetMotionGuids(); + if (motionGuids.Count > 0) + { + //Avatar sourceAvatar = contextCharacter.GetCharacterAvatar(); + foreach (string motionGuid in motionGuids) + { + string motionPath = AssetDatabase.GUIDToAssetPath(motionGuid); + AnimRetargetGUI.GenerateCharacterTargetedAnimations(motionPath, characterPrefab, true); + } + } + int animationRetargeted = contextCharacter.DualMaterialHair ? 2 : 1; + contextCharacter.animationRetargeted = animationRetargeted; + contextCharacter.Write(); + } + public static void ResetAllSceneViewCamera(GameObject targetOverride = null) { if (WindowManager.IsPreviewScene) From b0c954459e2c0da67962c8afe1fd22e97ad346f7 Mon Sep 17 00:00:00 2001 From: soupday <79094830+soupday@users.noreply.github.com> Date: Thu, 3 Aug 2023 00:26:16 +0100 Subject: [PATCH 4/4] 1.5.2 Changelog HDRP --- CHANGELOG.md | 12 ++ Editor/AnimPlayerGUI.cs | 332 +++++++------------------------- Editor/AnimPlayerOverlay.cs | 51 ++--- Editor/AnimRetargetGUI.cs | 149 +++++++++----- Editor/AnimRetargetOverlay.cs | 26 ++- Editor/ColliderManagerEditor.cs | 1 - Editor/ImporterMenu.cs | 1 - Editor/ImporterWindow.cs | 9 - Editor/Lodify.cs | 1 - Editor/MeshUtil.cs | 6 +- Editor/Physics.cs | 4 - Editor/Pipeline.cs | 1 - Editor/Util.cs | 3 +- Editor/WeightMapperEditor.cs | 5 - Editor/WindowManager.cs | 81 +------- 15 files changed, 231 insertions(+), 451 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b18d20..03c05a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,18 @@ Changelog ========= +### 1.5.2 +- Animation Retargeter fixes. + - AnimationMode removed. + - Clip generation file name suffix corrected. + - Animation Clip overwrite no longer breaks references in Unity 2023.1. + - Clip settings (foot IK, mirror, speed) reset to defaults on opening retarget window. +- Character prefab generation no longer breaks references. (Except 2023.1.1-5 due to Unity bugs) +- Rogue usings removed from code. +- Animation processing fixes. + - Correct character prefab used to retarget _motion.fbx files. + - Animation Clip overwrite no longer breaks references in Unity 2023.1. + ### 1.5.1 - Character Build no longer creates and adds a default animation controller due to bugs in Unity 2022/2023 causing memory leaks when applying animation controllers to prefabs. - Instalod and other renamed object/material name matching improvements. diff --git a/Editor/AnimPlayerGUI.cs b/Editor/AnimPlayerGUI.cs index b748e6b..c0cba55 100644 --- a/Editor/AnimPlayerGUI.cs +++ b/Editor/AnimPlayerGUI.cs @@ -84,8 +84,6 @@ public static void ClosePlayer() EditorApplication.update -= UpdateCallback; EditorApplication.playModeStateChanged -= PlayStateChangeCallback; - WindowManager.StopAnimationMode(); - if (CharacterAnimator) { GameObject scenePrefab = Util.GetScenePrefabInstanceRoot(CharacterAnimator.gameObject); @@ -162,16 +160,12 @@ static public void UpdateAnimatorClip(Animator animator, AnimationClip clip) { if (doneInitFace) ResetFace(true, true); - // stop animation mode - WindowManager.StopAnimationMode(); - if (!animator || CharacterAnimator != animator) doneInitFace = false; - CharacterAnimator = animator; + CharacterAnimator = animator; OriginalClip = clip; SetupCharacterAndAnimation(); - //WorkingClip = CloneClip(OriginalClip); AnimRetargetGUI.RebuildClip(); @@ -186,47 +180,6 @@ static public void UpdateAnimatorClip(Animator animator, AnimationClip clip) // finally, apply the face ApplyFace(); - - if (WorkingClip && CharacterAnimator) - { - // also restarts animation mode - //SampleOnce(); - } - - /* Original Code: - - if (doneInitFace) ResetFace(true, true); - - // stop animation mode - WindowManager.StopAnimationMode(); - - if (!animator || CharacterAnimator != animator) doneInitFace = false; - - CharacterAnimator = animator; - OriginalClip = clip; - WorkingClip = CloneClip(OriginalClip); - - AnimRetargetGUI.RebuildClip(); - - MeshFacialProfile = FacialProfileMapper.GetMeshFacialProfile(animator ? animator.gameObject : null); - ClipFacialProfile = FacialProfileMapper.GetAnimationClipFacialProfile(clip); - - time = 0f; - play = false; - - // intitialise the face refs if needed - if (!doneInitFace) InitFace(); - - // finally, apply the face - //ApplyFace(); - - if (WorkingClip && CharacterAnimator) - { - // also restarts animation mode - SampleOnce(); - } - - */ } #region Animator Setup @@ -270,7 +223,7 @@ enum AnimatorFlags // Animaton Override Controller [SerializeField] - private static AnimatorOverrideController animatorOverrideController; + public static AnimatorOverrideController animatorOverrideController; // Playback @@ -327,9 +280,6 @@ public static void SetupCharacterAndAnimation() // reset the animation player ResetAnimationPlayer(); - - - } private static AnimatorController CreateAnimatiorController() @@ -363,7 +313,7 @@ private static AnimatorOverrideController CreateAnimatorOverrideController() private static void ApplyDefaultSettings() { flagSettings = AnimatorFlags.AutoLoopPlayback; - FootIK = true; + SetFootIK(true); CharacterAnimator.SetFloat(paramDirection, 0f); if (CharacterAnimator != null) { @@ -371,6 +321,43 @@ private static void ApplyDefaultSettings() } } + // Important IK enable/disable function used by the retargeter + // (or you can't see the effects of changing the heel curves) + public static void SetFootIK(bool enable) + { + FootIK = enable; + + if (playbackAnimatorController) + { + AnimatorControllerLayer[] allLayer = playbackAnimatorController.layers; + for (int i = 0; i < allLayer.Length; i++) + { + ChildAnimatorState[] states = allLayer[i].stateMachine.states; + for (int j = 0; j < states.Length; j++) + { + if (states[j].state.nameHash == controlStateHash) + { + states[j].state.iKOnFeet = FootIK; + allLayer[i].iKPass = FootIK; + } + } + } + + if (EditorApplication.isPlaying) CharacterAnimator.gameObject.SetActive(false); + playbackAnimatorController.layers = allLayer; + if (EditorApplication.isPlaying) CharacterAnimator.gameObject.SetActive(true); + } + } + + // called by the retargetter to revert all settings to default + public static void ForceSettingsReset() + { + ApplyDefaultSettings(); + SetFootIK(false); + SetClipSettings(WorkingClip); + FirstFrameButton(); + } + private static void SelectOverrideAnimation(AnimationClip clip, AnimatorOverrideController aoc) { ResetAnimationPlayer(); @@ -394,6 +381,22 @@ private static void SelectOverrideAnimation(AnimationClip clip, AnimatorOverride FirstFrameButton(); } + public static void SelectOverrideAnimationWithoutReset(AnimationClip clip, AnimatorOverrideController aoc) + { + WorkingClip = clip; + + List> overrides = new List>(aoc.overridesCount); + aoc.GetOverrides(overrides); + + foreach (var v in overrides) + { + Util.LogInfo("Overrides: " + " Key: " + v.Key + " Value: " + v.Value); + } + + overrides[0] = new KeyValuePair(overrides[0].Key, WorkingClip); + aoc.ApplyOverrides(overrides); + } + private static void ResetAnimationPlayer() { play = false; @@ -424,7 +427,6 @@ private static void SetClipSettings(AnimationClip clip) CharacterAnimator.applyRootMotion = !flagSettings.HasFlag(AnimatorFlags.AnimateOnTheSpot); } - public static void ResetToBaseAnimatorController() { // look up the original prefab corresponding to the model in the preview scene @@ -524,105 +526,6 @@ public static AnimationClip CloneClip(AnimationClip clip) } #region IMGUI - /* //Original DrawPlayer() method - public static void ORIGINALDrawPlayer() - { - GUILayout.BeginVertical(); - EditorGUI.BeginChangeCheck(); - AnimFoldOut = EditorGUILayout.Foldout(AnimFoldOut, "Animation Playback", EditorStyles.foldout); - if (EditorGUI.EndChangeCheck()) - { - //if (foldOut && FacialMorphIMGUI.FoldOut) - // FacialMorphIMGUI.FoldOut = false; - doOnceCatchMouse = true; - } - if (AnimFoldOut) - { - EditorGUI.BeginChangeCheck(); - Animator selectedAnimator = (Animator)EditorGUILayout.ObjectField(new GUIContent("Scene Model", "Animated model in scene"), CharacterAnimator, typeof(Animator), true); - AnimationClip selectedClip = (AnimationClip)EditorGUILayout.ObjectField(new GUIContent("Animation", "Animation to play and manipulate"), OriginalClip, typeof(AnimationClip), false); - if (EditorGUI.EndChangeCheck()) - { - UpdateAnimatorClip(selectedAnimator, selectedClip); - } - - GUI.enabled = WorkingClip && CharacterAnimator; - - EditorGUI.BeginDisabledGroup(!AnimationMode.InAnimationMode()); - - if (WorkingClip != null) - { - float startTime = 0.0f; - float stopTime = WorkingClip.length; - EditorGUI.BeginChangeCheck(); - time = EditorGUILayout.Slider(time, startTime, stopTime); - if (EditorGUI.EndChangeCheck()) - { - ResetFace(); - } - } - else - { - float value = 0f; - value = EditorGUILayout.Slider(value, 0f, 1f); //disabled dummy entry - } - - GUILayout.BeginHorizontal(EditorStyles.toolbar); - // "Animation.FirstKey" - if (GUILayout.Button(new GUIContent(EditorGUIUtility.IconContent("Animation.FirstKey").image, "First Frame"), EditorStyles.toolbarButton)) - { - play = false; - time = 0f; - ResetFace(); - } - // "Animation.PrevKey" - if (GUILayout.Button(new GUIContent(EditorGUIUtility.IconContent("Animation.PrevKey").image, "Previous Frame"), EditorStyles.toolbarButton)) - { - play = false; - time -= 0.0166f; - ResetFace(); - } - // "Animation.Play" - EditorGUI.BeginChangeCheck(); - play = GUILayout.Toggle(play, new GUIContent(EditorGUIUtility.IconContent("Animation.Play").image, "Play (Toggle)"), EditorStyles.toolbarButton); - if (EditorGUI.EndChangeCheck()) - { - ResetFace(); - } - // "PauseButton" - if (GUILayout.Button(new GUIContent(EditorGUIUtility.IconContent("PauseButton").image, "Pause"), EditorStyles.toolbarButton)) - { - play = false; - ResetFace(); - } - // "Animation.NextKey" - if (GUILayout.Button(new GUIContent(EditorGUIUtility.IconContent("Animation.NextKey").image, "Next Frame"), EditorStyles.toolbarButton)) - { - play = false; - time += 0.0166f; - ResetFace(); - } - // "Animation.LastKey" - if (GUILayout.Button(new GUIContent(EditorGUIUtility.IconContent("Animation.LastKey").image, "Last Frame"), EditorStyles.toolbarButton)) - { - play = false; - time = WorkingClip.length; - ResetFace(); - } - - if (!UnityEditorInternal.InternalEditorUtility.isApplicationActive) play = false; - - GUILayout.EndHorizontal(); - - EditorGUI.EndDisabledGroup(); - - GUI.enabled = true; - } - GUILayout.EndVertical(); - } - // - */ - public class Styles { public GUIStyle settingsButton; @@ -686,14 +589,14 @@ public static void DrawPlayer() GUILayout.BeginHorizontal(); GUILayout.Space(4f); - + EditorGUI.BeginDisabledGroup(AnimRetargetGUI.IsPlayerShown()); EditorGUI.BeginChangeCheck(); - FootIK = GUILayout.Toggle(FootIK, new GUIContent("IK", "Toggle feet IK"), guiStyles.settingsButton, GUILayout.Width(24f), GUILayout.Height(24f)); + FootIK = GUILayout.Toggle(FootIK, new GUIContent("IK", FootIK ? "Toggle feet IK - Currently: ON" : "Toggle feet IK - Currently: OFF"), guiStyles.settingsButton, GUILayout.Width(24f), GUILayout.Height(24f)); if (EditorGUI.EndChangeCheck()) { ToggleIKButton(); } - + EditorGUI.EndDisabledGroup(); // Camera Bone Tracker if (!CheckTackingStatus()) @@ -731,11 +634,12 @@ public static void DrawPlayer() ResetCharacterAndPlayer(); } + EditorGUI.BeginDisabledGroup(AnimRetargetGUI.IsPlayerShown()); if (GUILayout.Button(new GUIContent(EditorGUIUtility.IconContent("d__Menu").image, "Animation Clip Preferences"), guiStyles.settingsButton, GUILayout.Width(20f), GUILayout.Height(20f))) { ShowPrefsGenericMenu(); } - + EditorGUI.EndDisabledGroup(); GUILayout.Space(4f); @@ -783,30 +687,23 @@ public static void DrawPlayer() EditorGUI.BeginDisabledGroup(!(CharacterAnimator && WorkingClip)); GUILayout.BeginHorizontal(EditorStyles.toolbar); + // "Animation.FirstKey" if (GUILayout.Button(new GUIContent(EditorGUIUtility.IconContent("Animation.FirstKey").image, "First Frame"), EditorStyles.toolbarButton)) { FirstFrameButton(); } + // "Animation.PrevKey" if (GUILayout.Button(new GUIContent(EditorGUIUtility.IconContent("Animation.PrevKey").image, "Previous Frame"), EditorStyles.toolbarButton)) { PrevFrameButton(); } + // "Animation.Play" Texture playButton = playbackSpeed > 0 ? EditorGUIUtility.IconContent("d_forward@2x").image : EditorGUIUtility.IconContent("d_back@2x").image; Texture pauseButton = EditorGUIUtility.IconContent("PauseButton").image; - /* - if (GUILayout.Button(new GUIContent(playButton, "Play"), EditorStyles.toolbarButton, GUILayout.Height(30f))) - { - PlayButton(); - } - // "PauseButton" - if (GUILayout.Button(new GUIContent(EditorGUIUtility.IconContent("PauseButton").image, "Pause"), EditorStyles.toolbarButton)) - { - PauseButton(); - } - */ + // play/pause: "Animation.Play" / "PauseButton" if (GUILayout.Button(new GUIContent(play ? pauseButton : playButton, play ? "Pause" : "Play"), EditorStyles.toolbarButton, GUILayout.Height(30f))) @@ -819,6 +716,7 @@ public static void DrawPlayer() { NextFrameButton(); } + // "Animation.LastKey" if (GUILayout.Button(new GUIContent(EditorGUIUtility.IconContent("Animation.LastKey").image, "Last Frame"), EditorStyles.toolbarButton)) { @@ -836,24 +734,7 @@ public static void DrawPlayer() ApplicationPlayToggle(); } - - GUILayout.EndHorizontal(); - - /* - EditorGUILayout.Space(28f); - GUILayout.BeginHorizontal(EditorStyles.toolbar); - GUILayout.FlexibleSpace(); - - Texture bigPlayButton = EditorApplication.isPlaying ? EditorGUIUtility.IconContent("preAudioPlayOn").image : EditorGUIUtility.IconContent("preAudioPlayOff").image; - string playToggleTxt = EditorApplication.isPlaying ? "Exit 'Play Mode'." : "Enter 'Play Mode' and focus on the scene view window. This is to be used to evaluate play mode physics whilst allowing visualization of objects such as colliders."; - if (GUILayout.Button(new GUIContent(bigPlayButton, playToggleTxt), EditorStyles.toolbarButton, GUILayout.Height(100f), GUILayout.Width(100f))) - { - ApplicationPlayToggle(); - } - - GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); - */ } GUILayout.EndVertical(); } @@ -867,22 +748,7 @@ private static void ToggleIKButton() { // Alternative method - retrieve a copy of the layers - modify then reapply // find the controlstate by nameHash - AnimatorControllerLayer[] allLayer = playbackAnimatorController.layers; - for (int i = 0; i < allLayer.Length; i++) - { - ChildAnimatorState[] states = allLayer[i].stateMachine.states; - for (int j = 0; j < states.Length; j++) - { - if (states[j].state.nameHash == controlStateHash) - { - states[j].state.iKOnFeet = FootIK; - allLayer[i].iKPass = FootIK; - } - } - } - if (EditorApplication.isPlaying) CharacterAnimator.gameObject.SetActive(false); - playbackAnimatorController.layers = allLayer; - if (EditorApplication.isPlaying) CharacterAnimator.gameObject.SetActive(true); + SetFootIK(FootIK); // originally using the cached default state directly ... // both methods encounter errors when changing foot ik during runtime @@ -903,7 +769,7 @@ private static void ToggleIKButton() CharacterAnimator.Update(time); } } - + // playback speed slider sets speed multiplier directly in edit mode but requires an update in play mode private static void PlaybackSpeedSlider() { @@ -927,13 +793,10 @@ public static void ResetCharacterAndPlayer() // reset the player ResetAnimationPlayer(); - // clear all the animation data ============================================================== - // ============================================================================================ + // clear all the animation data WorkingClip = null; OriginalClip = null; - // ENSURE RESET OF SELECTION FIELDS TOO - // ============================================================================================ - + // clear the animation controller + override controller // remove the on-disk temporary controller ResetToBaseAnimatorController(); @@ -1400,16 +1263,7 @@ private static void DeselectAllBones() }; #endregion Pose reset and bone tracking - public static void SampleOnce() - { - if (CharacterAnimator && WorkingClip) - { - if (!AnimationMode.InAnimationMode()) AnimationMode.StartAnimationMode(); - AnimationMode.BeginSampling(); - AnimationMode.SampleAnimationClip(CharacterAnimator.gameObject, WorkingClip, time); - AnimationMode.EndSampling(); - } - } + #region Update private static void PlayStateChangeCallback(PlayModeStateChange state) @@ -1514,50 +1368,8 @@ private static void UpdateCallback() } } - - #endregion Update - - private static void UpdateDelegate() - { - if (updateTime == 0f) updateTime = EditorApplication.timeSinceStartup; - deltaTime = EditorApplication.timeSinceStartup - updateTime; - updateTime = EditorApplication.timeSinceStartup; - - AdjustEyes(); - - if (!EditorApplication.isPlaying && AnimationMode.InAnimationMode()) - { - if (WorkingClip && CharacterAnimator) - { - if (play) - { - double frameDuration = 1.0f / WorkingClip.frameRate; - - time += (float)deltaTime; - frameTime += deltaTime; - if (time >= WorkingClip.length) - time = 0f; - - if (frameTime < frameDuration) return; - frameTime = 0f; - } - else - frameTime = 1f; - - if (current != time || forceUpdate) - { - AnimationMode.BeginSampling(); - AnimationMode.SampleAnimationClip(CharacterAnimator.gameObject, WorkingClip, time); - AnimationMode.EndSampling(); - SceneView.RepaintAll(); - - AnimPlayerGUI.current = time; - forceUpdate = false; - } - } - } - } + #endregion Update #endregion AnimPlayer diff --git a/Editor/AnimPlayerOverlay.cs b/Editor/AnimPlayerOverlay.cs index 1165e23..eb26d83 100644 --- a/Editor/AnimPlayerOverlay.cs +++ b/Editor/AnimPlayerOverlay.cs @@ -35,7 +35,10 @@ public class AnimPlayerOverlay : IMGUIOverlay, ITransientOverlay private static bool visibility = false; public static bool Visibility { get { return visibility; } } public static float width; - public static float height; + public static float height; + public static float containerHeight; + public static float containerWidth; + public static bool setInitialPosition = false; public static bool AnyVisible() { @@ -45,19 +48,19 @@ public static bool AnyVisible() } return false; } - + public static void ShowAll() { - visibility = true; + visibility = true; foreach (AnimPlayerOverlay apo in createdOverlays) { apo.Show(); - } + } } public static void HideAll() { - visibility = false; + visibility = false; foreach (AnimPlayerOverlay apo in createdOverlays) { apo.Hide(); @@ -65,33 +68,30 @@ public static void HideAll() } AnimPlayerOverlay() - { - isVisible = visibility; + { + isVisible = visibility; } public void Show() - { - isVisible = true; + { if (isInToolbar) Undock(); - collapsed = false; - floatingPosition = new Vector2( - containerWindow.position.width - width - 3f, - containerWindow.position.height - height - 3f - ); + collapsed = false; + setInitialPosition = true; + isVisible = true; } public void Hide() - { + { isVisible = false; } public override void OnCreated() - { - createdOverlays.Add(this); + { + createdOverlays.Add(this); } public override void OnWillBeDestroyed() - { + { if (createdOverlays.Contains(this)) { Hide(); @@ -106,11 +106,18 @@ public override void OnGUI() AnimPlayerGUI.DrawPlayer(); AnimPlayerGUI.DrawFacialMorph(); - if (Event.current.type == EventType.Repaint) + if (setInitialPosition) { - Rect last = GUILayoutUtility.GetLastRect(); - width = last.x + last.width; - height = last.y + last.height; + if (Event.current.type == EventType.Repaint) + { + Rect last = GUILayoutUtility.GetLastRect(); + width = last.x + last.width; + height = last.y + last.height; + containerHeight = this.containerWindow.position.height; + containerWidth = this.containerWindow.position.width; + floatingPosition = new Vector2(containerWidth - width - 14f, containerHeight - height - 23f); + setInitialPosition = false; + } } } } diff --git a/Editor/AnimRetargetGUI.cs b/Editor/AnimRetargetGUI.cs index 6797565..05fc3d8 100644 --- a/Editor/AnimRetargetGUI.cs +++ b/Editor/AnimRetargetGUI.cs @@ -112,9 +112,6 @@ public static void CloseRetargeter() { //EditorApplication.update -= UpdateDelegate; - //if (AnimationMode.InAnimationMode()) - // AnimationMode.StopAnimationMode(); - #if SCENEVIEW_OVERLAY_COMPATIBLE //2021.2.0a17+ AnimRetargetOverlay.HideAll(); @@ -154,11 +151,17 @@ static void Init() unlockedImage = Reallusion.Import.Util.FindTexture(folders, "RLIcon_Unlocked"); RebuildClip(); + + // reset all the clip flags to their default vaules + // set the animation player's Foot IK to off + AnimPlayerGUI.ForceSettingsReset(); + AnimPlayerGUI.UpdateAnimator(); } static void CleanUp() - { - + { + // reset the player fully with the currently selected clip + AnimPlayerGUI.SetupCharacterAndAnimation(); } public static void ResetClip() @@ -271,7 +274,6 @@ public static void DrawRetargeter() // All retarget controls GUILayout.BeginVertical(); // Horizontal Group of 3 controls `Hand` `Jaw` and `Blendshapes` - //EditorGUI.BeginDisabledGroup(!AnimationMode.InAnimationMode()); GUILayout.BeginHorizontal(); GUILayout.BeginVertical("box", GUILayout.Width(baseControlWidth)); // Hand control box - Width used to impose layout footprint for overlay GUILayout.BeginHorizontal(); @@ -279,8 +281,7 @@ public static void DrawRetargeter() { handPose++; if (handPose > 2) handPose = 0; - ApplyPose(handPose); - AnimPlayerGUI.SampleOnce(); + ApplyPose(handPose); } GUILayout.BeginVertical(); @@ -297,7 +298,6 @@ public static void DrawRetargeter() if (EditorGUI.EndChangeCheck()) { ApplyPose(handPose); - AnimPlayerGUI.SampleOnce(); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); @@ -309,7 +309,6 @@ public static void DrawRetargeter() { closeMouth = !closeMouth; CloseMouthToggle(closeMouth); - AnimPlayerGUI.SampleOnce(); } GUILayout.EndVertical(); // End of Jaw control @@ -353,7 +352,7 @@ public static void DrawRetargeter() if (GUILayout.Button(new GUIContent(blendshapeImage, "Copy all BlendShape animations from the selected animation clip to all of the relevant objects (e.g. facial hair) in the selected Scene Model."), GUILayout.Width(largeIconDim), GUILayout.Height(largeIconDim))) { RetargetBlendShapes(OriginalClip, WorkingClip, CharacterAnimator.gameObject); - AnimPlayerGUI.SampleOnce(); + AnimPlayerGUI.UpdateAnimator(); } GUI.backgroundColor = backgroundColor; GUI.enabled = true; @@ -371,9 +370,6 @@ public static void DrawRetargeter() if (EditorGUI.EndChangeCheck()) { OffsetShoulders(); - CharacterAnimator.gameObject.transform.position = animatorPosition; - CharacterAnimator.gameObject.transform.rotation = animatorRotation; - AnimPlayerGUI.SampleOnce(); } EditorGUI.BeginChangeCheck(); @@ -384,9 +380,6 @@ public static void DrawRetargeter() if (EditorGUI.EndChangeCheck()) { OffsetArms(); - CharacterAnimator.gameObject.transform.position = animatorPosition; - CharacterAnimator.gameObject.transform.rotation = animatorRotation; - AnimPlayerGUI.SampleOnce(); } EditorGUI.BeginChangeCheck(); @@ -396,10 +389,7 @@ public static void DrawRetargeter() GUILayout.EndHorizontal(); if (EditorGUI.EndChangeCheck()) { - OffsetArmsFB(); - CharacterAnimator.gameObject.transform.position = animatorPosition; - CharacterAnimator.gameObject.transform.rotation = animatorRotation; - AnimPlayerGUI.SampleOnce(); + OffsetArmsFB(); } EditorGUI.BeginChangeCheck(); @@ -409,10 +399,7 @@ public static void DrawRetargeter() GUILayout.EndHorizontal(); if (EditorGUI.EndChangeCheck()) { - OffsetLegs(); - CharacterAnimator.gameObject.transform.position = animatorPosition; - CharacterAnimator.gameObject.transform.rotation = animatorRotation; - AnimPlayerGUI.SampleOnce(); + OffsetLegs(); } EditorGUI.BeginChangeCheck(); @@ -422,10 +409,7 @@ public static void DrawRetargeter() GUILayout.EndHorizontal(); if (EditorGUI.EndChangeCheck()) { - OffsetHeel(); - CharacterAnimator.gameObject.transform.position = animatorPosition; - CharacterAnimator.gameObject.transform.rotation = animatorRotation; - AnimPlayerGUI.SampleOnce(); + OffsetHeel(); } EditorGUI.BeginChangeCheck(); @@ -435,10 +419,7 @@ public static void DrawRetargeter() GUILayout.EndHorizontal(); if (EditorGUI.EndChangeCheck()) { - OffsetHeight(); - CharacterAnimator.gameObject.transform.position = animatorPosition; - CharacterAnimator.gameObject.transform.rotation = animatorRotation; - AnimPlayerGUI.SampleOnce(); + OffsetHeight(); } GUILayout.EndVertical(); // End of animation curve adjustment sliders @@ -461,9 +442,6 @@ public static void DrawRetargeter() if (GUILayout.Button(new GUIContent(resetImage, "Reset all slider settings and applied modifications."), GUILayout.Width(smallIconDim), GUILayout.Height(smallIconDim))) { ResetClip(); - CharacterAnimator.gameObject.transform.position = animatorPosition; - CharacterAnimator.gameObject.transform.rotation = animatorRotation; - AnimPlayerGUI.SampleOnce(); } GUILayout.EndVertical(); GUILayout.BeginVertical("box"); // save button @@ -545,8 +523,10 @@ static void CloseMouthToggle(bool close) } jawCurve.keys = jawKeys; } - - AnimationUtility.SetEditorCurve(WorkingClip, targetBinding, jawCurve); + AnimationClip swapClip = AnimPlayerGUI.CloneClip(WorkingClip); + AnimationUtility.SetEditorCurve(swapClip, targetBinding, jawCurve); + AnimPlayerGUI.SelectOverrideAnimationWithoutReset(swapClip, AnimPlayerGUI.animatorOverrideController); + AnimPlayerGUI.UpdateAnimator(); } @@ -571,7 +551,6 @@ static void ApplyPose(int mode) SetPose(closedHandPose); break; } - } } @@ -579,6 +558,8 @@ static void SetPose(Dictionary pose) { if (!(OriginalClip && WorkingClip)) return; + AnimationClip swapClip = AnimPlayerGUI.CloneClip(WorkingClip); + EditorCurveBinding[] curveBindings = AnimationUtility.GetCurveBindings(OriginalClip); foreach (EditorCurveBinding binding in curveBindings) { @@ -593,25 +574,31 @@ static void SetPose(Dictionary pose) keys[i].value = p.Value; } curve.keys = keys; - AnimationUtility.SetEditorCurve(WorkingClip, binding, curve); + AnimationUtility.SetEditorCurve(swapClip, binding, curve); } } } + AnimPlayerGUI.SelectOverrideAnimationWithoutReset(swapClip, AnimPlayerGUI.animatorOverrideController); + AnimPlayerGUI.UpdateAnimator(); } static void ResetPose() { if (!(OriginalClip && WorkingClip)) return; + AnimationClip swapClip = AnimPlayerGUI.CloneClip(WorkingClip); + EditorCurveBinding[] curveBindings = AnimationUtility.GetCurveBindings(OriginalClip); foreach (EditorCurveBinding binding in curveBindings) { if (handCurves.Contains(binding.propertyName)) { AnimationCurve curve = AnimationUtility.GetEditorCurve(OriginalClip, binding); - AnimationUtility.SetEditorCurve(WorkingClip, binding, curve); + AnimationUtility.SetEditorCurve(swapClip, binding, curve); } } + AnimPlayerGUI.SelectOverrideAnimationWithoutReset(swapClip, AnimPlayerGUI.animatorOverrideController); + AnimPlayerGUI.UpdateAnimator(); } static void OffsetALL() @@ -625,9 +612,26 @@ static void OffsetALL() CloseMouthToggle(closeMouth); ApplyPose(handPose); } + + static void SetEditorCurves(AnimationClip clip, List bindings, List curves) + { +#if UNITY_2020_3_OR_NEWER + AnimationUtility.SetEditorCurves(clip, bindings.ToArray(), curves.ToArray()); +#else + int numClips = bindings.Count; + for (int i = 0; i < numClips; i++) + { + AnimationUtility.SetEditorCurve(clip, bindings[i], curves[i]); + } +#endif + } + static void OffsetShoulders() { if (!(OriginalClip && WorkingClip)) return; + + List applicableBindings = new List(); + List applicableCurves = new List(); foreach (KeyValuePair bind in shoulderBindings) { @@ -688,7 +692,6 @@ static void OffsetShoulders() break; } - float diff = shoulderOffset * scale; if (update) { @@ -696,11 +699,8 @@ static void OffsetShoulders() diff = (backgroundArmOffset + armOffset) * scale; } - - for (int a = 0; a < keys.Length; a++) { - keys[a].value = eval ? EvaluateValue(keys[a].value, subtract ? -diff : diff) : keys[a].value + (subtract ? -diff : diff); } curve.keys = keys; @@ -708,14 +708,22 @@ static void OffsetShoulders() { curve.SmoothTangents(b, 0.0f); } - AnimationUtility.SetEditorCurve(WorkingClip, bind.Value, curve); - } + applicableBindings.Add(bind.Value); + applicableCurves.Add(curve); + } + AnimationClip swapClip = AnimPlayerGUI.CloneClip(WorkingClip); + SetEditorCurves(swapClip, applicableBindings, applicableCurves); + AnimPlayerGUI.SelectOverrideAnimationWithoutReset(swapClip, AnimPlayerGUI.animatorOverrideController); + AnimPlayerGUI.UpdateAnimator(); } static void OffsetArms() { if (!(OriginalClip && WorkingClip)) return; + List applicableBindings = new List(); + List applicableCurves = new List(); + foreach (KeyValuePair bind in armBindings) { float scale = 0f; @@ -775,14 +783,22 @@ static void OffsetArms() { curve.SmoothTangents(b, 0.0f); } - AnimationUtility.SetEditorCurve(WorkingClip, bind.Value, curve); + applicableBindings.Add(bind.Value); + applicableCurves.Add(curve); } + AnimationClip swapClip = AnimPlayerGUI.CloneClip(WorkingClip); + SetEditorCurves(swapClip, applicableBindings, applicableCurves); + AnimPlayerGUI.SelectOverrideAnimationWithoutReset(swapClip, AnimPlayerGUI.animatorOverrideController); + AnimPlayerGUI.UpdateAnimator(); } static void OffsetArmsFB() { if (!(OriginalClip && WorkingClip)) return; + List applicableBindings = new List(); + List applicableCurves = new List(); + foreach (KeyValuePair bind in armFBBindings) { float scale = 0f; @@ -828,14 +844,22 @@ static void OffsetArmsFB() { curve.SmoothTangents(b, 0.0f); } - AnimationUtility.SetEditorCurve(WorkingClip, bind.Value, curve); + applicableBindings.Add(bind.Value); + applicableCurves.Add(curve); } + AnimationClip swapClip = AnimPlayerGUI.CloneClip(WorkingClip); + SetEditorCurves(swapClip, applicableBindings, applicableCurves); + AnimPlayerGUI.SelectOverrideAnimationWithoutReset(swapClip, AnimPlayerGUI.animatorOverrideController); + AnimPlayerGUI.UpdateAnimator(); } static void OffsetLegs() { if (!(OriginalClip && WorkingClip)) return; + List applicableBindings = new List(); + List applicableCurves = new List(); + foreach (KeyValuePair bind in legBindings) { float scale = 0f; @@ -889,14 +913,22 @@ static void OffsetLegs() { curve.SmoothTangents(b, 0.0f); } - AnimationUtility.SetEditorCurve(WorkingClip, bind.Value, curve); + applicableBindings.Add(bind.Value); + applicableCurves.Add(curve); } + AnimationClip swapClip = AnimPlayerGUI.CloneClip(WorkingClip); + SetEditorCurves(swapClip, applicableBindings, applicableCurves); + AnimPlayerGUI.SelectOverrideAnimationWithoutReset(swapClip, AnimPlayerGUI.animatorOverrideController); + AnimPlayerGUI.UpdateAnimator(); } static void OffsetHeel() { if (!(OriginalClip && WorkingClip)) return; + List applicableBindings = new List(); + List applicableCurves = new List(); + foreach (KeyValuePair bind in heelBindings) { float scale = 0f; @@ -950,14 +982,22 @@ static void OffsetHeel() { curve.SmoothTangents(b, 0.0f); } - AnimationUtility.SetEditorCurve(WorkingClip, bind.Value, curve); + applicableBindings.Add(bind.Value); + applicableCurves.Add(curve); } + AnimationClip swapClip = AnimPlayerGUI.CloneClip(WorkingClip); + SetEditorCurves(swapClip, applicableBindings, applicableCurves); + AnimPlayerGUI.SelectOverrideAnimationWithoutReset(swapClip, AnimPlayerGUI.animatorOverrideController); + AnimPlayerGUI.UpdateAnimator(); } static void OffsetHeight() { if (!(OriginalClip && WorkingClip)) return; + List applicableBindings = new List(); + List applicableCurves = new List(); + foreach (KeyValuePair bind in heightBindings) { AnimationCurve curve = AnimationUtility.GetEditorCurve(OriginalClip, bind.Value); @@ -974,8 +1014,13 @@ static void OffsetHeight() { curve.SmoothTangents(b, 0.0f); } - AnimationUtility.SetEditorCurve(WorkingClip, bind.Value, curve); + applicableBindings.Add(bind.Value); + applicableCurves.Add(curve); } + AnimationClip swapClip = AnimPlayerGUI.CloneClip(WorkingClip); + SetEditorCurves(swapClip, applicableBindings, applicableCurves); + AnimPlayerGUI.SelectOverrideAnimationWithoutReset(swapClip, AnimPlayerGUI.animatorOverrideController); + AnimPlayerGUI.UpdateAnimator(); } static float EvaluateValue(float currentKeyValue, float deltaValue) diff --git a/Editor/AnimRetargetOverlay.cs b/Editor/AnimRetargetOverlay.cs index ff159b6..58a4978 100644 --- a/Editor/AnimRetargetOverlay.cs +++ b/Editor/AnimRetargetOverlay.cs @@ -34,7 +34,9 @@ public class AnimRetargetOverlay : IMGUIOverlay, ITransientOverlay private static bool visibility = false; public static bool Visibility { get { return visibility; } } public static float width; - public static float height; + public static float height; + public static float containerHeight; + public static bool setInitialPosition = false; public static bool AnyVisible() { @@ -70,14 +72,15 @@ public static void HideAll() public void Show() { - isVisible = true; + setInitialPosition = true; Undock(); Undock(); - collapsed = false; + collapsed = false; floatingPosition = new Vector2( 1f, this.containerWindow.position.height - height - 3f ); + isVisible = true; } public void Hide() @@ -103,14 +106,19 @@ public override void OnWillBeDestroyed() public override void OnGUI() { - //if (!AnimPlayerGUI.useLightIcons) AnimPlayerGUI.useLightIcons = true; - AnimRetargetGUI.DrawRetargeter(); + AnimRetargetGUI.DrawRetargeter(); - if (Event.current.type == EventType.Repaint) + if (setInitialPosition) { - Rect last = GUILayoutUtility.GetLastRect(); - width = last.x + last.width; - height = last.y + last.height; + if (Event.current.type == EventType.Repaint) + { + Rect last = GUILayoutUtility.GetLastRect(); + width = last.x + last.width; + height = last.y + last.height; + containerHeight = this.containerWindow.position.height; + floatingPosition = new Vector2(1f, containerHeight - height - 23f); + setInitialPosition = false; + } } } } diff --git a/Editor/ColliderManagerEditor.cs b/Editor/ColliderManagerEditor.cs index 306b5d3..0b0c1de 100644 --- a/Editor/ColliderManagerEditor.cs +++ b/Editor/ColliderManagerEditor.cs @@ -295,7 +295,6 @@ public void UpdatePrefab(Object component) { WindowManager.HideAnimationPlayer(true); WindowManager.HideAnimationRetargeter(true); - WindowManager.StopAnimationMode(); GameObject prefabRoot = PrefabUtility.GetOutermostPrefabInstanceRoot(component); if (prefabRoot) diff --git a/Editor/ImporterMenu.cs b/Editor/ImporterMenu.cs index 23e27a2..9534ba4 100644 --- a/Editor/ImporterMenu.cs +++ b/Editor/ImporterMenu.cs @@ -20,7 +20,6 @@ using UnityEngine; using UnityEditor; -using System.IO; namespace Reallusion.Import { diff --git a/Editor/ImporterWindow.cs b/Editor/ImporterWindow.cs index c0fb01a..76805ee 100644 --- a/Editor/ImporterWindow.cs +++ b/Editor/ImporterWindow.cs @@ -1267,11 +1267,7 @@ public bool UpdatePreviewCharacter(GameObject prefabAsset) { if (WindowManager.IsPreviewScene) { - bool animationMode = WindowManager.StopAnimationMode(); - WindowManager.GetPreviewScene().UpdatePreviewCharacter(prefabAsset); - - WindowManager.RestartAnimationMode(animationMode); } return WindowManager.IsPreviewScene; @@ -1369,11 +1365,7 @@ bool ShowBakedCharacter(GameObject bakedAsset) { if (WindowManager.IsPreviewScene) { - bool animationMode = WindowManager.StopAnimationMode(); - WindowManager.GetPreviewScene().ShowBakedCharacter(bakedAsset); - - WindowManager.RestartAnimationMode(animationMode); } return WindowManager.IsPreviewScene; @@ -1383,7 +1375,6 @@ void RebuildCharacterPhysics() { WindowManager.HideAnimationPlayer(true); WindowManager.HideAnimationRetargeter(true); - WindowManager.StopAnimationMode(); GameObject prefabAsset = Physics.RebuildPhysics(contextCharacter); diff --git a/Editor/Lodify.cs b/Editor/Lodify.cs index c0948c1..7f2a61b 100644 --- a/Editor/Lodify.cs +++ b/Editor/Lodify.cs @@ -16,7 +16,6 @@ * along with CC_Unity_Tools. If not, see . */ -using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEditor; diff --git a/Editor/MeshUtil.cs b/Editor/MeshUtil.cs index edfbf0e..e48add8 100644 --- a/Editor/MeshUtil.cs +++ b/Editor/MeshUtil.cs @@ -238,9 +238,7 @@ public static Mesh GetMeshFrom(Object obj) } public static bool ReplaceMesh(Object obj, Mesh mesh) - { - bool animationMode = WindowManager.StopAnimationMode(obj); - + { bool replaced = false; Object o = null; @@ -276,8 +274,6 @@ public static bool ReplaceMesh(Object obj, Mesh mesh) PrefabUtility.ApplyPrefabInstance(sceneRoot, InteractionMode.UserAction); } - WindowManager.RestartAnimationMode(animationMode); - return replaced; } diff --git a/Editor/Physics.cs b/Editor/Physics.cs index 97fb65f..5fd9d50 100644 --- a/Editor/Physics.cs +++ b/Editor/Physics.cs @@ -276,15 +276,11 @@ private void ReadPhysicsJson(QuickJSON physicsJson, QuickJSON characterJson) public void AddPhysics(bool applyInstance) { - bool animationMode = WindowManager.StopAnimationMode(); - AddColliders(); AddCloth(); AddSpringBones(); if (applyInstance) PrefabUtility.ApplyPrefabInstance(prefabInstance, InteractionMode.AutomatedAction); - - WindowManager.RestartAnimationMode(animationMode); } public void RemoveAllPhysics() diff --git a/Editor/Pipeline.cs b/Editor/Pipeline.cs index 5cb459b..8897ac8 100644 --- a/Editor/Pipeline.cs +++ b/Editor/Pipeline.cs @@ -19,7 +19,6 @@ using System.Collections.Generic; using UnityEditor; using UnityEngine; -using UnityEngine.Rendering; #if HDRP_10_5_0_OR_NEWER using UnityEngine.Rendering.HighDefinition; using UnityEditor.Rendering.HighDefinition; diff --git a/Editor/Util.cs b/Editor/Util.cs index b144ad6..e0b3c58 100644 --- a/Editor/Util.cs +++ b/Editor/Util.cs @@ -1095,8 +1095,9 @@ public static bool AssetPathExists(string assetPath) public static bool AssetPathIsEmpty(string assetPath) { const string emptyGuid = "00000000000000000000000000000000"; + string pathGUID = AssetDatabase.AssetPathToGUID(assetPath); - return AssetDatabase.AssetPathToGUID(assetPath).Equals(emptyGuid); + return (pathGUID.Equals(emptyGuid) || string.IsNullOrEmpty(pathGUID)); } public static bool HasMaterialKeywords(GameObject obj, params string[] keywords) diff --git a/Editor/WeightMapperEditor.cs b/Editor/WeightMapperEditor.cs index db4413a..cda7786 100644 --- a/Editor/WeightMapperEditor.cs +++ b/Editor/WeightMapperEditor.cs @@ -59,11 +59,7 @@ public void OnClothInspectorGUI() GUI.backgroundColor = Color.Lerp(background, Color.white, 0.25f); if (GUILayout.Button("Rebuild Constraints", GUILayout.Width(BUTTON_WIDTH))) { - bool animationMode = WindowManager.StopAnimationMode(); - weightMapper.ApplyWeightMap(); - - WindowManager.RestartAnimationMode(animationMode); } GUI.backgroundColor = background; GUILayout.FlexibleSpace(); @@ -117,7 +113,6 @@ public void UpdatePrefab(Object component) { WindowManager.HideAnimationPlayer(true); WindowManager.HideAnimationRetargeter(true); - WindowManager.StopAnimationMode(); GameObject prefabRoot = PrefabUtility.GetOutermostPrefabInstanceRoot(component); if (prefabRoot) diff --git a/Editor/WindowManager.cs b/Editor/WindowManager.cs index 5205443..ff8e33b 100644 --- a/Editor/WindowManager.cs +++ b/Editor/WindowManager.cs @@ -147,66 +147,13 @@ public static void OnPlayModeStateChanged(PlayModeStateChange state) break; } } - /* - if (state == PlayModeStateChange.EnteredPlayMode) - { - showPlayerAfterPlayMode = showPlayer; - showRetargetAfterPlayMode = showRetarget; - showPlayer = false; - showRetarget = false; - AnimPlayerGUI.ClosePlayer(); - AnimRetargetGUI.CloseRetargeter(); - - /* - // original - showPlayerAfterPlayMode = showPlayer; - showRetargetAfterPlayMode = showRetarget; - showPlayer = false; - showRetarget = false; - AnimPlayerGUI.ClosePlayer(); - AnimRetargetGUI.CloseRetargeter(); - */ - /* - if (Util.TryDeSerializeBoolFromEditorPrefs(out bool val, WindowManager.sceneFocus)) - { - if (val) - { - SceneView.lastActiveSceneView.Focus(); - Util.SerializeBoolToEditorPrefs(false, WindowManager.sceneFocus); - ShowAnimationPlayer(); - if (Util.TryDeSerializeFloatFromEditorPrefs(out float timeCode, WindowManager.timeKey)) - { - //set the play position - AnimPlayerGUI.time = timeCode; - //slightly delay startup to allow the animator to initialize - AnimPlayerGUI.delayFrames = 10; - } - } - else //no scene view focus grab - replace the oringinal runtime animator controller - { - if (Util.TryDeSerializeBoolFromEditorPrefs(out bool restore, WindowManager.animatorControllerKey)) - { - if (restore) - { - AnimPlayerGUI.RestoreBaseAnimatorController(); - } - } - } - } - } - else if (state == PlayModeStateChange.EnteredEditMode) - { - showPlayer = showPlayerAfterPlayMode; - showRetarget = showRetargetAfterPlayMode; - } - */ } public static void OnBeforeAssemblyReload() { if (AnimationMode.InAnimationMode()) { - Util.LogInfo("Disabling Animation Mode on editor assembly reload."); + Util.LogWarn("Disabling Animation Mode on editor assembly reload."); AnimationMode.StopAnimationMode(); } @@ -527,32 +474,6 @@ public static void HideAnimationRetargeter(bool updateShowRetarget) showRetarget = false; } - public static bool StopAnimationMode(UnityEngine.Object obj = null) - { - bool inAnimationMode = false; - if (AnimationMode.InAnimationMode()) - { - inAnimationMode = true; - AnimationMode.StopAnimationMode(); - if (obj) - { - GameObject scenePrefab = Util.GetScenePrefabInstanceRoot(obj); - Util.TryResetScenePrefab(scenePrefab); - } - } - - return inAnimationMode; - } - - public static void RestartAnimationMode(bool inAnimationMode) - { - if (inAnimationMode) - { - if (!AnimationMode.InAnimationMode()) - AnimationMode.StartAnimationMode(); - } - } - public static void StartTimer(float delay) { timer = delay;