//[MenuItem( "Tools/I2 Localization/Create I2Languages", false, 1)]
        public static void CreateLanguageSources()
        {
            if (LocalizationManager.GlobalSources == null || LocalizationManager.GlobalSources.Length == 0)
            {
                return;
            }

            Object             GlobalSource = Resources.Load(LocalizationManager.GlobalSources[0]);
            LanguageSourceData sourceData   = null;
            string             sourcePath   = null;

            if (GlobalSource != null)
            {
                if (GlobalSource is GameObject)
                {
                    // I2Languages was a prefab before 2018.3, it should be converted to an ScriptableObject
                    sourcePath = AssetDatabase.GetAssetPath(GlobalSource);
                    LanguageSource langSourceObj = (GlobalSource as GameObject).GetComponent <LanguageSource>();
                    sourceData = langSourceObj.mSource;
                }
                else
                {
                    return;
                }
            }

            LanguageSourceAsset asset = ScriptableObject.CreateInstance <LanguageSourceAsset>();

            if (sourceData != null)
            {
                asset.mSource = sourceData;
                AssetDatabase.DeleteAsset(sourcePath);
            }

            if (string.IsNullOrEmpty(sourcePath))
            {
                //string PluginPath = GetI2LocalizationPath();
                string ResourcesFolder = "Assets/Resources";//PluginPath.Substring(0, PluginPath.Length-"/Localization".Length) + "/Resources";

                string fullresFolder = Application.dataPath + ResourcesFolder.Replace("Assets", "");
                if (!System.IO.Directory.Exists(fullresFolder))
                {
                    System.IO.Directory.CreateDirectory(fullresFolder);
                }

                sourcePath = ResourcesFolder + "/" + LocalizationManager.GlobalSources[0] + ".asset";
            }
            else
            {
                sourcePath = sourcePath.Replace(".prefab", ".asset");
            }

            AssetDatabase.CreateAsset(asset, sourcePath);
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();
        }
Beispiel #2
0
        public static void OpenGlobalSource()
        {
            CreateLanguageSources();
            LanguageSourceAsset GO = Resources.Load <LanguageSourceAsset>(LocalizationManager.GlobalSources[0]);

            if (GO == null)
            {
                Debug.Log("Unable to find Global Language at Assets/Resources/" + LocalizationManager.GlobalSources[0] + ".asset");
            }

            Selection.activeObject = GO;
        }
        static void RegisterSourceInResources()
        {
            // Find the Source that its on the Resources Folder
            foreach (string SourceName in GlobalSources)
            {
                LanguageSourceAsset sourceAsset = (ResourceManager.pInstance.GetAsset <LanguageSourceAsset>(SourceName));

                if (sourceAsset && !Sources.Contains(sourceAsset.mSource))
                {
                    if (!sourceAsset.mSource.mIsGlobalSource)
                    {
                        sourceAsset.mSource.mIsGlobalSource = true;
                    }
                    sourceAsset.mSource.owner = sourceAsset;
                    AddSource(sourceAsset.mSource);
                }
            }
        }