private static void DrawObjectField(IPropertyValueEntry <T> entry, GUIContent label, ref bool isToggled, bool showToggle = true) { var prev = EditorGUI.showMixedValue; if (entry.ValueState == PropertyValueState.ReferenceValueConflict) { EditorGUI.showMixedValue = true; } object newValue; GUI.changed = false; if (showToggle == false) { #pragma warning disable 0618 // Type or member is obsolete newValue = AllEditorGUI.ObjectField(entry, entry.BaseValueType, label, entry.SmartValue, entry.Property.Info.GetAttribute <AssetsOnlyAttribute>() == null); #pragma warning restore 0618 // Type or member is obsolete } else if (label == null) { EditorGUI.indentLevel++; #pragma warning disable 0618 // Type or member is obsolete newValue = AllEditorGUI.ObjectField(entry, entry.BaseValueType, label, entry.SmartValue, entry.Property.Info.GetAttribute <AssetsOnlyAttribute>() == null); #pragma warning restore 0618 // Type or member is obsolete EditorGUI.indentLevel--; } else { newValue = SirenixEditorFields.PolymorphicObjectField(GUIHelper.TempContent(" " + label.text, label.tooltip), entry.SmartValue, entry.BaseValueType, entry.Property.Info.GetAttribute <AssetsOnlyAttribute>() == null); } if (GUI.changed) { //entry.WeakSmartValue = newValue; entry.Property.Tree.DelayActionUntilRepaint(() => entry.WeakSmartValue = newValue); } if (showToggle) { isToggled = AllEditorGUI.Foldout(GUILayoutUtility.GetLastRect(), isToggled, GUIContent.none); } EditorGUI.showMixedValue = prev; }
protected override void DrawPropertyLayout(IPropertyValueEntry <ToggleableAsset> entry, GUIContent label) { if (entry.SmartValue.AutoToggle) { #pragma warning disable 0618 // Type or member is obsolete AllEditorGUI.ObjectField(null, entry.SmartValue.Object, entry.SmartValue.Object.GetType(), false, true); #pragma warning restore 0618 // Type or member is obsolete } else { var rect = GUILayoutUtility.GetRect(16, 16, GUILayoutOptions.ExpandWidth(true)); var toggleRect = new Rect(rect.x, rect.y, 16, 16); var objectFieldRect = new Rect(rect.x + 20, rect.y, rect.width - 20, 16); if (Event.current.type != EventType.Repaint) { toggleRect.x -= 5; toggleRect.y -= 5; toggleRect.width += 10; toggleRect.height += 10; } var prevChanged = GUI.changed; entry.SmartValue.Toggled = GUI.Toggle(toggleRect, entry.SmartValue.Toggled, ""); if (prevChanged != GUI.changed) { entry.ApplyChanges(); } GUIHelper.PushGUIEnabled(entry.SmartValue.Toggled); #pragma warning disable 0618 // Type or member is obsolete AllEditorGUI.ObjectField(objectFieldRect, null, entry.SmartValue.Object, entry.SmartValue.Object.GetType(), false, true); #pragma warning restore 0618 // Type or member is obsolete GUIHelper.PopGUIEnabled(); } }