/// <summary>
        /// Draws the property.
        /// </summary>
        protected override void DrawPropertyLayout(GUIContent label)
        {
            if (this.helper.ErrorMessage != null)
            {
                SirenixEditorGUI.ErrorMessageBox(this.helper.ErrorMessage);
                this.CallNextDrawer(label);
            }
            else
            {
                bool result = this.helper.GetValue(this.Attribute.Value);

                if (this.Attribute.Animate)
                {
                    if (SirenixEditorGUI.BeginFadeGroup(UniqueDrawerKey.Create(this.Property, this), !result))
                    {
                        this.CallNextDrawer(label);
                    }
                    SirenixEditorGUI.EndFadeGroup();
                }
                else
                {
                    if (!result)
                    {
                        this.CallNextDrawer(label);
                    }
                }
            }
        }
        /// <summary>
        /// Draws the property.
        /// </summary>
        protected override void DrawPropertyLayout(GUIContent label)
        {
            var property  = this.Property;
            var attribute = this.Attribute;

            if (this.TitleHelper.ErrorMessage != null)
            {
                SirenixEditorGUI.ErrorMessageBox(this.TitleHelper.ErrorMessage);
            }

            SirenixEditorGUI.BeginBox();
            SirenixEditorGUI.BeginBoxHeader();
            var content = GUIHelper.TempContent(this.TitleHelper.GetString(property));

            this.IsVisible.Value = SirenixEditorGUI.Foldout(this.IsVisible.Value, content);
            SirenixEditorGUI.EndBoxHeader();
            if (Event.current.type == EventType.Layout)
            {
                EditorTimeHelper.Time.Update();
                this.t = Mathf.MoveTowards(this.t, this.IsVisible.Value ? 1 : 0, EditorTimeHelper.Time.DeltaTime * (1f / SirenixEditorGUI.DefaultFadeGroupDuration));
            }

            if (SirenixEditorGUI.BeginFadeGroup(this.t))
            {
                for (int i = 0; i < property.Children.Count; i++)
                {
                    var child = property.Children[i];
                    child.Draw(child.Label);
                }
            }
            SirenixEditorGUI.EndFadeGroup();
            SirenixEditorGUI.EndBox();
        }
Exemple #3
0
        /// <summary>
        /// Draws the property.
        /// </summary>
        protected override void DrawPropertyLayout(GUIContent label)
        {
            bool   result;
            string errorMessage;

            var property  = this.Property;
            var attribute = this.Attribute;

            IfAttributesHelper.HandleIfAttributesCondition(this, property, attribute.MemberName, attribute.Value, out result, out errorMessage);

            if (errorMessage != null)
            {
                SirenixEditorGUI.ErrorMessageBox(errorMessage);
                this.CallNextDrawer(label);
            }
            else
            {
                if (attribute.Animate)
                {
                    if (SirenixEditorGUI.BeginFadeGroup(UniqueDrawerKey.Create(property, this), result))
                    {
                        this.CallNextDrawer(label);
                    }
                    SirenixEditorGUI.EndFadeGroup();
                }
                else
                {
                    if (result)
                    {
                        this.CallNextDrawer(label);
                    }
                }
            }
        }
        protected override void DrawPropertyLayout(GUIContent label)
        {
            bool show = true;

            if (this.helper.ErrorMessage != null)
            {
                SirenixEditorGUI.ErrorMessageBox(this.helper.ErrorMessage);
            }
            else
            {
                show = this.helper.GetValue(this.Attribute.Value);
            }

            if (this.Attribute.Animate)
            {
                if (SirenixEditorGUI.BeginFadeGroup(this, show))
                {
                    for (int i = 0; i < this.Property.Children.Count; i++)
                    {
                        this.Property.Children[i].Draw();
                    }
                }
                SirenixEditorGUI.EndFadeGroup();
            }
            else if (show)
            {
                for (int i = 0; i < this.Property.Children.Count; i++)
                {
                    this.Property.Children[i].Draw();
                }
            }
        }
        /// <summary>
        /// Draws the property.
        /// </summary>
        protected override void DrawPropertyLayout(GUIContent label)
        {
            var entry    = this.ValueEntry;
            var property = entry.Property;
            int minCount = int.MaxValue;
            int maxCount = 0;

            PropertyContext <bool> isVisible;

            if (entry.Context.Get(this, "is_visible", out isVisible))
            {
                isVisible.Value = GeneralDrawerConfig.Instance.OpenListsByDefault;
            }

            for (int i = 0; i < entry.ValueCount; i++)
            {
                if (entry.Values[i].Count > maxCount)
                {
                    maxCount = entry.Values[i].Count;
                }

                if (entry.Values[i].Count < minCount)
                {
                    minCount = entry.Values[i].Count;
                }
            }

            SirenixEditorGUI.BeginHorizontalToolbar();
            isVisible.Value =
                SirenixEditorGUI.Foldout(isVisible.Value, GUIHelper.TempContent("SyncList " + label.text + "  [" + typeof(TList).Name + "]"));
            EditorGUILayout.LabelField(GUIHelper.TempContent(minCount == maxCount ? (minCount == 0 ? "Empty" : minCount + " items") : minCount + " (" + maxCount + ") items"), SirenixGUIStyles.RightAlignedGreyMiniLabel);
            SirenixEditorGUI.EndHorizontalToolbar();

            if (SirenixEditorGUI.BeginFadeGroup(isVisible, isVisible.Value))
            {
                GUIHelper.PushGUIEnabled(false);
                SirenixEditorGUI.BeginVerticalList();
                {
                    var elementLabel = new GUIContent();
                    for (int i = 0; i < maxCount; i++)
                    {
                        SirenixEditorGUI.BeginListItem();
                        elementLabel.text = "Item " + i;

                        if (i < minCount)
                        {
                            property.Children[i].Draw(elementLabel);
                        }
                        else
                        {
                            EditorGUILayout.LabelField(elementLabel, SirenixEditorGUI.MixedValueDashChar);
                        }
                        SirenixEditorGUI.EndListItem();
                    }
                }
                SirenixEditorGUI.EndVerticalList();
                GUIHelper.PopGUIEnabled();
            }
            SirenixEditorGUI.EndFadeGroup();
        }
