Exemplo n.º 1
0
 public void Process(IStructComponentBase component)
 {
     this.Validate(component);
     for (int i = 0; i < this.boxVars.Length; ++i)
     {
         if (this.boxVars[i] != null)
         {
             this.boxVars[i].Save(this, i);
         }
     }
 }
Exemplo n.º 2
0
        public void Apply(ref IStructComponentBase component)
        {
            var fields = component.GetType().GetCachedFields();

            for (int i = 0; i < this.boxVars.Length; ++i)
            {
                if (this.boxVars[i] != null)
                {
                    var boxVarValue = this.boxVars[i].Load();
                    fields[i].SetValue(component, boxVarValue);
                }
            }
        }
Exemplo n.º 3
0
        public void Validate(IStructComponentBase component)
        {
            var fields = component.GetType().GetCachedFields();

            if (this.data == null || this.data.Length != fields.Length)
            {
                this.data = new FieldData[fields.Length];
            }
            if (this.captions == null || this.captions.Length != this.data.Length)
            {
                this.captions = new string[this.data.Length];
            }
            if (this.boxVars == null)
            {
                this.boxVars = new BoxVariable[this.data.Length];
            }
            if (this.boxVars.Length != this.data.Length)
            {
                System.Array.Resize(ref this.boxVars, this.data.Length);
            }

            for (int i = 0; i < this.data.Length; ++i)
            {
                this.captions[i] = fields[i].Name;
                var         val  = fields[i].GetValue(component);
                System.Type type = null;
                if (val == null)
                {
                    type = fields[i].FieldType;
                }
                else
                {
                    type = val.GetType();
                }

                if (type.IsArray == true)
                {
                    this.data[i].value    = null;
                    this.data[i].valueArr = ((System.Collections.IList)val).Cast <object>().ToArray();
                    this.data[i].isArray  = true;
                }
                else
                {
                    this.data[i].value    = val;
                    this.data[i].valueArr = null;
                    this.data[i].isArray  = false;
                }
            }
        }
Exemplo n.º 4
0
        private void DrawShared(IStructComponentBase component)
        {
            GUILayout.BeginHorizontal();
            {
                var styleLabel = new GUIStyle(EditorStyles.miniLabel);
                styleLabel.richText = true;
                if (component is IComponentShared)
                {
                    EditorGUI.BeginDisabledGroup(true);
                    EditorGUILayout.LabelField(new GUIContent("<color=#7f7><i>Shared</i></color>"), styleLabel);
                    EditorGUI.EndDisabledGroup();

                    GUILayout.Space(10f);
                }

                if (component is IComponentStatic)
                {
                    EditorGUI.BeginDisabledGroup(true);
                    EditorGUILayout.LabelField(new GUIContent("<color=#7ff><i>Static</i></color>"), styleLabel);
                    EditorGUI.EndDisabledGroup();
                }
            }
            GUILayout.EndHorizontal();
        }