private void DrawDirectlyInlined(GUIContent label, InspectorProperty property) { var size = EditorGUIUtility.singleLineHeight; if (property.ValueEntry.TypeOfValue.GetCustomAttribute <InlinePropertyAttribute>() == null) { SubDraw(); } else { EditorGUILayout.Space(-2f); GUIHelper.PushLabelWidth(GUIHelper.BetterLabelWidth - GUIHelper.CurrentIndentAmount + 3f); SubDraw(); GUIHelper.PopLabelWidth(); EditorGUILayout.Space(5f); } void SubDraw() { EditorGUILayout.BeginHorizontal(); property.Draw(label); if (GUILayout.Button(EditorIcons.X.Active, GUILayout.Width(size), GUILayout.Height(size))) { Property.BaseValueEntry.WeakSmartValue = null; } EditorGUILayout.EndHorizontal(); } }
protected override void DrawPropertyLayout(GUIContent label) { Rect rect = EditorGUILayout.GetControlRect(); if (label != null) { rect = EditorGUI.PrefixLabel(rect, label); } rect = EditorGUILayout.GetControlRect(); GUIHelper.PushLabelWidth(75); text.ValueEntry.WeakSmartValue = SirenixEditorFields.TextField(rect.Split(0, 2), "Text", (string)text.ValueEntry.WeakSmartValue); number.ValueEntry.WeakSmartValue = SirenixEditorFields.IntField(rect.Split(1, 2), "Number", (int)number.ValueEntry.WeakSmartValue); location.Draw(); GUIHelper.PopLabelWidth(); }
public static void DrawPropertyGroupLayout <T>(OdinGroupDrawer <T> ogd, InspectorProperty property, T attribute, GUIContent label, bool result) where T : CrossSceneSideAttribute { if (SirenixEditorGUI.BeginFadeGroup(UniqueDrawerKey.Create(property, ogd), result)) { var labelGetter = property.Context.Get <StringMemberHelper>(ogd, "LabelContext", (StringMemberHelper)null); if (labelGetter.Value == null) { labelGetter.Value = new StringMemberHelper(property, attribute.GroupName); } SirenixEditorGUI.BeginBox(attribute.ShowLabel ? labelGetter.Value.GetString(property) : null, attribute.CenterLabel); for (int i = 0; i < property.Children.Count; i++) { property.Draw(property.Children[i].Label); } SirenixEditorGUI.EndBox(); } SirenixEditorGUI.EndFadeGroup(); }
private void DrawKeyProperty(InspectorProperty keyProperty, GUIContent keyLabel) { EditorGUI.BeginChangeCheck(); #if SIRENIX_INTERNAL var keyValuePairValue = (keyProperty.Parent.ValueEntry as IPropertyValueEntry <EditableKeyValuePair <TKey, TValue> >).SmartValue; if (keyValuePairValue.IsTempKey && !keyValuePairValue.IsInvalidKey) { GUIHelper.PushColor(Color.green); } #endif keyProperty.Draw(keyLabel); #if SIRENIX_INTERNAL if (keyValuePairValue.IsTempKey && !keyValuePairValue.IsInvalidKey) { GUIHelper.PopColor(); } #endif var guiChanged = EditorGUI.EndChangeCheck(); bool valuesAreDirty = ValuesAreDirty(keyProperty); if (!guiChanged && valuesAreDirty) { this.dictionaryResolver.ValueApplyIsTemporary = true; ApplyChangesToProperty(keyProperty); this.dictionaryResolver.ValueApplyIsTemporary = false; } else if (guiChanged && !valuesAreDirty) { MarkPropertyDirty(keyProperty); } }
private Rect DrawItem(InspectorProperty itemProperty, DragHandle dragHandle, int index = -1) { var listItemInfo = itemProperty.Context.Get <ListItemInfo>(this, "listItemInfo"); Rect rect; rect = SirenixEditorGUI.BeginListItem(false, info.ListItemStyle, listItemOptions); { if (Event.current.type == EventType.Repaint && !info.IsReadOnly) { listItemInfo.Value.Width = rect.width; dragHandle.DragHandleRect = new Rect(rect.x + 4, rect.y, 20, rect.height); listItemInfo.Value.DragHandleRect = new Rect(rect.x + 4, rect.y + 2 + ((int)rect.height - 23) / 2, 20, 20); listItemInfo.Value.RemoveBtnRect = new Rect(listItemInfo.Value.DragHandleRect.x + rect.width - 22, listItemInfo.Value.DragHandleRect.y + 1, 14, 14); if (info.HideRemoveButton == false) { } if (info.Draggable) { GUI.Label(listItemInfo.Value.DragHandleRect, EditorIcons.List.Inactive, GUIStyle.none); } } GUIHelper.PushHierarchyMode(false); GUIContent label = null; if (info.CustomListDrawerOptions.ShowIndexLabelsHasValue) { if (info.CustomListDrawerOptions.ShowIndexLabels) { label = new GUIContent(index.ToString()); } } else if (info.ListConfig.ShowIndexLabels) { label = new GUIContent(index.ToString()); } if (info.GetListElementLabelText != null) { var value = itemProperty.ValueEntry.WeakSmartValue; if (object.ReferenceEquals(value, null)) { if (label == null) { label = new GUIContent("Null"); } else { label.text += " : Null"; } } else { label = label ?? new GUIContent(""); if (label.text != "") { label.text += " : "; } object text = info.GetListElementLabelText(value); label.text += (text == null ? "" : text.ToString()); } } if (info.OnBeginListElementGUI != null) { info.OnBeginListElementGUI(info.Property.ParentValues[0], index); } itemProperty.Draw(label); if (info.OnEndListElementGUI != null) { info.OnEndListElementGUI(info.Property.ParentValues[0], index); } GUIHelper.PopHierarchyMode(); if (info.IsReadOnly == false && info.HideRemoveButton == false) { if (SirenixEditorGUI.IconButton(listItemInfo.Value.RemoveBtnRect, EditorIcons.X)) { if (info.OrderedCollectionResolver != null) { if (index >= 0) { info.RemoveAt = index; } } else { var values = new object[itemProperty.ValueEntry.ValueCount]; for (int i = 0; i < values.Length; i++) { values[i] = itemProperty.ValueEntry.WeakValues[i]; } info.RemoveValues = values; } } } } SirenixEditorGUI.EndListItem(); return(rect); }
protected override void OnGUI() { _repaintSheduled = false; GUILayout.BeginHorizontal(); if (GUILayout.Button("Clear")) { _properties.Clear(); } Rect settingsRect = GUILayoutUtility.GetRect(24, 24, GUILayout.ExpandWidth(false)).AlignLeft(20).AlignCenterY(20); if (SirenixEditorGUI.IconButton(settingsRect, _showSettings ? EditorIcons.SettingsCog.Inactive : EditorIcons.SettingsCog.Active, "Settings")) { _showSettings = !_showSettings; } GUILayout.EndHorizontal(); if (_showSettings) { GUILayout.BeginHorizontal(); GUILayout.Space(40); GUI.changed = false; Rect rect = GUILayoutUtility.GetRect(1, EditorGUIUtility.singleLineHeight, GUILayout.ExpandWidth(true)); _labelWidth = GUI.HorizontalSlider(rect, _labelWidth, rect.xMin, rect.xMax); if (GUI.changed) { EditorPrefs.SetFloat("OWW_labelWidth", _labelWidth); } EditorGUILayout.LabelField("Label Width", GUILayout.Width(70)); GUILayout.EndHorizontal(); } GUILayout.Space(5); bool first = true; if (_properties.Count == 0) { EditorGUILayout.LabelField("Right-click any property in an Inspector and select 'Watch' to make it show up here.", SirenixGUIStyles.MultiLineCenteredLabel); } GUIHelper.PushLabelWidth(_labelWidth - 30); for (int i = 0; i < _properties.Count; i++) { TreeValuesHolder holder = _properties[i]; holder.CheckRefresh(); if (!first) { GUILayout.Space(5); } first = false; Rect titleRect = SirenixEditorGUI.BeginBox(" " + holder.Tree.TargetType.Name); titleRect = titleRect.AlignTop(21); if (holder.ParentObject != null) { Rect alignRight = titleRect.AlignRight(200).AlignCenterY(16).AlignLeft(180); GUIHelper.PushGUIEnabled(false); SirenixEditorFields.UnityObjectField(alignRight, holder.ParentObject, typeof(GameObject), true); GUIHelper.PopGUIEnabled(); } if (SirenixEditorGUI.IconButton(titleRect.AlignRight(20).AlignCenterY(18), EditorIcons.X)) { _properties.RemoveAt(i--); } Rect titleDragDropRect = titleRect.AlignLeft(30).AlignCenter(20, 20); EditorIcons.List.Draw(titleDragDropRect); TreeValuesHolder treedragdrop = (TreeValuesHolder)DragAndDropUtilities.DragAndDropZone(titleDragDropRect, holder, typeof(TreeValuesHolder), false, false); if (treedragdrop != holder) { int treeDragDropIndex = _properties.IndexOf(treedragdrop); Swap(_properties, treeDragDropIndex, i); } if (holder.Tree.UnitySerializedObject?.targetObject == null) { EditorGUILayout.LabelField($"This component is no longer valid in the current context (loaded different scene?)", SirenixGUIStyles.MultiLineLabel); } else { InspectorUtilities.BeginDrawPropertyTree(holder.Tree, true); for (int index = 0; index < holder.ValuePaths.Count; index++) { string path = holder.ValuePaths[index]; GUILayout.BeginHorizontal(); Rect rect1 = GUILayoutUtility.GetRect(EditorGUIUtility.singleLineHeight + 5, EditorGUIUtility.singleLineHeight + 3, GUILayout.ExpandWidth(false)).AlignRight(EditorGUIUtility.singleLineHeight + 2); EditorIcons.List.Draw(rect1); ValueDragDropHolder dragdrop = (ValueDragDropHolder)DragAndDropUtilities.DragAndDropZone(rect1, new ValueDragDropHolder(holder, index), typeof(ValueDragDropHolder), false, false); if (dragdrop.TreeValuesHolder == holder && dragdrop.Index != index) { string ptemp = holder.ValuePaths[index]; holder.ValuePaths[index] = holder.ValuePaths[dragdrop.Index]; holder.ValuePaths[dragdrop.Index] = ptemp; } InspectorProperty propertyAtPath = holder.Tree.GetPropertyAtPath(path); if (propertyAtPath == null) { propertyAtPath = holder.Tree.GetPropertyAtUnityPath(path); } if (propertyAtPath != null) { propertyAtPath.Draw(); } else { EditorGUILayout.LabelField($"Could not find property ({path})"); } if (SirenixEditorGUI.IconButton(EditorIcons.X)) { holder.ValuePaths.RemoveAt(index--); if (holder.ValuePaths.Count == 0) { _properties.RemoveAt(i--); } } GUILayout.Space(3); GUILayout.EndHorizontal(); } InspectorUtilities.EndDrawPropertyTree(holder.Tree); } SirenixEditorGUI.EndBox(); } GUIHelper.PopLabelWidth(); }