Exemple #6
0
        /// <summary>
        /// Draws this menu item followed by all of its child menu items
        /// </summary>
        /// <param name="indentLevel">The indent level.</param>
        public virtual void DrawMenuItems(int indentLevel)
        {
            this.DrawMenuItem(indentLevel);

            bool isVisible = this.Toggled;

            if (t < 0)
            {
                t = this.Toggled ? 1 : 0;
            }

            if (Event.current.type == EventType.Layout)
            {
                t = Mathf.MoveTowards(t, isVisible ? 1 : 0, EditorTimeHelper.Time.DeltaTime * (1f / SirenixEditorGUI.DefaultFadeGroupDuration));
            }

            if (SirenixEditorGUI.BeginFadeGroup(t))
            {
                for (int i = 0; i < this.ChildMenuItems.Count; i++)
                {
                    var child = this.ChildMenuItems[i];
                    child.DrawMenuItems(indentLevel + 1);
                }
            }
            SirenixEditorGUI.EndFadeGroup();
        }
Exemple #7
0
        /// <summary>
        /// Draws this menu item followed by all of its child menu items
        /// </summary>
        /// <param name="indentLevel">The indent level.</param>
        public virtual void DrawMenuItems(int indentLevel)
        {
            this.DrawMenuItem(indentLevel);

            var children   = this.ChildMenuItems;
            var childCount = children.Count;

            if (childCount == 0)
            {
                return;
            }

            bool isVisible = this.Toggled;

            if (t < 0)
            {
                t = isVisible ? 1 : 0;
            }

            if (OdinMenuTree.CurrentEventType == EventType.Layout)
            {
                t = Mathf.MoveTowards(t, isVisible ? 1 : 0, OdinMenuTree.CurrentEditorTimeHelperDeltaTime * (1f / SirenixEditorGUI.DefaultFadeGroupDuration));
            }

            if (SirenixEditorGUI.BeginFadeGroup(t))
            {
                for (int i = 0; i < childCount; i++)
                {
                    children[i].DrawMenuItems(indentLevel + 1);
                }
            }
            SirenixEditorGUI.EndFadeGroup();
        }
        protected override void DrawPropertyLayout(GUIContent label)
        {
            SirenixEditorGUI.BeginBox();

            bool collectionChanged = false;

            MakeHeader(ref collectionChanged);

            if (collectionChanged)
            {
                expanded.Value = true;
            }

            if (SirenixEditorGUI.BeginFadeGroup(this, expanded.Value))
            {
                if (!DrawEntries(ref collectionChanged))
                {
                    DrawPrompt();
                }
            }

            SirenixEditorGUI.EndFadeGroup();


            if (collectionChanged)
            {
                AssetDatabase.Refresh();
                AssetDatabase.SaveAssets();
                AssetDatabase.Refresh();
            }

            SirenixEditorGUI.EndBox();
        }
        /// <summary>
        /// Draws the property.
        /// </summary>
        protected override void DrawPropertyLayout(GUIContent label)
        {
            var entry = this.ValueEntry;

            if (Event.current.type == EventType.Layout)
            {
                this.drawAsReference = entry.ValueState == PropertyValueState.Reference;
            }

            if (this.drawAsReference)
            {
                var targetProp = entry.Property.Tree.GetPropertyAtPath(entry.TargetReferencePath);

                if (targetProp == null)
                {
                    GUILayout.Label("Reference to " + entry.TargetReferencePath + ". But no property was found at path, which is a problem.");
                    return;
                }

                var isInReference = targetProp.Context.GetGlobal("is_in_reference", false);

                bool drawReferenceBox = true;

                if (!isInReference.Value)
                {
                    drawReferenceBox = !this.hideReferenceBox;
                }

                if (drawReferenceBox)
                {
                    SirenixEditorGUI.BeginToolbarBox();
                    SirenixEditorGUI.BeginToolbarBoxHeader();
                    Rect valueRect;
                    this.isToggled.Value = SirenixEditorGUI.Foldout(this.isToggled.Value, label, out valueRect);
                    GUI.Label(valueRect, "Reference to " + targetProp.Path, SirenixGUIStyles.LeftAlignedGreyMiniLabel);
                    SirenixEditorGUI.EndToolbarBoxHeader();
                    if (SirenixEditorGUI.BeginFadeGroup(entry.Context.Get(this, "k", 0), this.isToggled.Value))
                    {
                        bool previous = isInReference.Value;
                        isInReference.Value = true;
                        targetProp.Draw(label);
                        isInReference.Value = previous;
                    }
                    SirenixEditorGUI.EndFadeGroup();
                    SirenixEditorGUI.EndToolbarBox();
                }
                else
                {
                    bool previous = isInReference.Value;
                    isInReference.Value = true;
                    targetProp.Draw(label);
                    isInReference.Value = previous;
                }
            }
            else
            {
                this.CallNextDrawer(label);
            }
        }
        /// <summary>
        /// Draws the property layout.
        /// </summary>
        protected override void DrawPropertyLayout(GUIContent label)
        {
            if (this.drawAsList)
            {
                if (GUILayout.Button("Draw as table"))
                {
                    this.drawAsList = false;
                }

                this.CallNextDrawer(label);
                return;
            }


            this.picker = ObjectPicker.GetObjectPicker(this, this.resolver.ElementType);
            this.paging.Update(this.resolver.MaxCollectionLength);
            this.currPage.Value         = this.paging.CurrentPage;
            this.isPagingExpanded.Value = this.paging.IsExpanded;

            var rect = SirenixEditorGUI.BeginIndentedVertical(SirenixGUIStyles.PropertyPadding);

            {
                if (!this.Attribute.HideToolbar)
                {
                    this.DrawToolbar(label);
                }

                if (this.Attribute.AlwaysExpanded)
                {
                    this.DrawColumnHeaders();
                    this.DrawTable();
                }
                else
                {
                    if (SirenixEditorGUI.BeginFadeGroup(this, this.isVisible.Value) && this.Property.Children.Count > 0)
                    {
                        this.DrawColumnHeaders();
                        this.DrawTable();
                    }
                    SirenixEditorGUI.EndFadeGroup();
                }
            }
            SirenixEditorGUI.EndIndentedVertical();
            if (Event.current.type == EventType.Repaint)
            {
                rect.yMin   -= 1;
                rect.height -= 3;
                SirenixEditorGUI.DrawBorders(rect, 1);
            }

            this.DropZone(rect);
            this.HandleObjectPickerEvents();

            if (Event.current.type == EventType.Repaint)
            {
                this.isFirstFrame = false;
            }
        }
