Example #1
0
        public void Apply(VariableStore store, bool removeMissing)
        {
            if (removeMissing)
            {
                for (var i = 0; i < store.Variables.Count; i++)
                {
                    if (!Contains(store.Variables[i].Name))
                    {
                        store.Remove(i--);
                    }
                }
            }

            foreach (var definition in Definitions)
            {
                var variable = store.GetVariable(definition.Name);

                if (variable == null)
                {
                    store.Add(VariableValue.Create(definition.Name, definition.Type));
                }
                else if (variable.Type != definition.Type)
                {
                    variable.ChangeType(definition.Type);
                }
            }
        }
Example #2
0
        private void Awake()
        {
            _context = new WorldInstructionContext(gameObject, Variable.Name + " Responder", null);
            _store   = _context.GetStore(Variable);

            if (_store != null)
            {
                var variable = _store.GetVariable(Variable.Name);
                _store.Subscribe(this, null);
                Trigger(variable);
            }
        }
Example #3
0
        public void DrawStoreEntry(Rect rect, int index)
        {
            var variable = _store.GetVariable(index);

            var nameWidth  = rect.width * 0.3f;
            var typeWidth  = rect.width * 0.3f;
            var valueWidth = rect.width - nameWidth - typeWidth - 10;

            var nameRect  = new Rect(rect.x, rect.y, nameWidth, rect.height);
            var typeRect  = new Rect(nameRect.xMax + 5, rect.y, typeWidth, rect.height);
            var valueRect = new Rect(typeRect.xMax + 5, rect.y, valueWidth, EditorGUIUtility.singleLineHeight);

            DrawName(nameRect, variable);
            DrawType(typeRect, variable);
            DrawValue(valueRect, variable, index);
        }