public VariableStoreControl Setup(string name, IVariableStore store, bool isStatic, bool isClosable)
        {
            Store        = store;
            Selected     = null;
            SelectedName = string.Empty;

            _label = new GUIContent(name);
            _proxy = isStatic ? (ValuesProxy) new StaticValuesProxy {
                Names = store.GetVariableNames()
            } : new DynamicValuesProxy {
                Store = store
            };

            Setup(_proxy)
            .MakeEmptyLabel(new GUIContent("The store is empty"))
            .MakeCollapsable(true)
            .MakeCustomHeight(GetHeight);

            if (store is Object obj)
            {
                MakeHeaderButton(EditButton, rect => Selection.activeObject = obj, Color.white);
            }

            if (isClosable)
            {
                MakeHeaderButton(CloseButton, rect => ShouldClose = true, Color.white);
            }

            return(this);
        }
Ejemplo n.º 2
0
        public static IVariableStore DrawTable(IVariableStore store, bool allowAddRemove)
        {
            var            names         = store.GetVariableNames();
            IVariableStore selectedStore = null;

            foreach (var name in names)
            {
                var value = store.GetVariable(name);

                using (var changes = new EditorGUI.ChangeCheckScope())
                {
                    switch (value.Type)
                    {
                    case VariableType.Empty: DrawEmpty(name, ref value); break;

                    case VariableType.Boolean: DrawBoolean(name, ref value); break;

                    case VariableType.Integer: DrawInteger(name, ref value); break;

                    case VariableType.Number: DrawNumber(name, ref value); break;

                    case VariableType.String: DrawString(name, ref value); break;

                    case VariableType.Null: DrawNull(name, ref value); break;

                    default:
                    {
                        if (DrawLink(name, value.RawObject))                                 // TODO: show object picker
                        {
                            selectedStore = value.Store;
                        }

                        break;
                    }
                    }

                    if (changes.changed)
                    {
                        store.SetVariable(name, value);
                    }
                }
            }

            return(selectedStore);
        }
Ejemplo n.º 3
0
        public VariableStoreControl Setup(string name, IVariableStore store)
        {
            Name         = name;
            Store        = store;
            Selected     = null;
            SelectedName = "";

            _label = new GUIContent(name);
            _names = store.GetVariableNames().ToList();

            Setup(_names)
            .MakeEmptyLabel(new GUIContent("The store is empty"))
            .MakeCollapsable(nameof(VariableStore) + "." + Name + ".IsOpen");

            if (store is Object obj)
            {
                MakeHeaderButton(EditButton, rect => Selection.activeObject = obj, Color.white);
            }

            return(this);
        }
 public override string GetName(int index) => Store.GetVariableNames()[index];