Exemple #11
0
        /// <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>
        /// Draws this menu item followed by all of its child menu items
        /// </summary>
        /// <param name="indentLevel">The indent level.</param>
        public virtual void DrawMenuItems(int indentLevel)
        {
            this.DrawMenuItem(indentLevel);

            if (SirenixEditorGUI.BeginFadeGroup(this, this.Toggled))
            {
                foreach (var child in this.ChildMenuItems)
                {
                    child.DrawMenuItems(indentLevel + 1);
                }
            }
            SirenixEditorGUI.EndFadeGroup();
        }
Exemple #13
0
        /// <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);

                SirenixEditorGUI.BeginBox();

                SirenixEditorGUI.BeginBoxHeader();
                EditorGUILayout.BeginHorizontal();

                isToggled.Value = label != null?SirenixEditorGUI.Foldout(isToggled.Value, label)
                                      : SirenixEditorGUI.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();
                SirenixEditorGUI.EndBoxHeader();

                if (SirenixEditorGUI.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--;
                }
                SirenixEditorGUI.EndFadeGroup();
                SirenixEditorGUI.EndBox();
            }
            else
            {
                this.CallNextDrawer(entry.Property, label);
            }
        }
Exemple #14
0
 private void DrawAsIndirectFoldout(GUIContent label, InspectorProperty property)
 {
     foldout.Value = SirenixEditorGUI.Foldout(foldout.Value, label);
     if (SirenixEditorGUI.BeginFadeGroup(this, foldout.Value))
     {
         GUIHelper.PushIndentLevel(1);
         for (var i = 0; i < Property.Children.Count; i++)
         {
             Property.Children[i].Draw();
         }
         GUIHelper.PopIndentLevel();
     }
     SirenixEditorGUI.EndFadeGroup();
 }
        protected override void DrawPort(GUIContent label)
        {
            SirenixEditorGUI.BeginBox();
            SirenixEditorGUI.BeginBoxHeader();
            isUnfolded.Value = SirenixEditorGUI.Foldout(isUnfolded.Value, label == null ? GUIContent.none : label);
            NodePortDrawerHelper.DrawPortHandle(NodePortInfo);
            SirenixEditorGUI.EndBoxHeader();

            if (SirenixEditorGUI.BeginFadeGroup(this, isUnfolded.Value))
            {
                CallNextDrawer(null);
            }
            SirenixEditorGUI.EndFadeGroup();

            SirenixEditorGUI.EndBox();
        }
        /// <summary>
        /// Not yet documented.
        /// </summary>
        protected override void DrawPropertyLayout(IPropertyValueEntry <GUIStyleState> entry, GUIContent label)
        {
            var property = entry.Property;

            var isVisible = property.Context.Get(this, "isVisible", SirenixEditorGUI.ExpandFoldoutByDefault);

            isVisible.Value = SirenixEditorGUI.Foldout(isVisible.Value, label ?? GUIContent.none);

            if (SirenixEditorGUI.BeginFadeGroup(isVisible, isVisible.Value))
            {
                EditorGUI.indentLevel++;
                entry.SmartValue.background = (Texture2D)SirenixEditorFields.UnityObjectField(label, entry.SmartValue.background, typeof(Texture2D), true);
                entry.SmartValue.textColor  = EditorGUILayout.ColorField(label ?? GUIContent.none, entry.SmartValue.textColor);
                EditorGUI.indentLevel--;
            }
            SirenixEditorGUI.EndFadeGroup();
        }
