private void DrawDropdown() { IEnumerable <object> newResult = null; if (!this.isList) { GUILayout.BeginHorizontal(); { var width = 15f; if (this.label != null) { width += GUIHelper.BetterLabelWidth; } newResult = GenericSelector <object> .DrawSelectorDropdown(this.label, GUIContent.none, this.ShowSelector, GUIStyle.none, GUILayoutOptions.Width(width)); if (Event.current.type == EventType.Repaint) { var btnRect = GUILayoutUtility.GetLastRect().AlignRight(15); btnRect.y += 4; SirenixGUIStyles.PaneOptions.Draw(btnRect, GUIContent.none, 0); } GUILayout.BeginVertical(); this.CallNextDrawer(null); GUILayout.EndVertical(); } GUILayout.EndHorizontal(); } else { string valueName = this.GetCurrentValueName(); newResult = GenericSelector <object> .DrawSelectorDropdown(this.label, valueName, this.ShowSelector); } if (newResult != null && newResult.Any()) { this.AddResult(newResult); } }
private void DrawDropdown() { EditorGUI.BeginChangeCheck(); IEnumerable <object> newResult = null; string valueName = GetCurrentValueName(); if (this.Property.Children.Count > 0) { Rect valRect; this.isToggled.Value = SirenixEditorGUI.Foldout(this.isToggled.Value, this.label, out valRect); newResult = GenericSelector <object> .DrawSelectorDropdown(valRect, valueName, this.ShowSelector); if (SirenixEditorGUI.BeginFadeGroup(this, this.isToggled.Value)) { EditorGUI.indentLevel++; for (int i = 0; i < this.Property.Children.Count; i++) { var child = this.Property.Children[i]; child.Draw(child.Label); } EditorGUI.indentLevel--; } SirenixEditorGUI.EndFadeGroup(); } else { newResult = GenericSelector <object> .DrawSelectorDropdown(this.label, valueName, this.ShowSelector); } if (EditorGUI.EndChangeCheck()) { if (newResult != null) { this.AddResult(newResult); } } }
private void DrawDropdown() { IEnumerable <object> newResult = null; //if (this.Attribute.InlineSelector) //{ // bool recreateBecauseOfListChange = false; // if (Event.current.type == EventType.Layout) // { // var _newCol = this.rawGetter.GetValue(); // if (_newCol != this.rawPrevGettedValue) // { // this.ReloadDropdownCollections(); // recreateBecauseOfListChange = true; // } // var iList = _newCol as IList; // if (iList != null) // { // if (iList.Count != this.rawPrevGettedValueCount) // { // this.ReloadDropdownCollections(); // recreateBecauseOfListChange = true; // } // this.rawPrevGettedValueCount = iList.Count; // } // this.rawPrevGettedValue = _newCol; // } // if (this.inlineSelector == null || recreateBecauseOfListChange) // { // this.inlineSelector = this.CreateSelector(); // this.inlineSelector.SelectionChanged += (x) => // { // this.nextResult = x; // }; // } // this.inlineSelector.OnInspectorGUI(); // if (this.nextResult != null) // { // newResult = this.nextResult; // this.nextResult = null; // } //} //else if (this.Attribute.AppendNextDrawer && !this.isList) if (this.Attribute.AppendNextDrawer && !this.isList) { GUILayout.BeginHorizontal(); { var width = 15f; if (this.label != null) { width += GUIHelper.BetterLabelWidth; } newResult = GenericSelector <object> .DrawSelectorDropdown(this.label, GUIContent.none, this.ShowSelector, GUIStyle.none, GUILayoutOptions.Width(width)); if (Event.current.type == EventType.Repaint) { var btnRect = GUILayoutUtility.GetLastRect().AlignRight(15); btnRect.y += 4; SirenixGUIStyles.PaneOptions.Draw(btnRect, GUIContent.none, 0); } GUILayout.BeginVertical(); bool disable = this.Attribute.DisableGUIInAppendedDrawer; if (disable) { GUIHelper.PushGUIEnabled(false); } this.CallNextDrawer(null); if (disable) { GUIHelper.PopGUIEnabled(); } GUILayout.EndVertical(); } GUILayout.EndHorizontal(); } else { string valueName = GetCurrentValueName(); if (this.Attribute.HideChildProperties == false && this.Property.Children.Count > 0) { Rect valRect; this.isToggled.Value = SirenixEditorGUI.Foldout(this.isToggled.Value, this.label, out valRect); newResult = GenericSelector <object> .DrawSelectorDropdown(valRect, valueName, this.ShowSelector); if (SirenixEditorGUI.BeginFadeGroup(this, this.isToggled.Value)) { EditorGUI.indentLevel++; for (int i = 0; i < this.Property.Children.Count; i++) { var child = this.Property.Children[i]; child.Draw(child.Label); } EditorGUI.indentLevel--; } SirenixEditorGUI.EndFadeGroup(); } else { newResult = GenericSelector <object> .DrawSelectorDropdown(this.label, valueName, this.ShowSelector); } } if (newResult != null && newResult.Any()) { this.AddResult(newResult); } }
protected override void DrawPropertyLayout(GUIContent label) { if (!this.rootIsComponent) { // Serialization root is not a Component, so it has no children. // Should we display a warning or an error here? this.CallNextDrawer(label); return; } if (this.rootCount > 1) { // TODO: Add support for multi-selection to the child-selector dropdown. this.CallNextDrawer(label); return; } if (this.isList) { var prev = CollectionDrawerStaticInfo.NextCustomAddFunction; CollectionDrawerStaticInfo.NextCustomAddFunction = ListAddButton; this.CallNextDrawer(label); CollectionDrawerStaticInfo.NextCustomAddFunction = prev; return; } // If we want it to validate the value each frame. // if (Event.current.type == EventType.Layout) // { // this.ValidateCurrentValue(); // } if (!this.isValidValues) { SirenixEditorGUI.ErrorMessageBox("The object must be a child of the selected GameObject."); } GUILayout.BeginHorizontal(); { var width = 15f; if (label != null) { width += GUIHelper.BetterLabelWidth; } var newResult = GenericSelector <UnityEngine.Object> .DrawSelectorDropdown(label, GUIContent.none, this.ShowSelector, GUIStyle.none, GUILayoutOptions.Width(width)); if (newResult != null && newResult.Any()) { this.ValueEntry.SmartValue = newResult.FirstOrDefault() as T; } if (Event.current.type == EventType.Repaint) { var btnRect = GUILayoutUtility.GetLastRect().AlignRight(15); btnRect.y += 4; SirenixGUIStyles.PaneOptions.Draw(btnRect, GUIContent.none, 0); } GUILayout.BeginVertical(); this.CallNextDrawer(null); GUILayout.EndVertical(); } GUILayout.EndHorizontal(); }