public void OnGUI_Warning_SourceInsidePluginsFolder()
        {
            if (!bSourceInsidePluginsFolder || mLanguageSource.UserAgreesToHaveItInsideThePluginsFolder)
            {
                return;
            }

            LanguageSource source = (LanguageSource)target;

            if (!source.IsGlobalSource())
            {
                bSourceInsidePluginsFolder = false;
                return;
            }

            string pluginPath = UpgradeManager.GetI2LocalizationPath();
            string assetPath  = AssetDatabase.GetAssetPath(source);

            if (!assetPath.StartsWith(pluginPath, StringComparison.OrdinalIgnoreCase))
            {
                bSourceInsidePluginsFolder = false;
                return;
            }

            string Text = @"Its advised to move this Global Source to a folder outside the I2 Localization.
For example (Assets/I2/Resources) instead of (Assets/I2/Localization/Resources)

That way upgrading the plugin its as easy as deleting the I2/Localization and I2/Common folders and reinstalling. 

Do you want the plugin to automatically move the LanguageSource to a folder outside the plugin?";

            EditorGUILayout.HelpBox(Text, MessageType.Warning);

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Keep as is"))
            {
                SerializedProperty Agree = serializedObject.FindProperty("UserAgreesToHaveItInsideThePluginsFolder");
                Agree.boolValue            = true;
                bSourceInsidePluginsFolder = true;
            }

            GUILayout.FlexibleSpace();

            if (GUILayout.Button("Ask me later"))
            {
                bSourceInsidePluginsFolder = false;
            }

            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Move to the Recommended Folder"))
            {
                EditorApplication.delayCall += MoveGlobalSource;
            }

            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            GUILayout.Space(10);
        }
        private static void MoveGlobalSource()
        {
            EditorApplication.delayCall -= MoveGlobalSource;

            string pluginPath = UpgradeManager.GetI2LocalizationPath();
            string assetPath  = AssetDatabase.GetAssetPath(mLanguageSource);

            string I2Path  = pluginPath.Substring(0, pluginPath.Length - "/Localization".Length);
            string newPath = I2Path + "/Resources/" + mLanguageSource.name + ".prefab";

            string fullresFolder = Application.dataPath + I2Path.Replace("Assets", "") + "/Resources";
            bool   folderExists  = System.IO.Directory.Exists(fullresFolder);

            if (!folderExists)
            {
                AssetDatabase.CreateFolder(I2Path, "Resources");
            }
            AssetDatabase.MoveAsset(assetPath, newPath);
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();

            var prefab = AssetDatabase.LoadAssetAtPath(newPath, typeof(GameObject)) as GameObject;

            Selection.activeGameObject = prefab;

            Debug.Log("LanguageSource moved to:" + newPath);
            ShowInfo("Please, ignore some console warnings/errors produced by this operation, everything worked fine. In a new release those warnings will be cleared");
        }
        static string GetPathToGeneratedScriptLocalization()
        {
            string[] assets = AssetDatabase.FindAssets("ScriptLocalization");
            if (assets.Length == 0)
            {
                return(UpgradeManager.GetI2LocalizationPath() + "/Scripts/LocalizationManager.cs");
            }

            string FilePath = AssetDatabase.GUIDToAssetPath(assets[0]);

            return(FilePath);
        }
Beispiel #4
0
        public static string GetI2CommonResourcesPath()
        {
            string I2Path = UpgradeManager.GetI2Path();

            return(I2Path + "/Resources");
        }
Beispiel #5
0
        public static string GetI2Path()
        {
            string pluginPath = UpgradeManager.GetI2LocalizationPath();

            return(pluginPath.Substring(0, pluginPath.Length - "/Localization".Length));
        }
 void OnEnable()
 {
     UpgradeManager.EnablePlugins();
     mAssets = serializedObject.FindProperty("Assets");
 }