//private object rawPrevGettedValue = null; //private int rawPrevGettedValueCount = 0; /// <summary> /// Initializes this instance. /// </summary> protected override void Initialize() { this.rawGetter = new InspectorPropertyValueGetter <object>(this.Property, this.Attribute.MemberName); this.isToggled = this.GetPersistentValue("Toggled", SirenixEditorGUI.ExpandFoldoutByDefault); this.error = this.rawGetter.ErrorMessage; this.isList = this.Property.ChildResolver as ICollectionResolver != null; this.getSelection = () => this.Property.ValueEntry.WeakValues.Cast <object>(); this.getValues = () => { var value = this.rawGetter.GetValue(); return(value == null ? null : (this.rawGetter.GetValue() as IEnumerable) .Cast <object>() .Where(x => x != null) .Select(x => { if (x is ValueDropdownItem) { return (ValueDropdownItem)x; } if (x is IValueDropdownItem) { var ix = x as IValueDropdownItem; return new ValueDropdownItem(ix.GetText(), ix.GetValue()); } return new ValueDropdownItem(null, x); })); }; this.ReloadDropdownCollections(); }
protected override void Initialize() { listItemStyle = new GUIStyle(GUIStyle.none) { padding = new RectOffset(7, 20, 3, 3) }; var entry = this.ValueEntry; this.toggled = this.GetPersistentValue("Toggled", GeneralDrawerConfig.Instance.OpenListsByDefault); this.keyWidthOffset = 130; this.label = this.Property.Label ?? new GUIContent(typeof(TDictionary).GetNiceName()); this.attrSettings = entry.Property.Info.GetAttribute <DictionaryDrawerSettings>() ?? new DictionaryDrawerSettings(); this.disableAddKey = entry.Property.Tree.PrefabModificationHandler.HasPrefabs && !entry.Property.SupportsPrefabModifications; this.keyLabel = new GUIContent(this.attrSettings.KeyLabel); this.valueLabel = new GUIContent(this.attrSettings.ValueLabel); this.keyLabelWidth = EditorStyles.label.CalcSize(this.keyLabel).x + 20; this.valueLabelWidth = EditorStyles.label.CalcSize(this.valueLabel).x + 20; if (!this.disableAddKey) { this.tempKeyValue = new TempKeyValuePair <TKey, TValue>(); var tree = PropertyTree.Create(this.tempKeyValue); tree.UpdateTree(); this.tempKeyEntry = (IPropertyValueEntry <TKey>)tree.GetPropertyAtPath("Key").ValueEntry; this.tempValueEntry = (IPropertyValueEntry <TValue>)tree.GetPropertyAtPath("Value").ValueEntry; } }
protected override void Initialize() { this.tabGroup = SirenixEditorGUI.CreateAnimatedTabGroup(this.Property); this.currentPage = this.GetPersistentValue <int>("CurrentPage", 0); this.tabs = new List <Tab>(); var addLastTabs = new List <Tab>(); for (int j = 0; j < this.Property.Children.Count; j++) { var child = this.Property.Children[j]; var added = false; if (child.Info.PropertyType == PropertyType.Group) { var attrType = child.GetAttribute <PropertyGroupAttribute>().GetType(); if (attrType.IsNested && attrType.DeclaringType == typeof(TabGroupAttribute)) { // This is a tab subgroup; add all its children to a tab for that subgroup var tab = new Tab(); tab.TabName = child.NiceName; tab.Title = new StringMemberHelper(this.Property, child.Name.TrimStart('#')); for (int i = 0; i < child.Children.Count; i++) { tab.InspectorProperties.Add(child.Children[i]); } this.tabs.Add(tab); added = true; } } if (!added) { // This is a group member of the tab group itself, so it gets its own tab var tab = new Tab(); tab.TabName = child.NiceName; tab.Title = new StringMemberHelper(this.Property, child.Name.TrimStart('#')); tab.InspectorProperties.Add(child); addLastTabs.Add(tab); } } foreach (var tab in addLastTabs) { this.tabs.Add(tab); } for (int i = 0; i < this.tabs.Count; i++) { this.tabGroup.RegisterTab(this.tabs[i].TabName); } var currentTab = this.tabs[this.currentPage.Value]; var selectedTabGroup = this.tabGroup.RegisterTab(currentTab.TabName); this.tabGroup.SetCurrentPage(selectedTabGroup); }
/// <summary> /// Draws the property. /// </summary> protected override void DrawPropertyLayout(GUIContent label) { var property = this.Property; if (property.Children.Count == 0) { if (property.ValueEntry != null) { if (label != null) { var rect = EditorGUILayout.GetControlRect(); GUI.Label(rect, label); } } else { GUILayout.BeginHorizontal(); { if (label != null) { EditorGUILayout.PrefixLabel(label); } SirenixEditorGUI.WarningMessageBox("There is no drawer defined for property " + property.NiceName + " of type " + property.Info.PropertyType + "."); } GUILayout.EndHorizontal(); } return; } if (label == null) { for (int i = 0; i < property.Children.Count; i++) { var child = property.Children[i]; child.Draw(child.Label); } } else { if (this.isVisisble == null) { this.isVisisble = property.Context.GetPersistent(this, "IsVisible", SirenixEditorGUI.ExpandFoldoutByDefault); } this.isVisisble.Value = SirenixEditorGUI.Foldout(this.isVisisble.Value, label); if (SirenixEditorGUI.BeginFadeGroup(this, this.isVisisble.Value)) { EditorGUI.indentLevel++; for (int i = 0; i < property.Children.Count; i++) { var child = property.Children[i]; child.Draw(child.Label); } EditorGUI.indentLevel--; } SirenixEditorGUI.EndFadeGroup(); } }
/// <summary> /// Gets a LocalPersistentContext object for the specified keys. /// Returns <c>true</c> when the context is first created. Otherwise <c>false</c>. /// </summary> /// <typeparam name="TKey1">The type of the first key.</typeparam> /// <typeparam name="TKey2">The type of the second key.</typeparam> /// <typeparam name="TKey3">The type of the third key.</typeparam> /// <typeparam name="TKey4">The type of the fourth key.</typeparam> /// <typeparam name="TKey5">The type of the fifth key.</typeparam> /// <typeparam name="TValue">The type of the value stored in the context object.</typeparam> /// <param name="alphaKey">The first key.</param> /// <param name="betaKey">The second key.</param> /// <param name="gammaKey">The third key.</param> /// <param name="deltaKey">The fourth key.</param> /// <param name="epsilonKey">The fifth key.</param> /// <param name="context">The persistent context object.</param> /// <returns>Returns <c>true</c> when the context is first created. Otherwise <c>false</c>.</returns> public static bool GetLocal <TKey1, TKey2, TKey3, TKey4, TKey5, TValue>(TKey1 alphaKey, TKey2 betaKey, TKey3 gammaKey, TKey4 deltaKey, TKey5 epsilonKey, out LocalPersistentContext <TValue> context) { GlobalPersistentContext <TValue> global; bool isNew = Get(alphaKey, betaKey, gammaKey, deltaKey, epsilonKey, out global); context = LocalPersistentContext <TValue> .Create(global); return(isNew); }
/// <summary> /// Gets a LocalPersistentContext object for the specified key. /// Returns <c>true</c> when the context is first created. Otherwise <c>false</c>. /// </summary> /// <typeparam name="TKey1">The type of the first key.</typeparam> /// <typeparam name="TValue">The type of the value stored in the context object.</typeparam> /// <param name="alphaKey">The first key.</param> /// <param name="context">The persistent context object.</param> /// <returns>Returns <c>true</c> when the context is first created. Otherwise <c>false</c>.</returns> public static bool GetLocal <TKey1, TValue>(TKey1 alphaKey, out LocalPersistentContext <TValue> context) { GlobalPersistentContext <TValue> global; bool isNew = Get <TKey1, TValue>(alphaKey, out global); context = LocalPersistentContext <TValue> .Create(global); return(isNew); }
protected override void Initialize() { this.isToggled = LocalPersistentContext <bool> .Create(PersistentContext.Get(this.Property.Path, SirenixEditorGUI.ExpandFoldoutByDefault)); this.drawUnityObject = typeof(UnityEngine.Object).IsAssignableFrom(this.ValueEntry.TypeOfValue); this.allowSceneObjects = this.Property.GetAttribute <AssetsOnlyAttribute>() == null; this.bakedDrawerArray = this.Property.GetActiveDrawerChain().BakedDrawerArray; this.inlinePropertyAttr = this.Property.Attributes.GetAttribute <InlinePropertyAttribute>(); }
/// <summary> /// Initializes this instance. /// </summary> protected override void Initialize() { this.expanded = false; this.buttonAttribute = this.Property.GetAttribute <ButtonAttribute>(); this.buttonHeight = this.Property.Context.GetGlobal("ButtonHeight", 0).Value; this.style = this.Property.Context.GetGlobal("ButtonStyle", (GUIStyle)null).Value; this.toggle = this.GetPersistentValue <bool>("toggle", false); this.hasGUIColorAttribute = this.Property.GetAttribute <GUIColorAttribute>() != null; this.drawParameters = this.Property.Children.Count > 0 && !DontDrawMethodParamaters; this.name = this.Property.NiceName; this.label = new GUIContent(name); if (buttonAttribute != null) { this.btnStyle = this.buttonAttribute.Style; this.expanded = buttonAttribute.Expanded; if (!string.IsNullOrEmpty(this.buttonAttribute.Name)) { this.mh = new StringMemberHelper(this.Property, this.buttonAttribute.Name); } if (this.buttonHeight == 0 && buttonAttribute.ButtonHeight > 0) { this.buttonHeight = buttonAttribute.ButtonHeight; } } if (this.style == null) { if (this.buttonHeight > 20) { this.style = SirenixGUIStyles.Button; } else { this.style = EditorStyles.miniButton; } } if (this.drawParameters && this.btnStyle == ButtonStyle.FoldoutButton && !this.expanded) { if (this.buttonHeight > 20) { this.style = SirenixGUIStyles.ButtonLeft; this.toggleBtnStyle = SirenixGUIStyles.ButtonRight; } else { this.style = EditorStyles.miniButtonLeft; this.toggleBtnStyle = EditorStyles.miniButtonRight; } } }
/// <summary> /// Initializes this instance. /// </summary> protected override void Initialize() { this.drawAsList = false; this.isReadOnly = this.Attribute.IsReadOnly || !this.Property.ValueEntry.IsEditable; this.indexLabelWidth = (int)SirenixGUIStyles.Label.CalcSize(new GUIContent("100")).x + 15; this.indexLabel = new GUIContent(); this.colOffset = 0; this.seenColumnNames = new HashSet <string>(); this.table = new GUITableRowLayoutGroup(); this.table.MinScrollViewHeight = this.Attribute.MinScrollViewHeight; this.table.MaxScrollViewHeight = this.Attribute.MaxScrollViewHeight; this.resolver = this.Property.ChildResolver as IOrderedCollectionResolver; this.isVisible = this.GetPersistentValue("toggle", GeneralDrawerConfig.Instance.ExpandFoldoutByDefault); this.scrollPos = this.GetPersistentValue("scrollPos", Vector2.zero); this.currPage = this.GetPersistentValue("currPage", 0); this.isPagingExpanded = this.GetPersistentValue("expanded", false); this.columns = new List <Column>(10); this.paging = new GUIPagingHelper(); this.paging.NumberOfItemsPerPage = this.Attribute.NumberOfItemsPerPage > 0 ? this.Attribute.NumberOfItemsPerPage : GeneralDrawerConfig.Instance.NumberOfItemsPrPage; this.paging.IsExpanded = this.isPagingExpanded.Value; this.paging.IsEnabled = GeneralDrawerConfig.Instance.ShowPagingInTables || this.Attribute.ShowPaging; this.paging.CurrentPage = this.currPage.Value; this.Property.ValueEntry.OnChildValueChanged += OnChildValueChanged; if (this.Attribute.AlwaysExpanded) { this.isVisible.Value = true; } var p = this.Attribute.CellPadding; if (p > 0) { this.table.CellStyle = new GUIStyle() { padding = new RectOffset(p, p, p, p) }; } GUIHelper.RequestRepaint(3); if (this.Attribute.ShowIndexLabels) { this.colOffset++; this.columns.Add(new Column(this.indexLabelWidth, true, false, null, ColumnType.Index)); } if (!this.isReadOnly) { this.columns.Add(new Column(22, true, false, null, ColumnType.DeleteButton)); } }
protected override void Initialize() { this.menuTreeWidth = this.GetPersistentValue <float>("menuTreeWidth", 320); this.overviewHeight = this.GetPersistentValue <float>("overviewHeight", 300); this.columns = new List <ResizableColumn>() { ResizableColumn.FlexibleColumn(this.menuTreeWidth.Value, 80), ResizableColumn.DynamicColumn(0, 200) }; this.runner = new ValidationRunner(); this.overview = new ValidationOverview(); this.editor = this.ValueEntry.SmartValue; this.profile = this.editor.Profile; this.sourceProperty = this.Property.Children["selectedSourceTarget"]; this.validationProfileTree = new ValidationProfileTree(); this.overviewToggle = this.GetPersistentValue <bool>("overviewToggle", true); this.validationProfileTree.Selection.SelectionChanged += (x) => { if (x == SelectionChangedType.ItemAdded) { var value = this.validationProfileTree.Selection.SelectedValue; var result = value as ValidationProfileResult; if (result != null) { this.editor.SetTarget(result.GetSource()); } else { this.editor.SetTarget(value); } } }; this.overview.OnProfileResultSelected += result => { var mi = this.validationProfileTree.GetMenuItemForObject(result); mi.Select(); var source = result.GetSource(); this.editor.SetTarget(source); }; this.validationProfileTree.AddProfileRecursive(this.ValueEntry.SmartValue.Profile); OdinMenuTree.ActiveMenuTree = this.validationProfileTree; if (this.editor.ScanProfileImmediatelyWhenOpening) { this.editor.ScanProfileImmediatelyWhenOpening = false; this.ScanProfile(this.editor.Profile); } }
/// <summary> /// Initializes the drawer. /// </summary> protected override void Initialize() { this.PaletteIndex = 0; this.CurrentName = this.Attribute.PaletteName; this.ShowAlpha = this.Attribute.ShowAlpha; this.Names = ColorPaletteManager.Instance.ColorPalettes.Select(x => x.Name).ToArray(); if (this.Attribute.PaletteName == null) { this.PersistentName = this.ValueEntry.Context.GetPersistent <string>(this, "ColorPaletteName", null); var list = this.Names.ToList(); this.CurrentName = this.PersistentName.Value; if (this.CurrentName != null && list.Contains(this.CurrentName)) { this.PaletteIndex = list.IndexOf(this.CurrentName); } } else { this.NameGetter = new StringMemberHelper(this.Property, this.Attribute.PaletteName); } }
protected override void Initialize() { expanded = this.GetPersistentValue <bool>("AutoTableAttributeDrawer.expanded", this.Attribute.expanded); }
/// <summary> /// Initializes this instance. /// </summary> protected override void Initialize() { IsVisible = this.GetPersistentValue("IsVisible", this.Attribute.HasDefinedExpanded ? this.Attribute.Expanded : SirenixEditorGUI.ExpandFoldoutByDefault); this.TitleHelper = new StringMemberHelper(this.Property, this.Attribute.GroupName); this.t = this.IsVisible.Value ? 1 : 0; }
protected override void Initialize() { this.isExpanded = this.GetPersistentValue <bool>("ColorFoldoutGroupAttributeDrawer.isExpanded", GeneralDrawerConfig.Instance.ExpandFoldoutByDefault); }
/// <summary> /// Draws the property. /// </summary> protected override void DrawPropertyLayout(GUIContent label) { var property = this.Property; var attribute = this.Attribute; var tabGroup = SirenixEditorGUI.CreateAnimatedTabGroup(property); tabGroup.AnimationSpeed = 1 / SirenixEditorGUI.TabPageSlideAnimationDuration; tabGroup.FixedHeight = attribute.UseFixedHeight; LocalPersistentContext <int> persistentPageContext = property.Context.GetPersistent(this, "CurrentPage", 0); bool setPersistentPage = false; PropertyContext <List <Tab> > tabs; if (property.Context.Get(this, "Tabs", out tabs)) { setPersistentPage = true; tabs.Value = new List <Tab>(); var addLastTabs = new List <Tab>(); for (int j = 0; j < property.Children.Count; j++) { var child = property.Children[j]; bool added = false; if (child.Info.PropertyType == PropertyType.Group) { var attrType = child.GetAttribute <PropertyGroupAttribute>().GetType(); if (attrType.IsNested && attrType.DeclaringType == typeof(TabGroupAttribute)) { // This is a tab subgroup; add all its children to a tab for that subgroup Tab tab = new Tab(); tab.TabName = child.NiceName; tab.Title = new StringMemberHelper(property, child.Name.TrimStart('#')); for (int i = 0; i < child.Children.Count; i++) { tab.InspectorProperties.Add(child.Children[i]); } tabs.Value.Add(tab); added = true; } } if (!added) { // This is a group member of the tab group itself, so it gets its own tab Tab tab = new Tab(); tab.TabName = child.NiceName; tab.Title = new StringMemberHelper(property, child.Name.TrimStart('#')); tab.InspectorProperties.Add(child); addLastTabs.Add(tab); } } foreach (var tab in addLastTabs) { tabs.Value.Add(tab); } } for (int i = 0; i < tabs.Value.Count; i++) { tabGroup.RegisterTab(tabs.Value[i].TabName); } if (setPersistentPage) { if (persistentPageContext.Value >= tabs.Value.Count || persistentPageContext.Value < 0) { persistentPageContext.Value = 0; } tabGroup.SetCurrentPage(tabGroup.RegisterTab(tabs.Value[persistentPageContext.Value].TabName)); } SirenixEditorGUI.BeginIndentedVertical(SirenixGUIStyles.PropertyPadding); tabGroup.BeginGroup(true, attribute.Paddingless ? GUIStyle.none : null); for (int i = 0; i < tabs.Value.Count; i++) { var page = tabGroup.RegisterTab(tabs.Value[i].TabName); page.Title = tabs.Value[i].Title.GetString(property); if (page.BeginPage()) { persistentPageContext.Value = i; int pageCount = tabs.Value[i].InspectorProperties.Count; for (int j = 0; j < pageCount; j++) { var child = tabs.Value[i].InspectorProperties[j]; child.Update(); // Since the property is not fetched through the property system, ensure it's updated before drawing it. child.Draw(child.Label); } } page.EndPage(); } tabGroup.EndGroup(); SirenixEditorGUI.EndIndentedVertical(); }
/// <summary> /// Gets a LocalPersistentContext object for the specified keys. /// </summary> /// <typeparam name="TKey1">The type of the first key.</typeparam> /// <typeparam name="TKey2">The type of the second key.</typeparam> /// <typeparam name="TValue">The type of the value stored in the context object.</typeparam> /// <param name="alphaKey">The first key.</param> /// <param name="betaKey">The second key.</param> /// <param name="defaultValue">The default value, used for when the context object is first created.</param> public static LocalPersistentContext <TValue> GetLocal <TKey1, TKey2, TValue>(TKey1 alphaKey, TKey2 betaKey, TValue defaultValue) { return(LocalPersistentContext <TValue> .Create(Get <TKey1, TKey2, TValue>(alphaKey, betaKey, defaultValue))); }
protected override void Initialize() { this.isToggled = this.GetPersistentValue("is_Toggled", false); this.hideReferenceBox = this.Property.Attributes.HasAttribute <HideDuplicateReferenceBoxAttribute>(); }
/// <summary> /// Gets a LocalPersistentContext object for the specified keys. /// </summary> /// <typeparam name="TKey1">The type of the first key.</typeparam> /// <typeparam name="TKey2">The type of the second key.</typeparam> /// <typeparam name="TKey3">The type of the third key.</typeparam> /// <typeparam name="TKey4">The type of the fourth key.</typeparam> /// <typeparam name="TKey5">The type of the fifth key.</typeparam> /// <typeparam name="TValue">The type of the value stored in the context object.</typeparam> /// <param name="alphaKey">The first key.</param> /// <param name="betaKey">The second key.</param> /// <param name="gammaKey">The third key.</param> /// <param name="deltaKey">The fourth key.</param> /// <param name="epsilonKey">The fifth key.</param> /// <param name="defaultValue">The default value, used for when the context object is first created.</param> public static LocalPersistentContext <TValue> GetLocal <TKey1, TKey2, TKey3, TKey4, TKey5, TValue>(TKey1 alphaKey, TKey2 betaKey, TKey3 gammaKey, TKey4 deltaKey, TKey5 epsilonKey, TValue defaultValue) { return(LocalPersistentContext <TValue> .Create(Get <TKey1, TKey2, TKey3, TKey4, TKey5, TValue>(alphaKey, betaKey, gammaKey, deltaKey, epsilonKey, defaultValue))); }
protected override void Initialize() { this.visible = this.Property.Context.GetPersistent(this, "expanded", GeneralDrawerConfig.Instance.OpenListsByDefault); }