@@ -214,6 +214,7 @@ static class Styles
214214 public static Texture2D prefabOverlayRemovedIcon = EditorGUIUtility.LoadIcon("PrefabOverlayRemoved Icon");
215215 public static readonly GUIStyle linkButton = "FloatFieldLinkButton";
216216 public static Texture2D repaintDot = EditorGUIUtility.LoadIcon("RepaintDot");
217+ public static string revertPropertyValueIdenticalToSource = L10n.Tr("Revert (identical value to Prefab '{0}')");
217218 }
218219
219220 static EditorGUI()
@@ -3027,6 +3028,14 @@ internal static GenericMenu FillPropertyContextMenu(SerializedProperty property,
30273028 }
30283029 else if (shouldDisplayPrefabContextMenuItems)
30293030 {
3031+ bool samePropertyValueAsSource = false;
3032+
3033+ Object source = PrefabUtility.GetCorrespondingObjectFromSource(targetObject);
3034+ SerializedObject sourceSerializedObject = new SerializedObject(source);
3035+ SerializedProperty sourceProperty = sourceSerializedObject.FindProperty(property.propertyPath);
3036+
3037+ samePropertyValueAsSource = SerializedProperty.DataEquals(property, sourceProperty);
3038+
30303039 PrefabUtility.HandleApplyRevertMenuItems(
30313040 null,
30323041 targetObject,
@@ -3045,7 +3054,18 @@ internal static GenericMenu FillPropertyContextMenu(SerializedProperty property,
30453054 (menuItemContent) =>
30463055 {
30473056 // Add revert menu item.
3048- pm.AddItem(menuItemContent, false, TargetChoiceHandler.RevertPrefabPropertyOverride, properties);
3057+ GUIContent content;
3058+ if (samePropertyValueAsSource)
3059+ {
3060+ GameObject sourceRoot = PrefabUtility.GetRootGameObject(source);
3061+ content = new GUIContent(string.Format(Styles.revertPropertyValueIdenticalToSource, sourceRoot.name));
3062+ }
3063+ else
3064+ {
3065+ content = menuItemContent;
3066+ }
3067+
3068+ pm.AddItem(content, false, TargetChoiceHandler.RevertPrefabPropertyOverride, properties);
30493069 },
30503070 false,
30513071 property.serializedObject.targetObjectsCount
@@ -5827,12 +5847,10 @@ static Rect GetSettingsRect(Rect position, GUIStyle baseStyle, GUIStyle iconButt
58275847
58285848 internal static bool EnableCheckBoxInTitlebar(Object targetObj)
58295849 {
5830- if (targetObj is ScriptableObject && targetObj is StateMachineBehaviour)
5831- return true;
5832- else if (targetObj is ScriptableObject)
5850+ if (targetObj is ScriptableObject && targetObj is not StateMachineBehaviour)
58335851 return false;
5834- else
5835- return true;
5852+
5853+ return true;
58365854 }
58375855
58385856 // Make an inspector-window-like titlebar.
@@ -5865,17 +5883,24 @@ internal static void DoInspectorTitlebar(Rect position, int id, bool foldout, Ob
58655883 int enabled = -1;
58665884 foreach (Object targetObj in targetObjs)
58675885 {
5868- int thisEnabled = EditorUtility.GetObjectEnabled(targetObj);
5869- if (enabled == -1)
5886+ if (comp is MonoBehaviour)
58705887 {
5871- if (EnableCheckBoxInTitlebar(targetObj))
5872- enabled = thisEnabled;
5888+ enabled = 1;
58735889 }
5874- else if (enabled != thisEnabled)
5890+ else
58755891 {
5876- enabled = -2;
5877- // Early out: mix value mode
5878- break;
5892+ int thisEnabled = EditorUtility.GetObjectEnabled(targetObj);
5893+ if (enabled == -1)
5894+ {
5895+ if (EnableCheckBoxInTitlebar(targetObj))
5896+ enabled = thisEnabled;
5897+ }
5898+ else if (enabled != thisEnabled)
5899+ {
5900+ enabled = -2;
5901+ // Early out: mix value mode
5902+ break;
5903+ }
58795904 }
58805905 }
58815906
0 commit comments