Beispiel #1
0
	/// <summary>
	/// Returns true if the window should show, returns false if not.
	/// If false, it will draw an editor label that says the window is unavailable
	/// </summary>
	public static bool ShouldShowWindow(bool isAvailableInPlayMode = false)
	{
		if(Application.isPlaying && !isAvailableInPlayMode)
		{
			GUILayout.Label ("This Smart Localization Window is not available in play mode", EditorStyles.boldLabel);
			if(LanguageManager.HasInstance)
			{
				if(GUILayout.Button("Go to translation window"))
				{
					TranslateLanguageWindow.ShowWindow(LanguageManager.Instance.GetCultureInfo(LanguageManager.Instance.CurrentlyLoadedCulture.languageCode), null);
				}
			}
			return false;
		}
		else if(!LocalizationWorkspace.Exists())
		{
			GUILayout.Label ("There is no localization workspace available in this project", EditorStyles.boldLabel);
			if(GUILayout.Button("Create localization workspace"))
			{
				if(LocalizationWorkspace.Create())
				{
					return true;
				}
			}

			return false;
		}
		else
		{
			return true;
		}
	}
 static void OnPostProcessScene()
 {
     if (LocalizationWorkspace.Exists() &&
         GenerateStorePresence &&
         !HasStorePresence)
     {
         GeneratePresence();
     }
 }
Beispiel #3
0
        /// <summary>
        /// Checks .resx files and converts them into text assets that can be used at runtime
        /// </summary>
        public static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
        {
            //Only use this if there's a localization system created
            if (!LocalizationWorkspace.Exists())
            {
                return;
            }

            foreach (string asset in importedAssets)
            {
                if (asset.EndsWith(LocalizationWorkspace.resXFileEnding))
                {
                    string newFileName = LocalizationWorkspace.ResourcesFolderFilePath() + "/" + Path.GetFileNameWithoutExtension(asset) + LocalizationWorkspace.txtFileEnding;

                    if (!DirectoryUtility.CheckAndCreate(LocalizationWorkspace.ResourcesFolderFilePath()))
                    {
                        return;
                    }

                    //Delete the file if it already exists
                    if (FileUtility.Exists(newFileName))
                    {
                        FileUtility.Delete(newFileName);
                    }

                    string fileData = "";
                    using (StreamReader reader = new StreamReader(asset))
                    {
                        fileData = reader.ReadToEnd();
                    }


                    FileUtility.WriteToFile(newFileName, fileData);

                    SmartCultureInfoCollection allCultures = SmartCultureInfoEx.Deserialize(LocalizationWorkspace.CultureInfoCollectionFilePath());
                    LanguageHandlerEditor.CheckAndSaveAvailableLanguages(allCultures);

                    AssetDatabase.Refresh(ImportAssetOptions.Default);
                }
            }
        }
        /// <summary>
        /// Returns if the key selector should be shown.
        /// </summary>
        /// <returns>Returns if the key selector should be shown.</returns>
        public static bool ShouldShowKeySelector()
        {
            if (Application.isPlaying)
            {
                GUILayout.Label("Feature not available in play mode.", EditorStyles.miniLabel);
                return(false);
            }

            if (!LocalizationWorkspace.Exists())
            {
                GUILayout.Label("There is no Smart Localization workspace created", EditorStyles.miniLabel);
                //There is no language created
                if (GUILayout.Button("Create Workspace"))
                {
                    LocalizationWorkspace.Create();
                }
                return(false);
            }

            return(true);
        }