public static GetFileExtension ( string fullFilePath ) : string | ||
fullFilePath | string | /// Full file path. /// |
Результат | string |
/// <summary> /// Copies the file into the resources folder. Naming the new asset to /// KEY /// </summary> /// <returns> /// The file into resources. /// </returns> /// <param name='objectPair'> /// Object pair. /// </param> public static string CopyFileIntoResources(SerializableLocalizationObjectPair objectPair, CultureInfo thisCultureInfo) { string languageFolderPath = Application.dataPath + "/SmartLocalizationLanguage/Resources/Localization/"; LocFileUtility.CheckAndCreateDirectory(languageFolderPath + thisCultureInfo.Name + "/"); //TODO: Create generic function LocalizedObject objectToCopy = objectPair.changedValue; if (objectToCopy.ObjectType == LocalizedObjectType.AUDIO && objectToCopy.ThisAudioClip != null) { string thisFilePath = languageFolderPath + thisCultureInfo.Name + "/Audio Files/"; string newFileName = objectPair.keyValue; LocFileUtility.CheckAndCreateDirectory(thisFilePath); //Get the current path of the object string currentAssetPath = AssetDatabase.GetAssetPath(objectToCopy.ThisAudioClip); //Get the fileExtension of the asset string fileExtension = LocFileUtility.GetFileExtension(Application.dataPath + currentAssetPath); //Copy or replace the file to the new path FileUtil.ReplaceFile(currentAssetPath, thisFilePath + newFileName + fileExtension); return(AssetDatabase.AssetPathToGUID(currentAssetPath)); } else if (objectToCopy.ObjectType == LocalizedObjectType.TEXTURE && objectToCopy.ThisTexture != null) { string thisFilePath = languageFolderPath + thisCultureInfo.Name + "/Textures/"; string newFileName = objectPair.keyValue; LocFileUtility.CheckAndCreateDirectory(thisFilePath); string currentAssetPath = AssetDatabase.GetAssetPath(objectToCopy.ThisTexture); string fileExtension = LocFileUtility.GetFileExtension(Application.dataPath + currentAssetPath); FileUtil.ReplaceFile(currentAssetPath, thisFilePath + newFileName + fileExtension); return(AssetDatabase.AssetPathToGUID(currentAssetPath)); } else if (objectToCopy.ObjectType == LocalizedObjectType.GAME_OBJECT && objectToCopy.ThisGameObject != null) { string thisFilePath = languageFolderPath + thisCultureInfo.Name + "/Prefabs/"; string newFileName = objectPair.keyValue; LocFileUtility.CheckAndCreateDirectory(thisFilePath); string currentAssetPath = AssetDatabase.GetAssetPath(objectToCopy.ThisGameObject); string fileExtension = LocFileUtility.GetFileExtension(Application.dataPath + currentAssetPath); FileUtil.ReplaceFile(currentAssetPath, thisFilePath + newFileName + fileExtension); return(AssetDatabase.AssetPathToGUID(currentAssetPath)); } else { return(""); } }