예제 #1
0
        public static bool Save(BaseScript script, out ScriptReference xmlScriptReference)
        {
            xmlScriptReference = new ScriptReference();

            xmlScriptReference.AddScriptName(new SchemaString(script.GetType().ToString()));

            foreach (FieldInfo field in script.m_Fields)
            {
                ParameterType parameter = new ParameterType();

                parameter.AddName(new SchemaString(field.Name));
                parameter.AddType2(new SchemaString(field.FieldType.ToString()));

                object value = field.GetValue(script);
                if (value != null)
                {
                    parameter.AddValue(Variable.GetConstantFromValue(value));
                }
                else
                {
                    Debug.LogError("Error saving value for field " + field.Name + " in script " + script.GetType().ToString());
                }

                xmlScriptReference.AddParameter(parameter);
            }

            return(true);
        }