/// <summary> /// Draws the property. /// </summary> protected override void DrawPropertyLayout(InspectorProperty property, ShowDrawerChainAttribute attribute, GUIContent label) { OdinDrawer[] drawers = DrawerLocator.GetDrawersForProperty(property); AllEditorGUI.BeginBox("Drawers"); for (int i = 0; i < drawers.Length; i++) { bool highlight = drawers[i].GetType().Assembly != typeof(ShowDrawerChainAttributeDrawer).Assembly; if (highlight) { GUIHelper.PushColor(Color.green); } EditorGUILayout.LabelField(i + ": " + drawers[i].GetType().GetNiceName()); var rect = GUILayoutUtility.GetLastRect(); GUI.Label(rect, DrawerLocator.GetDrawerPriority(drawers[i].GetType()).ToString(), SirenixGUIStyles.RightAlignedGreyMiniLabel); if (highlight) { GUIHelper.PopColor(); } } AllEditorGUI.EndBox(); this.CallNextDrawer(property, label); }
/// <summary> /// Draws the property. /// </summary> protected override void DrawPropertyLayout(IPropertyValueEntry <T> entry, GUIContent label) { if (entry.ValueState == PropertyValueState.Reference) { var isToggled = entry.Context.GetPersistent(this, "is_Toggled", false); var targetProp = entry.Property.Tree.GetPropertyAtPath(entry.TargetReferencePath); AllEditorGUI.BeginBox(); AllEditorGUI.BeginBoxHeader(); EditorGUILayout.BeginHorizontal(); isToggled.Value = label != null?AllEditorGUI.Foldout(isToggled.Value, label) : AllEditorGUI.Foldout(isToggled.Value, GUIHelper.TempContent("")); if (targetProp.Parent == null) { EditorGUILayout.LabelField("Reference to " + targetProp.Path, SirenixGUIStyles.RightAlignedGreyMiniLabel); } else { EditorGUILayout.LabelField("Reference to " + targetProp.Path, SirenixGUIStyles.RightAlignedGreyMiniLabel); } EditorGUILayout.EndHorizontal(); AllEditorGUI.EndBoxHeader(); if (AllEditorGUI.BeginFadeGroup(UniqueDrawerKey.Create(entry.Property, this), isToggled.Value)) { //EditorGUI.indentLevel++; //GUIHelper.PushGUIEnabled(true); var isInReference = targetProp.Context.GetGlobal("is_in_reference", false); bool previous = isInReference.Value; isInReference.Value = true; InspectorUtilities.DrawProperty(targetProp); isInReference.Value = previous; //GUIHelper.PopGUIEnabled(); //EditorGUI.indentLevel--; } AllEditorGUI.EndFadeGroup(); AllEditorGUI.EndBox(); } else { this.CallNextDrawer(entry.Property, label); } }
/// <summary> /// Draws the property. /// </summary> protected override void DrawPropertyGroupLayout(InspectorProperty property, BoxGroupAttribute attribute, GUIContent label) { var labelGetter = property.Context.Get <StringMemberHelper>(this, "LabelContext", (StringMemberHelper)null); if (labelGetter.Value == null) { labelGetter.Value = new StringMemberHelper(property.ParentType, attribute.GroupName); } AllEditorGUI.BeginBox(attribute.ShowLabel ? labelGetter.Value.GetString(property) : null, attribute.CenterLabel); for (int i = 0; i < property.Children.Count; i++) { InspectorUtilities.DrawProperty(property.Children[i]); } AllEditorGUI.EndBox(); }
/// <summary> /// Draws the property. /// </summary> protected override void DrawPropertyLayout(IPropertyValueEntry <ColorPalette> entry, GUIContent label) { var isEditing = entry.Property.Context.Get(this, "isEditing", false); entry.SmartValue.Name = entry.SmartValue.Name ?? "Palette Name"; AllEditorGUI.BeginBox(); { AllEditorGUI.BeginBoxHeader(); { GUILayout.Label(entry.SmartValue.Name); GUILayout.FlexibleSpace(); if (AllEditorGUI.IconButton(EditorIcons.Pen)) { isEditing.Value = !isEditing.Value; } } AllEditorGUI.EndBoxHeader(); if (entry.SmartValue.Colors == null) { entry.SmartValue.Colors = new List <Color>(); } if (AllEditorGUI.BeginFadeGroup(entry.SmartValue, entry, isEditing.Value)) { this.CallNextDrawer(entry.Property, null); } AllEditorGUI.EndFadeGroup(); if (AllEditorGUI.BeginFadeGroup(entry.SmartValue, entry.SmartValue, isEditing.Value == false)) { Color col = default(Color); var stretch = ColorPaletteManager.Instance.StretchPalette; var size = ColorPaletteManager.Instance.SwatchSize; var margin = ColorPaletteManager.Instance.SwatchSpacing; ColorPaletteAttributeDrawer.DrawColorPaletteColorPicker(entry, entry.SmartValue, ref col, entry.SmartValue.ShowAlpha, stretch, size, 20, margin); } AllEditorGUI.EndFadeGroup(); } AllEditorGUI.EndBox(); }
/// <summary> /// Draws the property. /// </summary> protected override void DrawPropertyGroupLayout(InspectorProperty property, FoldoutGroupAttribute attribute, GUIContent label) { var context = property.Context.Get <FoldoutGroupContext>(this, "FoldoutGroupContext", (FoldoutGroupContext)null); if (context.Value == null) { context.Value = new FoldoutGroupContext() { IsVisible = property.Context.GetPersistent <bool>(this, "IsVisible", attribute.HasDefinedExpanded ? attribute.Expanded : AllEditorGUI.ExpandFoldoutByDefault), TitleHelper = new StringMemberHelper(property.ParentType, attribute.GroupName) }; } if (context.Value.TitleHelper.ErrorMessage != null) { AllEditorGUI.ErrorMessageBox(context.Value.TitleHelper.ErrorMessage); } AllEditorGUI.BeginBox(); { AllEditorGUI.BeginBoxHeader(); var content = GUIHelper.TempContent(context.Value.TitleHelper.GetString(property)); var rect = GUILayoutUtility.GetRect(content, SirenixGUIStyles.Label); context.Value.IsVisible.Value = AllEditorGUI.Foldout(rect, context.Value.IsVisible.Value, content); AllEditorGUI.EndBoxHeader(); if (AllEditorGUI.BeginFadeGroup(context, context.Value.IsVisible.Value)) { for (int i = 0; i < property.Children.Count; i++) { InspectorUtilities.DrawProperty(property.Children[i]); } } AllEditorGUI.EndFadeGroup(); } AllEditorGUI.EndBox(); }
private void EndDrawListElement(int index) { AllEditorGUI.EndBox(); }
private void DrawElements(IPropertyValueEntry <TDictionary> entry, GUIContent label, Context context) { for (int i = context.Paging.StartIndex; i < context.Paging.EndIndex; i++) { var keyValuePairProperty = entry.Property.Children[i]; var keyValuePairEntry = (PropertyDictionaryElementValueEntry <TDictionary, TKey, TValue>)keyValuePairProperty.BaseValueEntry; Rect rect = AllEditorGUI.BeginListItem(false, context.ListItemStyle); { if (context.AttrSettings.DisplayMode != DictionaryDisplayOptions.OneLine) { bool defaultExpanded; switch (context.AttrSettings.DisplayMode) { case DictionaryDisplayOptions.CollapsedFoldout: defaultExpanded = false; break; case DictionaryDisplayOptions.ExpandedFoldout: defaultExpanded = true; break; default: defaultExpanded = AllEditorGUI.ExpandFoldoutByDefault; break; } var isExpanded = keyValuePairProperty.Context.Get(this, "Expanded", defaultExpanded); AllEditorGUI.BeginBox(); AllEditorGUI.BeginBoxHeader(); { if (keyValuePairEntry.HasTempInvalidKey) { GUIHelper.PushColor(Color.red); } var btnRect = GUIHelper.GetCurrentLayoutRect().AlignLeft(HeaderMargin.margin.left); btnRect.y += 1; GUILayout.BeginVertical(HeaderMargin); GUIHelper.PushIsDrawingDictionaryKey(true); GUIHelper.PushLabelWidth(10); InspectorUtilities.DrawProperty(keyValuePairProperty.Children[0], null); GUIHelper.PopLabelWidth(); GUIHelper.PopIsDrawingDictionaryKey(); GUILayout.EndVertical(); if (keyValuePairEntry.HasTempInvalidKey) { GUIHelper.PopColor(); } isExpanded.Value = AllEditorGUI.Foldout(btnRect, isExpanded.Value, GUIHelper.TempContent("Key")); } AllEditorGUI.EndBoxHeader(); if (AllEditorGUI.BeginFadeGroup(isExpanded, isExpanded.Value)) { InspectorUtilities.DrawProperty(keyValuePairProperty.Children[1], null); } AllEditorGUI.EndFadeGroup(); AllEditorGUI.EndBox(); } else { GUILayout.BeginHorizontal(); GUILayout.BeginVertical(GUILayoutOptions.Width(context.KeyWidthOffset)); { var keyProperty = keyValuePairProperty.Children[0]; if (keyValuePairEntry.HasTempInvalidKey) { GUIHelper.PushColor(Color.red); } if (context.AttrSettings.IsReadOnly) { GUIHelper.PushGUIEnabled(false); } GUIHelper.PushIsDrawingDictionaryKey(true); GUIHelper.PushLabelWidth(10); InspectorUtilities.DrawProperty(keyProperty, null); GUIHelper.PopLabelWidth(); GUIHelper.PopIsDrawingDictionaryKey(); if (context.AttrSettings.IsReadOnly) { GUIHelper.PopGUIEnabled(); } if (keyValuePairEntry.HasTempInvalidKey) { GUIHelper.PopColor(); } } GUILayout.EndVertical(); GUILayout.BeginVertical(OneLineMargin); { var valueEntry = keyValuePairProperty.Children[1]; var tmp = GUIHelper.ActualLabelWidth; EditorGUIUtility.labelWidth = 150; InspectorUtilities.DrawProperty(valueEntry, null); EditorGUIUtility.labelWidth = tmp; } GUILayout.EndVertical(); GUILayout.EndHorizontal(); } if (entry.IsEditable && !context.AttrSettings.IsReadOnly && AllEditorGUI.IconButton(new Rect(rect.xMax - 24 + 5, rect.y + 2 + ((int)rect.height - 23) / 2, 14, 14), EditorIcons.X)) { context.DictionaryHandler.Remove(context.DictionaryHandler.GetKey(0, i)); EditorApplication.delayCall += () => context.NewKewIsValid = null; GUIHelper.RequestRepaint(); } } AllEditorGUI.EndListItem(); } if (context.Paging.IsOnLastPage && entry.ValueState == PropertyValueState.CollectionLengthConflict) { AllEditorGUI.BeginListItem(false); GUILayout.Label(GUIHelper.TempContent("------"), EditorStyles.centeredGreyMiniLabel); AllEditorGUI.EndListItem(); } }
/// <summary> /// Draws the property. /// </summary> protected override void DrawPropertyLayout(IPropertyValueEntry <T> entry, GUIContent label) { var isToggled = entry.Property.Context.GetPersistent <bool>(this, "Toggled", AllEditorGUI.ExpandFoldoutByDefault); if (entry.ValueState == PropertyValueState.NullReference) { GUIHelper.PushGUIEnabled(GUI.enabled && entry.IsEditable); try { if (typeof(UnityEngine.Object).IsAssignableFrom(entry.TypeOfValue)) { entry.WeakSmartValue = label == null? EditorGUILayout.ObjectField((UnityEngine.Object) entry.WeakSmartValue, entry.TypeOfValue, entry.Property.Info.GetAttribute <AssetsOnlyAttribute>() == null) : EditorGUILayout.ObjectField(label, (UnityEngine.Object)entry.WeakSmartValue, entry.TypeOfValue, entry.Property.Info.GetAttribute <AssetsOnlyAttribute>() == null); } else { if (entry.SerializationBackend == SerializationBackend.Unity && entry.IsEditable && Event.current.type == EventType.Layout) { Debug.LogError("Unity-backed value is null. This should already be fixed by the FixUnityNullDrawer!"); } else { bool drawWithBox = ShouldDrawReferenceObjectPicker(entry); bool contextValue = isToggled.Value; if (drawWithBox) { AllEditorGUI.BeginBox(); AllEditorGUI.BeginBoxHeader(); { DrawObjectField(entry, label, ref contextValue); } AllEditorGUI.EndBoxHeader(); AllEditorGUI.EndBox(); } else { DrawObjectField(entry, label, ref contextValue, false); } isToggled.Value = contextValue; } } } finally { GUIHelper.PopGUIEnabled(); } } else { if (ShouldDrawReferenceObjectPicker(entry)) { AllEditorGUI.BeginBox(); AllEditorGUI.BeginBoxHeader(); { GUIHelper.PushGUIEnabled(GUI.enabled && entry.IsEditable); bool contextValue = isToggled.Value; DrawObjectField(entry, label, ref contextValue); isToggled.Value = contextValue; GUIHelper.PopGUIEnabled(); } AllEditorGUI.EndBoxHeader(); if (AllEditorGUI.BeginFadeGroup(UniqueDrawerKey.Create(entry, this), isToggled.Value)) { this.CallNextDrawer(entry.Property, null); } AllEditorGUI.EndFadeGroup(); AllEditorGUI.EndBox(); } else { this.CallNextDrawer(entry.Property, label); } } var objectPicker = ObjectPicker.GetObjectPicker(entry, entry.BaseValueType); if (objectPicker.IsReadyToClaim) { var obj = objectPicker.ClaimObject(); entry.Property.Tree.DelayActionUntilRepaint(() => entry.WeakSmartValue = obj); } }