Exemple #17
0
        protected override void DrawPropertyLayout(GUIContent label)
        {
            var target = Property.ValueEntry.WeakSmartValue as Object;

            if (target != null)
            {
                foldout.Value = EditorGUILayout.Foldout(foldout.Value, new GUIContent(typeof(T).GetNiceName().Replace("Effect", string.Empty)));

                if (SirenixEditorGUI.BeginFadeGroup(this, foldout.Value))
                {
                    InspectorUtilities.BeginDrawPropertyTree(tree, true);
                    InspectorUtilities.DrawPropertiesInTree(tree);
                    InspectorUtilities.EndDrawPropertyTree(tree);
                }
                SirenixEditorGUI.EndFadeGroup();
            }
        }
Exemple #18
0
        /// <summary>
        /// Draws the property.
        /// </summary>
        protected override void DrawPropertyLayout(GUIContent label)
        {
            var entry     = this.ValueEntry;
            var isEditing = entry.Property.Context.Get(this, "isEditing", false);

            entry.SmartValue.Name = entry.SmartValue.Name ?? "Palette Name";

            SirenixEditorGUI.BeginBox();
            {
                SirenixEditorGUI.BeginToolbarBoxHeader();
                {
                    GUILayout.Label(entry.SmartValue.Name);
                    GUILayout.FlexibleSpace();
                    if (SirenixEditorGUI.IconButton(EditorIcons.Pen))
                    {
                        isEditing.Value = !isEditing.Value;
                    }
                }
                SirenixEditorGUI.EndToolbarBoxHeader();

                if (entry.SmartValue.Colors == null)
                {
                    entry.SmartValue.Colors = new List <Color>();
                }

                if (SirenixEditorGUI.BeginFadeGroup(entry.SmartValue, entry, isEditing.Value))
                {
                    this.CallNextDrawer(null);
                }
                SirenixEditorGUI.EndFadeGroup();

                if (SirenixEditorGUI.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);
                }
                SirenixEditorGUI.EndFadeGroup();
            }
            SirenixEditorGUI.EndToolbarBox();
        }
        protected override void DrawPropertyLayout(GUIContent label)
        {
            GUIHelper.PushColor(new Color(this.Attribute.r, this.Attribute.g, this.Attribute.b, this.Attribute.a));
            SirenixEditorGUI.BeginBox();
            SirenixEditorGUI.BeginBoxHeader();
            GUIHelper.PopColor();

            this.isExpanded.Value = SirenixEditorGUI.Foldout(this.isExpanded.Value, label);
            SirenixEditorGUI.EndBoxHeader();

            if (SirenixEditorGUI.BeginFadeGroup(this, this.isExpanded.Value))
            {
                for (int i = 0; i < this.Property.Children.Count; i++)
                {
                    this.Property.Children[i].Draw();
                }
            }
            SirenixEditorGUI.EndFadeGroup();
            SirenixEditorGUI.EndBox();
        }
        private void DrawParameters(bool appendButton)
        {
            if (SirenixEditorGUI.BeginFadeGroup(this, this.toggle.Value || this.expanded))
            {
                GUILayout.Space(0);
                for (int i = 0; i < this.Property.Children.Count; i++)
                {
                    this.Property.Children[i].Draw();
                }

                if (appendButton)
                {
                    var rect = EditorGUILayout.BeginVertical(SirenixGUIStyles.BottomBoxPadding).Expand(3);
                    SirenixEditorGUI.DrawHorizontalLineSeperator(rect.x, rect.y, rect.width);
                    this.DrawNormalButton();
                    EditorGUILayout.EndVertical();
                }
            }
            SirenixEditorGUI.EndFadeGroup();
        }
