From 7c09510342c23e487e97edd7170913b0ed0b9af1 Mon Sep 17 00:00:00 2001 From: Gregory Labute Date: Mon, 13 May 2024 11:47:23 -0400 Subject: [PATCH] improve the last commit - we don't want object upgrades happening from prefab inspectors --- .../Editor/Upgrader/CinemachineUpgradeManager.cs | 2 +- .../Editor/Upgrader/UpgradeManagerInspectorHelpers.cs | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/com.unity.cinemachine/Editor/Upgrader/CinemachineUpgradeManager.cs b/com.unity.cinemachine/Editor/Upgrader/CinemachineUpgradeManager.cs index bea6599fb..be1816803 100644 --- a/com.unity.cinemachine/Editor/Upgrader/CinemachineUpgradeManager.cs +++ b/com.unity.cinemachine/Editor/Upgrader/CinemachineUpgradeManager.cs @@ -178,7 +178,7 @@ public static bool ObjectsUsePrefabs(UnityEngine.Object[] objects) if (b != null) go = b.gameObject; } - if (go != null && (PrefabUtility.IsPartOfPrefabInstance(go) || PrefabStageUtility.GetCurrentPrefabStage() != null)) + if (go != null && PrefabUtility.IsPartOfPrefabInstance(go) || PrefabUtility.IsPartOfPrefabAsset(go)) return true; } return false; diff --git a/com.unity.cinemachine/Editor/Upgrader/UpgradeManagerInspectorHelpers.cs b/com.unity.cinemachine/Editor/Upgrader/UpgradeManagerInspectorHelpers.cs index 0cbe04920..d152b0b35 100644 --- a/com.unity.cinemachine/Editor/Upgrader/UpgradeManagerInspectorHelpers.cs +++ b/com.unity.cinemachine/Editor/Upgrader/UpgradeManagerInspectorHelpers.cs @@ -3,6 +3,7 @@ using UnityEditor; using System; using UnityEngine.UIElements; +using UnityEditor.SceneManagement; namespace Unity.Cinemachine.Editor { @@ -88,7 +89,7 @@ public override void OnOpen() }) { text = text, style = { flexGrow = 0, alignSelf = Align.Center } - }).SetEnabled(!CinemachineUpgradeManager.ObjectsUsePrefabs(Editor.targets)); + }).SetEnabled(PrefabStageUtility.GetCurrentPrefabStage() == null && !CinemachineUpgradeManager.ObjectsUsePrefabs(Editor.targets)); // Upgrade current scene ux.AddChild(new TextElement() @@ -105,7 +106,7 @@ public override void OnOpen() }) { text = "Upgrade all objects in Scene", style = { flexGrow = 0, alignSelf = Align.Center } - }).SetEnabled(!CinemachineUpgradeManager.CurrentSceneUsesPrefabs()); + }).SetEnabled(PrefabStageUtility.GetCurrentPrefabStage() == null && !CinemachineUpgradeManager.CurrentSceneUsesPrefabs()); // Upgrade project ux.AddChild(new TextElement()