示例#1
0
        public EditorGUIElementAttachment_Singular_Label_Index(EditProperty_Array a, int i, Process p)
        {
            property = a;
            index    = i;

            process = p;
        }
示例#2
0
        static public void Resize(this EditProperty_Array item, int new_size)
        {
            int current_size;

            if (item.TryGetNumberElements(out current_size))
            {
                if (new_size < 0)
                {
                    new_size = 0;
                }

                if (new_size != current_size)
                {
                    if (new_size > current_size)
                    {
                        for (int i = current_size; i < new_size; i++)
                        {
                            item.InsertElement(i);
                        }
                    }
                    else
                    {
                        for (int i = current_size - 1; i >= new_size; i--)
                        {
                            item.RemoveElement(i);
                        }
                    }
                }
            }
        }
示例#3
0
        static public void SetElementValue(this EditProperty_Array item, int index, object value)
        {
            EditProperty_Single_Value property;

            if (item.TryGetElementValue(index, out property))
            {
                property.SetContentValues(value);
            }
        }
示例#4
0
        static public bool TryGetElementValue(this EditProperty_Array item, int index, out object value)
        {
            EditProperty_Single_Value property;

            if (item.TryGetElementValue(index, out property))
            {
                return(property.TryGetContentValues(out value));
            }

            value = null;
            return(false);
        }
示例#5
0
        static public bool IsIndexValid(this EditProperty_Array item, int index)
        {
            int number_elements;

            if (item.TryGetNumberElements(out number_elements))
            {
                if (index >= 0 && index < number_elements)
                {
                    return(true);
                }
            }

            return(false);
        }
示例#6
0
        protected override EditorGUIElement PushState()
        {
            EditTarget target = GetProperty().GetContents();
            EditorGUIElement_Container_Flow_Multiline container = new EditorGUIElement_Container_Flow_Multiline();

            if (target.IsValid())
            {
                EditProperty_Array property = target.ForcePropertyArray("percents");

                container.AddFixedChild(32.0f, new EditorGUIElement_EditPropertyArray_ArraySize(property));
                container.AddWeightedChild(1.0f, new EditorGUIElement_EditPropertyArray_FloatSequence(property));
            }

            return(container);
        }
示例#7
0
        static public bool TryGetElementValue <T>(this EditProperty_Array item, int index, out T value)
        {
            object temp;

            if (item.TryGetElementValue(index, out temp))
            {
                if (temp.Convert <T>(out value))
                {
                    return(true);
                }
            }

            value = default(T);
            return(false);
        }
示例#8
0
        protected override void DrawArrayInternal(Rect rect, int array_size)
        {
            EditProperty_Array property = GetProperty();

            EditorGUI.DrawRect(border_rect, Color.black);
            EditorGUI.DrawRect(background_rect, Color.gray);

            float x = background_rect.xMin;
            float y = background_rect.yMax;

            float element_width      = background_rect.width / array_size;
            float element_max_height = background_rect.height;

            for (int i = 0; i < array_size; i++)
            {
                float value;

                if (property.TryGetElementValue <float>(i, out value))
                {
                    float height = element_max_height * value.ConvertFromRangeToPercent(min_value, max_value);

                    EditorGUI.DrawRect(RectExtensions.CreateMinMaxRect(
                                           new Vector2(x, y),
                                           new Vector2(x + element_width, y - height)
                                           ), Color.cyan);
                }

                x += element_width;
            }

            Vector2 percent;

            if (GUIExtensions.MousePercentArea(background_rect, out percent, true, true))
            {
                int   index     = (int)(array_size * percent.x);
                float magnitude = 1.0f - percent.y;

                if (property.IsIndexValid(index))
                {
                    property.SetElementValue(index, magnitude.ConvertFromPercentToRange(min_value, max_value));
                }
            }
        }
示例#9
0
 static public void InsertElementAfter(this EditProperty_Array item, EditProperty element)
 {
     item.InsertElement(item.GetIndexOfElement(element) + 1);
 }
示例#10
0
 public EditorGUIElement_EditPropertyArray_ArraySize(EditProperty_Array p) : base(p)
 {
 }
示例#11
0
 public EditorGUIElement_EditPropertyArray_FloatSequence(EditProperty_Array p) : this(p, 1.0f)
 {
 }
