public static void CreateTestPng(string childPath, string fileName, TextureColor color) { var path = UnityPathUtility.GetUnityAbsoluteFullPath(childPath, fileName, GetExtension(FileType.Png)); var texture2D = Texture2D.normalTexture; switch (color) { case TextureColor.black: texture2D = Texture2D.blackTexture; break; case TextureColor.white: texture2D = Texture2D.whiteTexture; break; default: texture2D = Texture2D.normalTexture; break; } var bytes = texture2D.EncodeToPNG(); File.WriteAllBytes(path, bytes); RefreshAsset(); }
public static bool CreateAssetFile(FileType fileType, string childPath, string fileName) { var fileNotExist = IsFileInPath(UnityPathUtility.GetUnityFullPath(childPath), fileName, fileType) == false; if (fileNotExist) { if (IsUnityFolderExist(childPath) == false) { CreateUnityFolder(childPath); } switch (fileType) { case FileType.AnimatorOverride: CreateUnityAsset(childPath, fileName, typeof(AnimatorOverrideController), GetExtension(fileType)); break; case FileType.AnimationClip: CreateUnityAsset(childPath, fileName, typeof(AnimationClip), GetExtension(fileType)); break; case FileType.Png: CreatePng(childPath, fileName); break; default: throw new ArgumentOutOfRangeException(nameof(fileType), fileType, null); } RefreshAsset(); } return(fileNotExist); }
public static void CreateUnityAsset(string childPath, string fileName, Type type, string extension) { var instance = (Object)Activator.CreateInstance(type); var path = UnityPathUtility.GetUnityFullPath(childPath, fileName, extension); AssetDatabase.CreateAsset(instance, path); RefreshAsset(); }
public static void CreatePng(string childPath, string fileName) { var path = UnityPathUtility.GetUnityAbsoluteFullPath(childPath, fileName, GetExtension(FileType.Png)); var texture2D = Texture2D.blackTexture; var bytes = texture2D.EncodeToPNG(); File.WriteAllBytes(path, bytes); RefreshAsset(); }
public static void CreateUnityFolder(string childPath) { var fullPath = UnityPathUtility.GetUnityAbsoluteFolderPath(childPath); if (CSharpFileUtility.IsFolderExist(fullPath) == false) { Directory.CreateDirectory(fullPath); RefreshAsset(); } }
public static void DeleteUnityFolder(string childPath) { AssetDatabase.DeleteAsset(UnityPathUtility.GetUnityFolderPath(childPath)); RefreshAsset(); }
private static string CombineUnityFullPath(string childPath, string fileName, string extension) { return(CombineAbsolutePath(UnityPathUtility.GetUnityFolderPath(childPath), fileName, extension)); }
public static string GetUnityFolderPath(string childPath) { return(CombineUnityPath(UnityPathUtility.GetUnityPath(), childPath)); }