Ejemplo n.º 1
0
        public override void Draw()
        {
            object newValue = null;

            if (IsPrimitive(PropertyType))
            {
                newValue = DrawPrimitive();
            }
            else if (IsArray(PropertyType))
            {
                newValue = DrawArray();
            }
            else if (IsEnum(PropertyType))
            {
                newValue = DrawEnum();
            }
            else if (IsUnityObject(PropertyType))
            {
                newValue = DrawUnityObject();
            }

            if (newValue == Value)
            {
                return;
            }

            EventChange?.Invoke(newValue);
            Value = newValue;
        }
Ejemplo n.º 2
0
        public override void Draw()
        {
            var options = Variants.Select(t => t.Name).ToList();

            if (CanNullable)
            {
                options.Insert(0, "null");
            }

            if (!options.Any())
            {
                throw new InvalidDataException("options for select in dropdown not contains any element");
            }

            var index            = Variants.FindIndex(t => t.Value.Equals(Selected));
            var current_selected = Selected == null ? 0 : index == -1 ? 0 : index + (CanNullable ? 1 : 0);

            int new_selection;

            if (Label == null)
            {
                new_selection = EditorGUILayout.Popup(current_selected, options.ToArray(), LayoutOptions);
            }
            else
            {
                new_selection = EditorGUILayout.Popup(new GUIContent(Label), current_selected,
                                                      options.Select(t => new GUIContent(t)).ToArray(), LayoutOptions);
            }

            if (current_selected == new_selection)
            {
                return;
            }

            var variantValue = Variants.FirstOrDefault(t => t.Name == options[new_selection]);
            var newSelected  = variantValue == null ? default(T) : variantValue.Value;

            EventChange?.Invoke(newSelected);
            Selected = newSelected;
        }
Ejemplo n.º 3
0
 private void cmbImplementation_SelectedIndexChanged(object sender, EventArgs e)
 {
     EventChange?.Invoke((ETypeImpl)cmbImpl.SelectedIndex);
     NextEventChange?.Invoke((ETypeImpl)cmbImpl.SelectedIndex);
 }