コード例 #1
0
        ///
        /// Write a property of a data class.
        ///
        private void WriteProperty(MemberFieldData field)
        {
            TextInfo ti = new CultureInfo("en-US", false).TextInfo;

            m_Writer.WriteLine(m_Indentation + "[ExposeProperty]");

            string tmp = string.Empty;

            if (field.type == CellType.Enum)
            {
                tmp += "public " + field.Name + " " + field.Name.ToUpper() + " ";
            }
            else
            {
                if (field.IsArrayType)
                {
                    tmp += "public " + field.Type + "[]" + " " + ti.ToTitleCase(field.Name) + " ";
                }
                else
                {
                    tmp += "public " + field.Type + " " + ti.ToTitleCase(field.Name) + " ";
                }
            }

            tmp += "{ get {return " + field.Name.ToLower() + "; } set { " + field.Name.ToLower() + " = value;} }";

            m_Writer.WriteLine(m_Indentation + tmp);
        }
コード例 #2
0
        ///
        /// Write a member field of a data class.
        ///
        private void WriteMemberField(MemberFieldData field)
        {
            m_Writer.WriteLine(m_Indentation + "[SerializeField]");

            string tmp = field.Type + " " + field.Name.ToLower() + ";";

            m_Writer.WriteLine(m_Indentation + tmp);
        }
コード例 #3
0
    /// <summary>
    /// Create a data class which describes the spreadsheet and write it down on the specified folder.
    /// </summary>
    protected void CreateDataClassScript(BaseMachine machine, ScriptPrescription sp)
    {
        // check the directory path exists
        string fullPath = TargetPathForData(machine.WorkSheetName);
        string folderPath = Path.GetDirectoryName(fullPath);
        if (!Directory.Exists(folderPath))
        {
            EditorUtility.DisplayDialog(
                "Warning",
                "The folder for runtime script files does not exist. Check the path " + folderPath + " exists.",
                "OK"
                );
            return;
        }

        List<MemberFieldData> fieldList = new List<MemberFieldData>();

        //FIXME: replace ValueType to CellType and support Enum type.
        foreach (HeaderColumn header in machine.HeaderColumnList)
        {
            MemberFieldData member = new MemberFieldData();
            member.Name = header.name;
            member.type = header.type;
            member.IsArrayType = header.isArray;

            fieldList.Add(member);
        }

        sp.className = machine.WorkSheetName + "Data";
        sp.template = GetTemplate("DataClass");

        sp.memberFields = fieldList.ToArray();

        // write a script to the given folder.
        using (var writer = new StreamWriter(fullPath))
        {
            writer.Write(new NewScriptGenerator(sp).ToString());
            writer.Close();
        }
    }
コード例 #4
0
        ///
        /// Write a member field of a data class.
        ///
        private void WriteMemberField(MemberFieldData field)
        {
            m_Writer.WriteLine(m_Indentation + "[SerializeField]");

            string tmp;

            if (field.type == CellType.Enum)
            {
                tmp = field.Name + " " + field.Name.ToLower() + ";";
            }
            else
            {
                if (field.IsArrayType)
                {
                    tmp = field.Type + "[]" + " " + field.Name.ToLower() + " = new " + field.Type + "[0]" + ";";
                }
                else
                {
                    tmp = field.Type + " " + field.Name.ToLower() + ";";
                }
            }

            m_Writer.WriteLine(m_Indentation + tmp);
        }
コード例 #5
0
        ///
        /// Write a property of a data class.
        ///
        private void WriteProperty(MemberFieldData field)
        {
            TextInfo ti = new CultureInfo("en-US",false).TextInfo;

            m_Writer.WriteLine (m_Indentation + "[ExposeProperty]");

            string tmp = string.Empty;

            if (field.type == CellType.Enum)
                tmp += "public " + field.Name + " " + field.Name.ToUpper() + " ";
            else
            {
                if (field.IsArrayType)
                    tmp += "public " + field.Type + "[]" + " " + ti.ToTitleCase(field.Name) + " ";
                else
                    tmp += "public " + field.Type + " " + ti.ToTitleCase(field.Name) + " ";
            }

            tmp += "{ get {return " + field.Name.ToLower() + "; } set { " + field.Name.ToLower() + " = value;} }";

            m_Writer.WriteLine (m_Indentation + tmp);
        }
コード例 #6
0
        ///
        /// Write a member field of a data class.
        ///
        private void WriteMemberField(MemberFieldData field)
        {
            m_Writer.WriteLine (m_Indentation + "[SerializeField]");

            string tmp;
            if (field.type == CellType.Enum)
                tmp = field.Name + " " + field.Name.ToLower() + ";";
            else
            {
                if (field.IsArrayType)
                    tmp = field.Type + "[]" + " " + field.Name.ToLower() + " = new " + field.Type + "[0]" +";";
                else
                    tmp = field.Type + " " + field.Name.ToLower() + ";";
            }

            m_Writer.WriteLine (m_Indentation + tmp);
        }