Ejemplo n.º 1
0
        /// <summary>
        /// Load the specified CSV file.
        /// </summary>

        static bool LoadCSV(byte[] bytes, TextAsset asset, bool merge = false)
        {
            if (bytes == null)
            {
                return(false);
            }
            GameByteReader reader = new GameByteReader(bytes);

            // The first line should contain "KEY", followed by languages.
            GameBetterList <string> temp = reader.ReadCSV();

            // There must be at least two columns in a valid CSV file
            if (temp.size < 2)
            {
                return(false);
            }

            // Clear the dictionary
            if (!merge || temp.size - 1 != mLanguage.Length)
            {
                merge = false;
                mDictionary.Clear();
            }

            temp[0]    = "KEY";
            mLanguages = new string[temp.size - 1];
            for (int i = 0; i < mLanguages.Length; ++i)
            {
                mLanguages[i] = temp[i + 1];
            }

            // Read the entire CSV file into memory
            while (temp != null)
            {
                AddCSV(temp, !merge);
                temp = reader.ReadCSV();
            }
            return(true);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Set the localization data directly.
        /// </summary>

        static public void Set(string languageName, byte[] bytes)
        {
            GameByteReader reader = new GameByteReader(bytes);

            Set(languageName, reader.ReadDictionary());
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Load the specified asset and activate the localization.
        /// </summary>

        static public void Load(TextAsset asset)
        {
            GameByteReader reader = new GameByteReader(asset);

            Set(asset.name, reader.ReadDictionary());
        }