示例#12
0
 static public bool TryGetElementValue(this EditProperty_Array item, int index, out EditProperty_Single_Value value)
 {
     return(item.GetElement(index).Convert <EditProperty_Single_Value>(out value));
 }
示例#13
0
 static public void MoveElement(this EditProperty_Array item, EditProperty element, int dst)
 {
     item.MoveElement(item.GetIndexOfElement(element), dst);
 }
示例#14
0
 static public void RemoveElement(this EditProperty_Array item, EditProperty element)
 {
     item.RemoveElement(item.GetIndexOfElement(element));
 }
示例#15
0
 public EditorGUIElement_EditPropertyArray_FloatSequence(EditProperty_Array p, float min, float max) : base(p)
 {
     min_value = min;
     max_value = max;
 }
示例#16
0
 public EditorGUIElement_EditPropertyArray_FloatSequence(EditProperty_Array p, float max) : this(p, 0.0f, max)
 {
 }
示例#17
0
        protected override EditorGUIElement PushState()
        {
            int number_elements;
            EditProperty_Array property = GetEditPropertyArray();
            EditorGUIElement_Container_Auto container = new EditorGUIElement_Container_Auto_Simple_VerticalStrip();

            Type array_type = property.GetPropertyType().GetIEnumerableType();

            if (property.TryGetNumberElements(out number_elements))
            {
                EditorGUIElement_Container_Flow_Line length_strip = container.AddChild(new EditorGUIElement_Container_Flow_Line())
                                                                    .LabelWithGUIContent("Length");

                length_strip.AddWeightedChild(0.6f, new EditorGUIElement_EditPropertyArray_ArraySize(property));
                length_strip.AddWeightedChild(0.4f, new EditorGUIElement_Button("+", delegate() {
                    property.InsertElement(0);
                }));

                if (number_elements <= 0)
                {
                    if (array_type.CanBeTreatedAs <UnityEngine.Object>())
                    {
                        length_strip.AddWeightedChild(0.6f, new EditorGUIElement_DropZone("Drag + Drop",
                                                                                          array_type,
                                                                                          l => property.ForceContentValues(l)
                                                                                          ));
                    }
                }
                else
                {
                    for (int i = 0; i < number_elements; i++)
                    {
                        EditProperty sub_property = property.GetElement(i);

                        EditorGUIElement control = sub_property.CreateEditorGUIElement();
                        EditorGUIElement_Container_Auto_Simple_HorizontalStrip buttons = new EditorGUIElement_Container_Auto_Simple_HorizontalStrip();

                        buttons.AddChild(new EditorGUIElement_Button("+v", delegate() {
                            property.InsertElementAfter(sub_property);
                        }));
                        buttons.AddChild(new EditorGUIElement_Button("+^", delegate() {
                            property.InsertElementBefore(sub_property);
                        }));
                        buttons.AddChild(new EditorGUIElement_Button("-", delegate() {
                            property.RemoveElement(sub_property);
                        }));

                        container.AddChild(new EditorGUIElement_Sideboard(
                                               new EditorGUIFlowElement(control, EditorGUIElementDimension.Weighted(1.0f)),
                                               new EditorGUIFlowElement(buttons, EditorGUIElementDimension.Fixed(100.0f))
                                               )).LabelWithIndex(property, i, () => ForceRecreation());
                    }
                }
            }
            else
            {
                container.AddChild(new EditorGUIElement_Text("--Disabled(Array lengths are not unified)--"));
            }

            return(container);
        }
示例#18
0
        static public T LabelWithIndex <T>(this T item, EditProperty_Array a, int i, Process p) where T : EditorGUIElement
        {
            item.AddAttachment(new EditorGUIElementAttachment_Singular_Label_Index(a, i, p));

            return(item);
        }
示例#19
0
 public EditorGUIElement_Complex_EditPropertyArray_Generic(EditProperty_Array p) : base(p)
 {
 }
示例#20
0
 public EditorGUIElement_EditPropertyArray(EditProperty_Array p)
 {
     property = p;
 }
示例#21
0
 static public void InsertElementBefore(this EditProperty_Array item, EditProperty element)
 {
     item.InsertElement(item.GetIndexOfElement(element));
 }