コード例 #1
0
ファイル: LocaData.cs プロジェクト: MadlenThaleiser/MyGyruss
        public static LocaData Load(string pLanguageShort)
        {
            LocaData lData = new LocaData();

            lData.xmlData          = new XmlLocaData();
            lData.xmlData.language = pLanguageShort;

            string path = "loca/loca_" + pLanguageShort;

            try
            {
                // iOS related crash with connected Xcode (EXC_BAD_ACCESS) - check for file 'exists'
                TextAsset ta = Resources.Load <TextAsset>(path);
                if (ta == null)
                {
                    throw new FileNotFoundException("File not found: " + path);
                }

                MemoryStream ms = new MemoryStream(ta.bytes);

                XmlSerializer s    = new XmlSerializer(typeof(XmlLocaData));
                XmlLocaData   data = s.Deserialize(ms) as XmlLocaData;

                lData.xmlData = data;

                lData.xmlData.PostRead();
            }
            catch (Exception e)
            {
                Debug.LogWarning("Error loading loca file for requested language. " + e.Message);
            }

            return(lData);
        }
コード例 #2
0
ファイル: LocaData.cs プロジェクト: MadlenThaleiser/MyGyruss
        public static LocaData LoadFromEditor(string pLanguageShort)
        {
            UnityEditor.AssetDatabase.Refresh();
            LocaData lData = new LocaData();
            string   path  = Application.dataPath + "/Resources/loca/loca_" + pLanguageShort;

            try
            {
                FileInfo file = new FileInfo(path);
                if (!file.Exists)
                {
                    Debug.LogWarning("Localization: File not found: " + file.FullName);
                    return(lData);
                }

                path = Path.GetFileName(path);
                path = "Assets/Resources/loca/" + path;

                TextAsset ta = UnityEditor.AssetDatabase.LoadAssetAtPath(path, typeof(TextAsset)) as TextAsset;

                Debug.Log(ta.text.Length);

                MemoryStream ms = new MemoryStream(ta.bytes);

                XmlSerializer s    = new XmlSerializer(typeof(XmlLocaData));
                XmlLocaData   data = s.Deserialize(ms) as XmlLocaData;

                lData.xmlData = data;

                lData.xmlData.PostRead();
            }
            catch (Exception e)
            {
                Debug.LogWarning("Error loading loca file for requested language. " + e.Message);
                lData.xmlData          = new XmlLocaData();
                lData.xmlData.language = pLanguageShort;
            }

            return(lData);
        }