Exemple #21
0
        /// <summary>
        /// Draws the property.
        /// </summary>
        protected override void DrawPropertyLayout(IPropertyValueEntry <Rect> entry, GUIContent label)
        {
            if (label == null)
            {
                this.DrawValues(entry);
            }
            else
            {
                var isVisible = entry.Property.Context.GetPersistent <bool>(this, "IsVisible", GeneralDrawerConfig.Instance.ExpandFoldoutByDefault);

                isVisible.Value = SirenixEditorGUI.Foldout(isVisible.Value, label);
                if (SirenixEditorGUI.BeginFadeGroup(UniqueDrawerKey.Create(entry, this), isVisible.Value))
                {
                    EditorGUI.indentLevel++;
                    this.DrawValues(entry);
                    EditorGUI.indentLevel--;
                }
                SirenixEditorGUI.EndFadeGroup();
            }
        }
    protected override void DrawPropertyLayout(GUIContent label)
    {
        GUIHelper.PushColor(new Color(this.Attribute.R, this.Attribute.G, this.Attribute.B, this.Attribute.A));
        SirenixEditorGUI.BeginBox();
        SirenixEditorGUI.BeginBoxHeader();
        GUIHelper.PopColor();

        this.isOpen = SirenixEditorGUI.Foldout(this.isOpen, label);
        SirenixEditorGUI.EndBoxHeader();

        if (SirenixEditorGUI.BeginFadeGroup(this, isOpen))
        {
            for (int i = 0; i < this.Property.Children.Count; i++)
            {
                this.Property.Children[i].Draw();
            }
        }
        SirenixEditorGUI.EndFadeGroup();
        SirenixEditorGUI.EndBox();
    }
Exemple #23
0
        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);
                }
            }
        }
Exemple #24
0
    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();
    }
        /// <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 : SirenixEditorGUI.ExpandFoldoutByDefault),
                    TitleHelper = new StringMemberHelper(property.ParentType, attribute.GroupName)
                };
            }

            if (context.Value.TitleHelper.ErrorMessage != null)
            {
                SirenixEditorGUI.ErrorMessageBox(context.Value.TitleHelper.ErrorMessage);
            }

            SirenixEditorGUI.BeginBox();
            {
                SirenixEditorGUI.BeginBoxHeader();
                var content = GUIHelper.TempContent(context.Value.TitleHelper.GetString(property));
                var rect    = GUILayoutUtility.GetRect(content, SirenixGUIStyles.Label);
                context.Value.IsVisible.Value = SirenixEditorGUI.Foldout(rect, context.Value.IsVisible.Value, content);
                SirenixEditorGUI.EndBoxHeader();

                if (SirenixEditorGUI.BeginFadeGroup(context, context.Value.IsVisible.Value))
                {
                    for (int i = 0; i < property.Children.Count; i++)
                    {
                        InspectorUtilities.DrawProperty(property.Children[i]);
                    }
                }

                SirenixEditorGUI.EndFadeGroup();
            }
            SirenixEditorGUI.EndBox();
        }
Exemple #26
0
        /// <summary>
        /// Draws the property with GUILayout support.
        /// </summary>
        protected override void DrawPropertyLayout(GUIContent label)
        {
            var entry    = this.ValueEntry;
            var property = entry.Property;

            if (label != null)
            {
                this.isVisible = SirenixEditorGUI.Foldout(this.isVisible, label);
                if (SirenixEditorGUI.BeginFadeGroup(isVisible, this.isVisible))
                {
                    EditorGUI.indentLevel++;
                    entry.SmartValue.background = (Texture2D)SirenixEditorFields.UnityObjectField(label, entry.SmartValue.background, typeof(Texture2D), true);
                    entry.SmartValue.textColor  = EditorGUILayout.ColorField(label ?? GUIContent.none, entry.SmartValue.textColor);
                    EditorGUI.indentLevel--;
                }
                SirenixEditorGUI.EndFadeGroup();
            }
            else
            {
                entry.SmartValue.background = (Texture2D)SirenixEditorFields.UnityObjectField(label, entry.SmartValue.background, typeof(Texture2D), true);
                entry.SmartValue.textColor  = EditorGUILayout.ColorField(label ?? GUIContent.none, entry.SmartValue.textColor);
            }
        }
