GetCleanKey() public static method

Gets the clean key. i.e the key without a type identifier "" etc.
public static GetCleanKey ( string key ) : string
key string /// The full key with the type identifier ///
return string
示例#1
0
	/// <summary> Deletes the localized file from resources.</summary>
	public static void DeleteFileFromResources(string key, SmartCultureInfo cultureInfo)
	{
		string languageFolderPath = string.Empty;
		string cleanKey = LocalizedObject.GetCleanKey(key);
		LocalizedObjectType keyType = LocalizedObject.GetLocalizedObjectType(key);
		
		switch(keyType)
		{
			case LocalizedObjectType.GAME_OBJECT:
			languageFolderPath = LocalizationWorkspace.LanguagePrefabsFolderPathRelative(cultureInfo.languageCode) + "/" + cleanKey + LocalizationWorkspace.prefabFileEnding;
			break;
			
			case LocalizedObjectType.AUDIO:
			languageFolderPath = LocalizationWorkspace.LanguageAudioFolderPathRelative(cultureInfo.languageCode);
			break;
			
			case LocalizedObjectType.TEXTURE:
			languageFolderPath = LocalizationWorkspace.LanguageTexturesFolderPathRelative(cultureInfo.languageCode);
			break;

			case LocalizedObjectType.TEXT_ASSET:
			languageFolderPath = LocalizationWorkspace.LanguageTextAssetsFolderPathRelative(cultureInfo.languageCode);
			break;
			case LocalizedObjectType.FONT:
			languageFolderPath = LocalizationWorkspace.LanguageFontsFolderPathRelative(cultureInfo.languageCode);
			break;
		}

		if(keyType != LocalizedObjectType.GAME_OBJECT)
		{
			string fileExtension = FileUtility.GetFileExtension(cleanKey, languageFolderPath);
			languageFolderPath += "/" + cleanKey + fileExtension;
		}

		if(FileUtility.Exists(Application.dataPath + languageFolderPath))
		{
			AssetDatabase.DeleteAsset("Assets" + languageFolderPath);
		}
		AssetDatabase.Refresh();
	}
示例#2
0
    /// <summary>
    /// Renames the localized file from resources.
    /// </summary>
    /// <param name='key'>
    /// Key.
    /// </param>
    /// <param name='thisCultureInfo'>
    /// This culture info.
    /// </param>
    public static void RenameFileFromResources(string key, string newKey, CultureInfo thisCultureInfo)
    {
        string languageFolderPath       = "/SmartLocalizationLanguage/Resources/Localization/" + thisCultureInfo.Name;
        LocalizedObjectType thisKeyType = LocalizedObject.GetLocalizedObjectType(key);
        string cleanKey    = LocalizedObject.GetCleanKey(key);
        string cleanNewKey = LocalizedObject.GetCleanKey(newKey);

        if (thisKeyType == LocalizedObjectType.GAME_OBJECT)
        {
            languageFolderPath += "/Prefabs/" + cleanKey + ".prefab";
            if (CheckIfFileExists(Application.dataPath + languageFolderPath))
            {
                AssetDatabase.RenameAsset("Assets" + languageFolderPath, cleanNewKey);
            }
        }
        else if (thisKeyType == LocalizedObjectType.AUDIO)
        {
            languageFolderPath += "/Audio Files/";
            string fileExtension = GetFileExtension(cleanKey, languageFolderPath);
            languageFolderPath += cleanKey + fileExtension;

            if (CheckIfFileExists(Application.dataPath + languageFolderPath))
            {
                AssetDatabase.RenameAsset("Assets" + languageFolderPath, cleanNewKey);
            }
        }
        else if (thisKeyType == LocalizedObjectType.TEXTURE)
        {
            languageFolderPath += "/Textures/";
            string fileExtension = GetFileExtension(cleanKey, languageFolderPath);
            languageFolderPath += cleanKey + fileExtension;
            if (CheckIfFileExists(Application.dataPath + languageFolderPath))
            {
                AssetDatabase.RenameAsset("Assets" + languageFolderPath, cleanNewKey);
            }
        }
        AssetDatabase.Refresh();
    }