Beispiel #1
0
        protected override LabeledSpritePoint DrawValueInternal(Rect rect, LabeledSpritePoint value)
        {
            string  label    = value.GetLabel();
            Vector2 position = value.GetPosition();

            EditProperty_Single_Value sprite_property = GetProperty().GetTarget().ForcePropertyValue("target_asset");

            Rect label_rect;
            Rect position_rect;

            rect.SplitByXLeftPercent(0.4f, out rect, out position_rect);
            rect.SplitByYBottomOffset(LINE_HEIGHT, out label_rect, out rect);

            label = EditorGUIExtensions.TextField(label_rect, label);

            if (sprite_property != null)
            {
                Sprite sprite;

                if (sprite_property.TryGetContentValues <Sprite>(out sprite))
                {
                    position_rect = GUIExtensions.DrawSprite(position_rect, sprite);

                    position = EditorGUIExtensions.XYControl(
                        position_rect,
                        position,
                        new FloatRange(0.0f, 1.0f),
                        new FloatRange(0.0f, 1.0f)
                        );
                }
            }

            return(new LabeledSpritePoint(label, position));
        }
Beispiel #2
0
        protected override void DrawElementInternal(int draw_id, Rect view)
        {
            GUIExtensions.DrawOutlinedRect(GetElementRect(), Color.gray);
            GUI.Label(GetElementRect(), label);

            is_dropped = EditorGUIExtensions.DropZone(GetElementRect(), type, out dragged);
        }
Beispiel #3
0
        protected override Sprite DrawValueInternal(Rect rect, Sprite value)
        {
            Rect field_rect;

            rect.SplitByXRightOffset(64.0f, out field_rect, out rect);

            value = EditorGUIExtensions.ObjectField <Sprite>(field_rect, value);
            GUIExtensions.DrawSprite(rect, value);

            return(value);
        }
Beispiel #4
0
        protected override Duration DrawValueInternal(Rect rect, Duration value)
        {
            Rect view_rect;

            rect.SplitByXRightPercent(0.5f, out rect, out view_rect);

            value = EditorGUIExtensions.TextField(rect, value.ToString()).ParseDuration();
            EditorGUI.LabelField(view_rect, value.ToString());

            return(value);
        }
Beispiel #5
0
        protected override void DrawUnifiedElementInternal(Rect rect, T old_value)
        {
            if (EditorGUIExtensions.DropdownButton(GetElementRect(), old_value.ToStringEX("None")))
            {
                List <T> options = GetOptions()
                                   .Sort(o => o.ToStringEX())
                                   .ToList();

                GenericMenuExtensions.Create <T>(options, o => GetProperty().SetContentValues(o))
                .DropDown(GetElementRect());
            }
        }
Beispiel #6
0
        protected override void DrawElementInternal(int draw_id, Rect view)
        {
            object value;

            if (GetEditDisplay().TryGetValue(out value))
            {
                EditorGUIExtensions.TextDisplay(GetElementRect(), value.ToStringEX());
            }
            else
            {
                EditorGUIExtensions.TextDisplay(GetElementRect(), "Non Unified Values");
            }
        }
Beispiel #7
0
        protected override void DrawUnifiedElementInternal(Rect rect, T old_value)
        {
            if (EditorGUIExtensions.DropdownButton(GetElementRect(), old_value.ToStringEX("None")))
            {
                GenericMenu menu = new GenericMenu();

                foreach (AssetInfo option in GetAssetInfos())
                {
                    menu.AddItem(option.ToStringEX("None"), () => GetProperty().SetContentValues(option.Resolve <T>()));
                }

                menu.ShowAsContext();
            }
        }
Beispiel #8
0
        protected override OctoSubTile DrawValueInternal(Rect rect, OctoSubTile value)
        {
            Sprite   sprite = value.GetSprite();
            OctoMask mask   = value.GetMask();
            float    weight = value.GetWeight();

            Rect left_rect;
            Rect right_rect;

            Rect weight_rect;

            Vector2 filled_dimension = Vector2.one.GetFilledDimension(rect.GetSize());

            rect.SplitByXLeftOffset(filled_dimension.x, out left_rect, out right_rect);
            right_rect.SplitByYBottomOffset(LINE_HEIGHT, out weight_rect, out right_rect);

            weight = EditorGUI.FloatField(weight_rect, "Weight", weight);

            left_rect
            .ProcessGrid(3, 3, delegate(int x, int y, Rect sub_rect) {
                if (x == 1 && y == 1)
                {
                    sprite = EditorGUIExtensions.SpriteDropZone(sub_rect, sprite);
                }
                else
                {
                    int dx = x - 1;
                    int dy = y - 1;

                    bool has = mask.HasBitAt(dx, dy);

                    if (GUIExtensions.ColorButton(sub_rect, has.ConvertBool(Color.black, Color.gray)))
                    {
                        if (has)
                        {
                            mask = mask.GetWithoutBitAt(dx, dy);
                        }
                        else
                        {
                            mask = mask.GetWithBitAt(dx, dy);
                        }
                    }
                }
            });

            return(new OctoSubTile(mask, sprite, weight));
        }