Exemple #27
0
        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);
            }
        }
        /// <summary>
        /// Draws the property.
        /// </summary>
        protected override void DrawPropertyLayout(GUIContent label)
        {
            var  resolver   = this.Property.ChildResolver as ICollectionResolver;
            bool isReadOnly = resolver.IsReadOnly;

            if (this.errorMessage != null)
            {
                SirenixEditorGUI.ErrorMessageBox(errorMessage);
            }

            if (info.Label == null || (label != null && label.text != info.Label.text))
            {
                info.Label = new GUIContent(label == null || string.IsNullOrEmpty(label.text) ? Property.ValueEntry.TypeOfValue.GetNiceName() : label.text, label == null ? string.Empty : label.tooltip);
            }

            info.IsReadOnly = resolver.IsReadOnly;

            info.ListItemStyle.padding.left  = info.Draggable ? 25 : 7;
            info.ListItemStyle.padding.right = info.IsReadOnly || info.HideRemoveButton ? 4 : 20;

            if (Event.current.type == EventType.Repaint)
            {
                info.DropZoneTopLeft = GUIUtility.GUIToScreenPoint(new Vector2(0, 0));
            }

            info.CollectionResolver        = Property.ChildResolver as ICollectionResolver;
            info.OrderedCollectionResolver = Property.ChildResolver as IOrderedCollectionResolver;
            info.Count   = Property.Children.Count;
            info.IsEmpty = Property.Children.Count == 0;

            SirenixEditorGUI.BeginIndentedVertical(SirenixGUIStyles.PropertyPadding);
            this.BeginDropZone();
            {
                this.DrawToolbar();
                if (SirenixEditorGUI.BeginFadeGroup(UniqueDrawerKey.Create(Property, this), info.Toggled.Value))
                {
                    GUIHelper.PushLabelWidth(GUIHelper.BetterLabelWidth - info.ListItemStyle.padding.left);
                    this.DrawItems();
                    GUIHelper.PopLabelWidth();
                }
                SirenixEditorGUI.EndFadeGroup();
            }
            this.EndDropZone();
            SirenixEditorGUI.EndIndentedVertical();

            if (info.OrderedCollectionResolver != null)
            {
                if (info.RemoveAt >= 0 && Event.current.type == EventType.Repaint)
                {
                    try
                    {
                        if (info.CustomRemoveIndexFunction != null)
                        {
                            foreach (var parent in this.Property.ParentValues)
                            {
                                info.CustomRemoveIndexFunction(
                                    parent,
                                    info.RemoveAt);
                            }
                        }
                        else if (info.CustomRemoveElementFunction != null)
                        {
                            for (int i = 0; i < this.Property.ParentValues.Count; i++)
                            {
                                info.CustomRemoveElementFunction(
                                    this.Property.ParentValues[i],
                                    this.Property.Children[info.RemoveAt].ValueEntry.WeakValues[i]);
                            }
                        }
                        else
                        {
                            info.OrderedCollectionResolver.QueueRemoveAt(info.RemoveAt);
                        }
                    }
                    finally
                    {
                        info.RemoveAt = -1;
                    }

                    GUIHelper.RequestRepaint();
                }
            }
            else if (info.RemoveValues != null && Event.current.type == EventType.Repaint)
            {
                try
                {
                    if (info.CustomRemoveElementFunction != null)
                    {
                        for (int i = 0; i < this.Property.ParentValues.Count; i++)
                        {
                            info.CustomRemoveElementFunction(
                                this.Property.ParentValues[i],
                                this.info.RemoveValues[i]);
                        }
                    }
                    else
                    {
                        info.CollectionResolver.QueueRemove(info.RemoveValues);
                    }
                }
                finally
                {
                    info.RemoveValues = null;
                }
                GUIHelper.RequestRepaint();
            }

            if (info.ObjectPicker != null && info.ObjectPicker.IsReadyToClaim && Event.current.type == EventType.Repaint)
            {
                var value = info.ObjectPicker.ClaimObject();

                if (info.JumpToNextPageOnAdd)
                {
                    info.StartIndex = int.MaxValue;
                }

                object[] values = new object[info.Property.Tree.WeakTargets.Count];

                values[0] = value;
                for (int j = 1; j < values.Length; j++)
                {
                    values[j] = SerializationUtility.CreateCopy(value);
                }

                info.CollectionResolver.QueueAdd(values);
            }
        }
