From 16a1cc93958c60a5ef27e2e2aaee562d1490b3f9 Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Thu, 8 Sep 2022 17:43:43 +0200 Subject: [PATCH 1/2] [unity] Added Preferences setting `Optimize Preview Meshes`, disabled by default now to not increase build time every build. Previous behaviour was always-on. See #1273. --- CHANGELOG.md | 1 + .../spine-unity/Editor/Utility/SpineBuildProcessor.cs | 6 ++++-- .../Editor/spine-unity/Editor/Windows/SpinePreferences.cs | 5 +++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a4a7a6203..f734a218d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -88,6 +88,7 @@ * Timeline `SkeletonAnimation Track` and `SkeletonGraphic Track` now provide an `Unscaled Time` property. Whenever starting a new animation clip of this track, `SkeletonAnimation.UnscaledTime` or `SkeletonGraphic.UnscaledTime` will be set to this value. This allows you to play back Timeline clips either in normal game time or unscaled game time. Note that `PlayableDirector.UpdateMethod` is ignored and replaced by this property, which allows more fine-granular control per Timeline track. * Added `SkeletonRootMotion` callback delegates `ProcessRootMotionOverride` and `PhysicsUpdateRootMotionOverride` to customize how root motion is applied. The new property `disableOnOverride` determines whether the callback will be issued in addition or instead of normally applying root motion. Added property `rootMotionScaleRotation` to allow scaling rotational root-motion to match e.g. a 90 degree rotation to a custom target angle. * Added outline shader parameter `Advanced - Opaque Alpha` which can be used to exclude problematic semi-transparent areas, which may receive an undesired large outline color overlay otherwise. + * Added Spine Preferences setting `Prefabs` - `Optimize Preview Meshes`. When enabled, Spine prefab preview meshes will be removed in a pre-build step to reduce build size. This increases build time as all prefabs in the project will be processed. Defaults to false to not slow down builds substantially every time. * **Breaking changes** * Made `SkeletonGraphic.unscaledTime` parameter protected, use the new property `UnscaledTime` instead. diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/SpineBuildProcessor.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/SpineBuildProcessor.cs index a5f6db683..0cb095fae 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/SpineBuildProcessor.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/SpineBuildProcessor.cs @@ -67,7 +67,8 @@ namespace Spine.Unity.Editor { internal static void PreprocessBuild () { isBuilding = true; #if HAS_ON_POSTPROCESS_PREFAB - PreprocessSpinePrefabMeshes(); + if (SpineEditorUtilities.Preferences.removePrefabPreviewMeshes) + PreprocessSpinePrefabMeshes(); #endif PreprocessSpriteAtlases(); } @@ -75,7 +76,8 @@ namespace Spine.Unity.Editor { internal static void PostprocessBuild () { isBuilding = false; #if HAS_ON_POSTPROCESS_PREFAB - PostprocessSpinePrefabMeshes(); + if (SpineEditorUtilities.Preferences.removePrefabPreviewMeshes) + PostprocessSpinePrefabMeshes(); #endif PostprocessSpriteAtlases(); } diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Windows/SpinePreferences.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Windows/SpinePreferences.cs index cc5888688..478d8ea03 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Windows/SpinePreferences.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Windows/SpinePreferences.cs @@ -89,6 +89,9 @@ namespace Spine.Unity.Editor { #if HAS_ON_POSTPROCESS_PREFAB internal const bool DEFAULT_FIX_PREFAB_OVERRIDE_VIA_MESH_FILTER = false; public bool fixPrefabOverrideViaMeshFilter = DEFAULT_FIX_PREFAB_OVERRIDE_VIA_MESH_FILTER; + + internal const bool DEFAULT_REMOVE_PREFAB_PREVIEW_MESHES = false; + public bool removePrefabPreviewMeshes = DEFAULT_REMOVE_PREFAB_PREVIEW_MESHES; #endif public bool UsesPMAWorkflow { @@ -324,6 +327,8 @@ namespace Spine.Unity.Editor { { EditorGUILayout.PropertyField(settings.FindProperty("fixPrefabOverrideViaMeshFilter"), new GUIContent("Fix Prefab Overr. MeshFilter", "Fixes the prefab always being marked as changed (sets the MeshFilter's hide flags to DontSaveInEditor), but at the cost of references to the MeshFilter by other components being lost. This is a global setting that can be overwritten on each SkeletonRenderer")); SkeletonRenderer.fixPrefabOverrideViaMeshFilterGlobal = settings.FindProperty("fixPrefabOverrideViaMeshFilter").boolValue; + + EditorGUILayout.PropertyField(settings.FindProperty("removePrefabPreviewMeshes"), new GUIContent("Optimize Preview Meshes", "When enabled, Spine prefab preview meshes will be removed in a pre-build step to reduce build size. This increases build time as all prefabs in the project will be processed.")); } #endif From d9935741c2b84abea85e961489ed71b5b473aa64 Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Fri, 9 Sep 2022 15:27:10 +0200 Subject: [PATCH 2/2] [unity] Using InteractionMode.AutomatedAction at prefab Revert() call in newer Unity versions. See #1273. --- .../Runtime/spine-unity/Components/SkeletonRenderer.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonRenderer.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonRenderer.cs index adc490ace..f99b099df 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonRenderer.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonRenderer.cs @@ -43,6 +43,10 @@ #define CONFIGURABLE_ENTER_PLAY_MODE #endif +#if UNITY_2020_1_OR_NEWER +#define REVERT_HAS_OVERLOADS +#endif + #define SPINE_OPTIONAL_RENDEROVERRIDE #define SPINE_OPTIONAL_MATERIALOVERRIDE @@ -100,7 +104,11 @@ namespace Spine.Unity { var objectOverrides = UnityEditor.PrefabUtility.GetObjectOverrides(instanceRoot); foreach (UnityEditor.SceneManagement.ObjectOverride objectOverride in objectOverrides) { if (objectOverride.instanceObject == meshFilter) { +#if REVERT_HAS_OVERLOADS + objectOverride.Revert(UnityEditor.InteractionMode.AutomatedAction); +#else objectOverride.Revert(); +#endif break; } }