Beispiel #9
0
        private int CalculateNumberLines()
        {
            if (multiline_attribute != null)
            {
                return(multiline_attribute.lines);
            }

            if (auto_multiline_attribute != null)
            {
                string value;

                if (GetProperty().TryGetContentValues <string>(out value))
                {
                    return(EditorGUIExtensions.CalculateTextAreaNumberLines(GetElementRect().width, value, use_word_wrap));
                }
            }

            return(1);
        }
Beispiel #10
0
        protected override FloatRange DrawBuiltInInternal(Rect rect, GUIContent label, FloatRange value)
        {
            if (range_attribute != null)
            {
                return((FloatRange)EditorGUIExtensions.RangeSlider(rect, label, (FloatRange)value, new FloatRange(range_attribute.min, range_attribute.max)));
            }
            else
            {
                Rect x1_rect;
                Rect x2_rect;

                rect.SplitByXCenter(out x1_rect, out x2_rect);

                float x1 = EditorGUI.FloatField(x1_rect, label, value.x1);
                float x2 = EditorGUI.FloatField(x2_rect, "->", value.x2);

                return(new FloatRange(x1, x2));
            }
        }
Beispiel #11
0
        protected override string DrawBuiltInInternal(Rect rect, GUIContent label, string value)
        {
            if (multiline_attribute != null)
            {
                return(EditorGUIExtensions.TextArea(rect, label, value, use_word_wrap));
            }

            if (auto_multiline_attribute != null)
            {
                string new_value = EditorGUIExtensions.TextArea(rect, label, value, use_word_wrap);

                if (new_value != value)
                {
                    Invalidate();
                }

                return(new_value);
            }

            return(EditorGUIExtensions.TextField(rect, label, value));
        }
Beispiel #12
0
        protected override EditorGUIElement PushState()
        {
            CustomAsset asset;
            EditProperty_Single_Value property = GetProperty();

            Type field_type = property.GetPropertyType();

            EditorGUIElement_Container_Auto      container      = new EditorGUIElement_Container_Auto_Simple_VerticalStrip();
            EditorGUIElement_Container_Flow_Line type_container = container.AddChild(new EditorGUIElement_Container_Flow_Line());

            if (property.TryGetContentValues <CustomAsset>(out asset, true))
            {
                switch (asset.GetAssetType())
                {
                case AssetType.None:
                case AssetType.External:
                    type_container.AddWeightedChild(1.0f,
                                                    new EditorGUIElement_EditPropertySingleValue_Selector_Asset(property, false)
                                                    );
                    break;

                case AssetType.Internal:
                    type_container.AddWeightedChild(1.0f,
                                                    new EditorGUIElement_Popup_ProcessOperation <Type>(
                                                        GetInternalCustomAssetTypes(field_type),
                                                        t => property.SetContentValues(CustomAssets.CreateInternalCustomAsset(t)),
                                                        (out Type t) => property.TryGetContentsType(out t)
                                                        )
                                                    );
                    break;
                }

                type_container.AddFixedChild(64.0f, new EditorGUIElement_Process(delegate(Rect rect) {
                    AssetType new_type = EditorGUIExtensions.EnumPopup(rect, asset.GetAssetType());

                    if (asset.GetAssetType() != new_type)
                    {
                        switch (new_type)
                        {
                        case AssetType.None:
                            property.SetContentValues(null);
                            break;

                        case AssetType.External:
                            property.SetContentValues(
                                CustomAssets.GetExternalCustomAssetsOfType(field_type)
                                .GetFirst()
                                );
                            break;

                        case AssetType.Internal:
                            property.SetContentValues(
                                CustomAssets.CreateInternalCustomAsset(
                                    GetInternalCustomAssetTypes(field_type)
                                    .GetFirst()
                                    )
                                );
                            break;
                        }
                    }
                }));

                if (asset != null && asset.IsInternalAsset())
                {
                    container.AddChild(new EditorGUIElement_Complex_EditTarget(new EditTarget(asset)));
                }
            }

            return(container);
        }
Beispiel #13
0
 static public Vector2 XYControl(Rect rect, Vector2 value, FloatRange range)
 {
     return(EditorGUIExtensions.XYControl(rect, value, range, range));
 }
Beispiel #14
0
 protected virtual T DrawValueInternal(Rect rect, T value)
 {
     return(EditorGUIExtensions.ObjectField <T>(rect, value));
 }