Exemple #29
0
            public void DrawItem()
            {
                bool hasLabel = this.labelName != null && (this.matchesSearchTerm || this.window.hasSearchTerm == false);

                if (hasLabel)
                {
                    bool isSelected = false, isChosen = false;
                    if (this.ChildNodes != null)
                    {
                        if (this.window.hideFoldoutLabels == false)
                        {
                            SirenixEditorGUI.BeginMenuListItem(out isSelected, out isChosen, this.ForceSetSelected);
                            {
                                if (this.matchesSearchTerm)
                                {
                                    SirenixEditorGUI.Foldout(true, this.label);
                                }
                                else
                                {
                                    this.IsVisible = SirenixEditorGUI.Foldout(this.IsVisible, this.label);
                                }
                            }
                            SirenixEditorGUI.EndMenuListItem();
                        }
                    }
                    else
                    {
                        SirenixEditorGUI.BeginMenuListItem(out isSelected, out isChosen, this.ForceSetSelected);
                        {
                            //if (this.drawHasNoEmptyConstructor)
                            //{
                            //    GUIHelper.PushGUIEnabled(false);
                            //}

                            // Properbly a type
                            if (this.isTypeNode && this.Type == typeof(NullType))
                            {
                                EditorGUILayout.LabelField(this.label, SirenixGUIStyles.LeftAlignedGreyMiniLabel);
                            }
                            else
                            {
                                EditorGUILayout.LabelField(this.label);
                            }

                            //if (this.drawHasNoEmptyConstructor)
                            //{
                            //    GUIHelper.PopGUIEnabled();
                            //}

                            if (this.drawHasNoEmptyConstructor)
                            {
                                var rect = GUILayoutUtility.GetLastRect();

                                rect.width -= 16;

                                EditorIcons.AlertTriangle.Draw(new Rect(rect.xMax, rect.yMin, 16, 16));

                                GUI.Label(rect, this.hasNoEmptyConstructorLabel, SirenixGUIStyles.RightAlignedGreyMiniLabel);
                                //isChosen = false;
                            }
                            //var rect = GUILayoutUtility.GetLastRect();
                            //if (this.isTypeNode && this.showNotSerializableLabel)
                            //{
                            //    GUI.Label(rect, isNotSerializableLabel, isSelected ? SirenixGUIStyles.RightAlignedWhiteMiniLabel : SirenixGUIStyles.RightAlignedGreyMiniLabel);
                            //}
                        }
                        SirenixEditorGUI.EndMenuListItem();
                    }

                    if (isSelected && Event.current.type == EventType.KeyDown)
                    {
                        if (Event.current.keyCode == KeyCode.RightArrow)
                        {
                            this.IsVisible = true;
                        }
                        else if (Event.current.keyCode == KeyCode.LeftArrow)
                        {
                            this.IsVisible = false;
                        }
                        else if (Event.current.keyCode == KeyCode.Return)
                        {
                            isChosen = true;
                        }
                    }

                    if (isChosen)
                    {
                        this.IsVisible = !this.IsVisible;

                        if (this.isTypeNode)
                        {
                            this.window.chosenType = this.Type;
                        }
                    }

                    this.ForceSetSelected = false;
                }

                if (this.labelName == null)
                {
                    this.IsVisible = true;
                }

                if (this.ChildNodes != null)
                {
                    if (this.matchesSearchTerm || SirenixEditorGUI.BeginFadeGroup(this, this.IsVisible))
                    {
                        if (hasLabel && !this.window.hideFoldoutLabels)
                        {
                            EditorGUI.indentLevel++;
                        }
                        for (int i = 0; i < this.ChildNodes.Count; i++)
                        {
                            this.ChildNodes[i].DrawItem();
                        }
                        if (hasLabel && !this.window.hideFoldoutLabels)
                        {
                            EditorGUI.indentLevel--;
                        }
                    }
                    if (this.matchesSearchTerm == false)
                    {
                        SirenixEditorGUI.EndFadeGroup();
                    }
                }
            }
        /// <summary>
        /// Draws the property.
        /// </summary>
        protected override void DrawPropertyLayout(IPropertyValueEntry <TList> entry, GUIContent label)
        {
            var property    = entry.Property;
            var infoContext = property.Context.Get(this, "Context", (ListDrawerConfigInfo)null);
            var info        = infoContext.Value;

            bool isReadOnly = false;

            if (entry.TypeOfValue.IsArray == false)
            {
                for (int i = 0; i < entry.ValueCount; i++)
                {
                    if ((entry.WeakValues[i] as IList <TElement>).IsReadOnly)
                    {
                        isReadOnly = true;
                        break;
                    }
                }
            }

            if (info == null)
            {
                var customListDrawerOptions = property.Info.GetAttribute <ListDrawerSettingsAttribute>() ?? new ListDrawerSettingsAttribute();
                isReadOnly = entry.IsEditable == false || isReadOnly || customListDrawerOptions.IsReadOnlyHasValue && customListDrawerOptions.IsReadOnly;

                info = infoContext.Value = new ListDrawerConfigInfo()
                {
                    StartIndex              = 0,
                    Toggled                 = entry.Context.GetPersistent <bool>(this, "ListDrawerToggled", customListDrawerOptions.ExpandedHasValue ? customListDrawerOptions.Expanded : GeneralDrawerConfig.Instance.OpenListsByDefault),
                    RemoveAt                = -1,
                    label                   = new GUIContent(label == null || string.IsNullOrEmpty(label.text) ? property.ValueEntry.TypeOfValue.GetNiceName() : label.text, label == null ? string.Empty : label.tooltip),
                    ShowAllWhilePageing     = false,
                    EndIndex                = 0,
                    CustomListDrawerOptions = customListDrawerOptions,
                    IsReadOnly              = isReadOnly,
                    Draggable               = !isReadOnly && (!customListDrawerOptions.IsReadOnlyHasValue)
                };

                info.listConfig = GeneralDrawerConfig.Instance;
                info.property   = property;

                if (customListDrawerOptions.DraggableHasValue && !customListDrawerOptions.DraggableItems)
                {
                    info.Draggable = false;
                }

                if (info.CustomListDrawerOptions.OnBeginListElementGUI != null)
                {
                    string     errorMessage;
                    MemberInfo memberInfo = property.ParentType
                                            .FindMember()
                                            .IsMethod()
                                            .IsNamed(info.CustomListDrawerOptions.OnBeginListElementGUI)
                                            .HasParameters <int>()
                                            .ReturnsVoid()
                                            .GetMember <MethodInfo>(out errorMessage);

                    if (memberInfo == null || errorMessage != null)
                    {
                        Debug.LogError(errorMessage ?? "There should really be an error message here.");
                    }
                    else
                    {
                        info.OnBeginListElementGUI = EmitUtilities.CreateWeakInstanceMethodCaller <int>(memberInfo as MethodInfo);
                    }
                }

                if (info.CustomListDrawerOptions.OnEndListElementGUI != null)
                {
                    string     errorMessage;
                    MemberInfo memberInfo = property.ParentType
                                            .FindMember()
                                            .IsMethod()
                                            .IsNamed(info.CustomListDrawerOptions.OnEndListElementGUI)
                                            .HasParameters <int>()
                                            .ReturnsVoid()
                                            .GetMember <MethodInfo>(out errorMessage);

                    if (memberInfo == null || errorMessage != null)
                    {
                        Debug.LogError(errorMessage ?? "There should really be an error message here.");
                    }
                    else
                    {
                        info.OnEndListElementGUI = EmitUtilities.CreateWeakInstanceMethodCaller <int>(memberInfo as MethodInfo);
                    }
                }

                if (info.CustomListDrawerOptions.OnTitleBarGUI != null)
                {
                    string     errorMessage;
                    MemberInfo memberInfo = property.ParentType
                                            .FindMember()
                                            .IsMethod()
                                            .IsNamed(info.CustomListDrawerOptions.OnTitleBarGUI)
                                            .HasNoParameters()
                                            .ReturnsVoid()
                                            .GetMember <MethodInfo>(out errorMessage);

                    if (memberInfo == null || errorMessage != null)
                    {
                        Debug.LogError(errorMessage ?? "There should really be an error message here.");
                    }
                    else
                    {
                        info.OnTitleBarGUI = EmitUtilities.CreateWeakInstanceMethodCaller(memberInfo as MethodInfo);
                    }
                }

                if (info.CustomListDrawerOptions.ListElementLabelName != null)
                {
                    string     errorMessage;
                    MemberInfo memberInfo = typeof(TElement)
                                            .FindMember()
                                            .HasNoParameters()
                                            .IsNamed(info.CustomListDrawerOptions.ListElementLabelName)
                                            .HasReturnType <object>(true)
                                            .GetMember(out errorMessage);

                    if (memberInfo == null || errorMessage != null)
                    {
                        Debug.LogError(errorMessage ?? "There should really be an error message here.");
                    }
                    else
                    {
                        string methodSuffix = memberInfo as MethodInfo == null ? "" : "()";
                        info.GetListElementLabelText = DeepReflection.CreateWeakInstanceValueGetter(typeof(TElement), typeof(object), info.CustomListDrawerOptions.ListElementLabelName + methodSuffix);
                    }
                }
            }

            info.listConfig = GeneralDrawerConfig.Instance;
            info.property   = property;

            info.ListItemStyle.padding.left  = info.Draggable ? 25 : 7;
            info.ListItemStyle.padding.right = info.IsReadOnly ? 4 : 20;

            if (Event.current.type == EventType.Repaint)
            {
                info.DropZoneTopLeft = GUIUtility.GUIToScreenPoint(new Vector2(0, 0));
            }

            info.ListValueChanger = property.ValueEntry.GetListValueEntryChanger();
            info.Count            = property.Children.Count;
            info.IsEmpty          = property.Children.Count == 0;

            SirenixEditorGUI.BeginIndentedVertical(SirenixGUIStyles.PropertyPadding);
            this.BeginDropZone(info);
            {
                this.DrawToolbar(info);
                if (SirenixEditorGUI.BeginFadeGroup(UniqueDrawerKey.Create(property, this), info.Toggled.Value))
                {
                    GUIHelper.PushLabelWidth(EditorGUIUtility.labelWidth - info.ListItemStyle.padding.left);
                    this.DrawItems(info);
                    GUIHelper.PopLabelWidth();
                }
                SirenixEditorGUI.EndFadeGroup();
            }
            this.EndDropZone(info);
            SirenixEditorGUI.EndIndentedVertical();

            if (info.RemoveAt >= 0 && Event.current.type == EventType.Repaint)
            {
                info.ListValueChanger.RemoveListElementAt(info.RemoveAt, CHANGE_ID);

                info.RemoveAt = -1;
                GUIHelper.RequestRepaint();
            }

            if (info.ObjectPicker != null && info.ObjectPicker.IsReadyToClaim && Event.current.type == EventType.Repaint)
            {
                var value = info.ObjectPicker.ClaimObject();

                if (info.JumpToNextPageOnAdd)
                {
                    info.StartIndex = int.MaxValue;
                }

                object[] values = new object[info.ListValueChanger.ValueCount];

                values[0] = value;
                for (int j = 1; j < values.Length; j++)
                {
                    values[j] = SerializationUtility.CreateCopy(value);
                }

                info.ListValueChanger.AddListElement(values, CHANGE_ID);
            }
        }