Пример #1
0
 static void OnPostprocessAllAssets(
     string[] importedAssets,
     string[] deletedAssets,
     string[] movedAssets,
     string[] movedFromPaths)
 {
     foreach (string assetPath in importedAssets)
     {
         if (Path.GetExtension(assetPath) == ".efk")
         {
             EffekseerEffectAsset.CreateAsset(assetPath);
         }
         if (Path.GetExtension(assetPath) == ".efkmodel")
         {
             EffekseerModelAsset.CreateAsset(assetPath);
         }
         if (Path.GetExtension(assetPath) == ".efkproj")
         {
             EffekseerTool.Core.LoadFrom(assetPath);
             var exporter = new EffekseerTool.Binary.Exporter();
             var data     = exporter.Export(1);
             EffekseerEffectAsset.CreateAsset(assetPath, data);
         }
     }
 }
Пример #2
0
        public static EffekseerSoundResource LoadAsset(string dirPath, string resPath)
        {
            AudioClip clip = AssetDatabase.LoadAssetAtPath <AudioClip>(EffekseerEffectAsset.NormalizeAssetPath(dirPath + "/" + resPath));

            EffekseerSoundResource res = new EffekseerSoundResource();

            res.path = resPath;
            res.clip = clip;
            return(res);
        }
Пример #3
0
        public static EffekseerTextureResource LoadAsset(string dirPath, string resPath)
        {
            Texture2D texture = AssetDatabase.LoadAssetAtPath <Texture2D>(EffekseerEffectAsset.NormalizeAssetPath(dirPath + "/" + resPath));

            var res = new EffekseerTextureResource();

            res.path    = resPath;
            res.texture = texture;
            return(res);
        }
Пример #4
0
        static void OnPostprocessAllAssets(
            string[] importedAssets,
            string[] deletedAssets,
            string[] movedAssets,
            string[] movedFromPaths)
        {
            // Hack for EffekseerMaterial

            if (importedAssets.Any(_ => System.IO.Path.GetExtension(_) == ".asset"))
            {
                foreach (string assetPath in importedAssets)
                {
                    if (Path.GetExtension(assetPath) == ".asset")
                    {
                        var asset = AssetDatabase.LoadAssetAtPath <EffekseerMaterialAsset>(assetPath);

                        if (asset != null)
                        {
                            asset.AttachShader(assetPath);
                        }
                    }
                }
            }

            foreach (string assetPath in importedAssets)
            {
                if (Path.GetExtension(assetPath) == ".efk")
                {
                    EffekseerEffectAsset.CreateAsset(assetPath);
                }
                if (Path.GetExtension(assetPath) == ".efkmodel")
                {
                    EffekseerModelAsset.CreateAsset(assetPath);
                }
                if (Path.GetExtension(assetPath) == ".efkmat")
                {
                    EffekseerMaterialAsset.ImportingAsset importingAsset = new EffekseerMaterialAsset.ImportingAsset();
                    importingAsset.Data = System.IO.File.ReadAllBytes(assetPath);
                    importingAsset.UserTextureSlotMax = EffekseerTool.Constant.UserTextureSlotCount;
                    var info = new EffekseerTool.Utl.MaterialInformation();
                    info.Load(System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), assetPath));

                    importingAsset.CustomData1Count = info.CustomData1Count;
                    importingAsset.CustomData2Count = info.CustomData2Count;
                    importingAsset.HasRefraction    = info.HasRefraction;
                    importingAsset.ShadingModel     = info.ShadingModel;

                    foreach (var u in info.Uniforms)
                    {
                        var up = new EffekseerMaterialAsset.UniformProperty();
                        up.Name        = u.Name;
                        up.UniformName = u.UniformName;
                        up.Count       = u.Type;
                        importingAsset.Uniforms.Add(up);
                    }

                    foreach (var t in info.Textures)
                    {
                        var tp = new EffekseerMaterialAsset.TextureProperty();
                        tp.Name        = t.Name;
                        tp.UniformName = t.UniformName;
                        importingAsset.Textures.Add(tp);
                    }

                    importingAsset.IsCacheFile = false;
                    importingAsset.Code        = info.Code;

                    EffekseerMaterialAsset.CreateAsset(assetPath, importingAsset);
                }
                if (Path.GetExtension(assetPath) == ".efkmatd")
                {
                    EffekseerMaterialAsset.ImportingAsset importingAsset = new EffekseerMaterialAsset.ImportingAsset();
                    importingAsset.Data        = System.IO.File.ReadAllBytes(assetPath);
                    importingAsset.IsCacheFile = true;

                    EffekseerMaterialAsset.CreateAsset(assetPath, importingAsset);
                }
                if (Path.GetExtension(assetPath) == ".efkproj")
                {
                    EffekseerTool.Core.LoadFrom(assetPath);
                    var exporter = new EffekseerTool.Binary.Exporter();
                    var data     = exporter.Export(1);
                    EffekseerEffectAsset.CreateAsset(assetPath, data);
                }
                if (Path.GetExtension(assetPath) == ".efkefc")
                {
                    var fullpath = System.IO.Path.GetFullPath(assetPath);
                    if (!System.IO.File.Exists(fullpath))
                    {
                        return;
                    }
                    var allData = System.IO.File.ReadAllBytes(fullpath);

                    if (allData.Length < 24)
                    {
                        return;
                    }

                    if (allData[0] != 'E' ||
                        allData[1] != 'F' ||
                        allData[2] != 'K' ||
                        allData[3] != 'E')
                    {
                        return;
                    }

                    var version = System.BitConverter.ToInt32(allData, 4);

                    var chunkData = allData.Skip(8).ToArray();

                    var chunk = new EffekseerTool.IO.Chunk();
                    chunk.Load(chunkData);

                    var binBlock = chunk.Blocks.FirstOrDefault(_ => _.Chunk == "BIN_");
                    if (binBlock == null)
                    {
                        return;
                    }

                    EffekseerEffectAsset.CreateAsset(assetPath, binBlock.Buffer);
                }
            }
        }
Пример #5
0
        public static EffekseerMaterialResource LoadAsset(string dirPath, string resPath)
        {
            resPath = Path.ChangeExtension(resPath, ".asset");

            EffekseerMaterialAsset asset = AssetDatabase.LoadAssetAtPath <EffekseerMaterialAsset>(EffekseerEffectAsset.NormalizeAssetPath(dirPath + "/" + resPath));

            var res = new EffekseerMaterialResource();

            res.path  = resPath;
            res.asset = asset;
            return(res);
        }
Пример #6
0
 public void SetEffect(int index)
 {
     currentEffect = effectAssets[index];
 }