Ejemplo n.º 1
0
        private void CreateConstants()
        {
            GenerateFileList();

            string ns        = string.Format("{0}.{1}", CodifyString(PlayerSettings.companyName), CodifyString(PlayerSettings.productName)); // TODO jsmellie: I should probably put this in something shared...  I now use this in multiple places
            string className = "TestConstants";

            switch (m_Data.ConstantNameGenerationType)
            {
            case eConstantNameGenerationType.USER_SPECIFIED:
                className = m_Data.SpecifiedConstantName;
                if (!className.EndsWith(CONSTANT_NAME_ENDING))
                {
                    className += CONSTANT_NAME_ENDING;
                }
                break;

            case eConstantNameGenerationType.AUTO_GENERATION:
                className = Path.GetFileName(m_PathStub) + CONSTANT_NAME_ENDING;
                break;
            }
            string path = Application.dataPath + ROOT_PATH + m_PathStub + Path.DirectorySeparatorChar;

            ResourceConstantsGenerator generator = new ResourceConstantsGenerator();

            generator.Session = new Dictionary <string, object>();
            generator.Session["m_Namespace"]           = ns;
            generator.Session["m_ClassName"]           = className;
            generator.Session["m_ConstantsDictionary"] = new Dictionary <string, string[]>()
            {
                { "Unsorted", m_LocalFiles.ToArray() }
            };

            generator.Initialize();

            string fileText = generator.TransformText();

            if (!System.IO.Directory.Exists(path))
            {
                System.IO.Directory.CreateDirectory(path);
            }

            System.IO.File.WriteAllText(path + className + FILE_EXTENSION, fileText);

            AssetDatabase.Refresh();
        }
Ejemplo n.º 2
0
        private void CreateConstants()
        {
            if (m_LocalFiles == null)
            {
                m_LocalFiles = new List<string>();
            }
            else
            {
                m_LocalFiles.Clear();
            }

            // Grab all the files
            string[] allFiles = GetAllFiles(m_FullPath);

            if (allFiles.Length > 0)
            {
                for (int i = 0; i < allFiles.Length; ++i)
                {
                    allFiles[i] = allFiles[i].Replace('\\', '/');
                    if (IsValidPath(allFiles[i]))
                    {
                        m_LocalFiles.Add(allFiles[i]);
                    }
                }
            }

            string ns = string.Format("{0}.{1}", CodifyString(PlayerSettings.companyName), CodifyString(PlayerSettings.productName)); // TODO jsmellie: I should probably put this in something shared...  I now use this in multiple places
            string className = "TestConstants";
            string path = Application.dataPath + ROOT_PATH + m_PathStub + Path.DirectorySeparatorChar;

            ResourceConstantsGenerator generator = new ResourceConstantsGenerator();

            generator.Session = new Dictionary<string, object>();
            generator.Session["m_Namespace"] = ns;
            generator.Session["m_ClassName"] = className;
            generator.Session["m_ConstantsDictionary"] = new Dictionary<string, string[]>()
            {
                { "Unsorted", m_LocalFiles.ToArray() }
            };

            generator.Initialize();

            string fileText = generator.TransformText();

            if (!System.IO.Directory.Exists(path))
            {
                System.IO.Directory.CreateDirectory(path);
            }

            System.IO.File.WriteAllText(path + className + FILE_EXTENSION, fileText);

            AssetDatabase.Refresh();
        }