From 24d998ec69964221d003644448700625c8f256ad Mon Sep 17 00:00:00 2001 From: bd_ Date: Sun, 28 Jan 2024 21:25:18 +0900 Subject: [PATCH] fix: optimizing phase not executed even when VRCFury isn't installed (#135) Closes: #129 --- CHANGELOG.md | 1 + Editor/ApplyOnPlay.cs | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a7fa55d..94bfbb9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed ### Changed +- Reverted the optimizing phase to being invoked by Apply on Play when VRCFury is not installed (#135) ### Removed diff --git a/Editor/ApplyOnPlay.cs b/Editor/ApplyOnPlay.cs index a8c2a17..980d983 100644 --- a/Editor/ApplyOnPlay.cs +++ b/Editor/ApplyOnPlay.cs @@ -26,6 +26,8 @@ #region +using System; +using System.Linq; using nadena.dev.ndmf.config; using nadena.dev.ndmf.runtime; using UnityEditor; @@ -62,9 +64,15 @@ private static void MaybeProcessAvatar(ApplyOnPlayGlobalActivator.OnDemandSource { var avatar = RuntimeUtil.FindAvatarInParents(component.transform); if (avatar == null) return; + + var furyInstalled = AppDomain.CurrentDomain.GetAssemblies() + .Any(a => a.GetName().Name == "VRCFury"); - // Skip optimizing the avatar as we might have VRCFury or similar running after us. - AvatarProcessor.ProcessAvatar(avatar.gameObject, BuildPhase.Transforming); + // Skip optimizing the avatar if VRCFury is installed, as VRCFury will run after optimizations + // and might be broken by e.g. blendshape removal, etc. + var lastPhase = furyInstalled ? BuildPhase.Transforming : BuildPhase.Optimizing; + + AvatarProcessor.ProcessAvatar(avatar.gameObject, lastPhase); } }