Пример #1
0
        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();
        }
Пример #2
0
        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);
        }
Пример #3
0
        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();
        }
Пример #4
0
        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();
        }
Пример #5
0
        public static void CreateUnityFolder(string childPath)
        {
            var fullPath = UnityPathUtility.GetUnityAbsoluteFolderPath(childPath);

            if (CSharpFileUtility.IsFolderExist(fullPath) == false)
            {
                Directory.CreateDirectory(fullPath);
                RefreshAsset();
            }
        }
Пример #6
0
 public static void DeleteUnityFolder(string childPath)
 {
     AssetDatabase.DeleteAsset(UnityPathUtility.GetUnityFolderPath(childPath));
     RefreshAsset();
 }
Пример #7
0
 private static string CombineUnityFullPath(string childPath, string fileName, string extension)
 {
     return(CombineAbsolutePath(UnityPathUtility.GetUnityFolderPath(childPath), fileName, extension));
 }
Пример #8
0
 public static string GetUnityFolderPath(string childPath)
 {
     return(CombineUnityPath(UnityPathUtility.GetUnityPath(), childPath));
 }