예제 #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 EffekseerModelResource LoadAsset(string dirPath, string resPath)
        {
            resPath = Path.ChangeExtension(resPath, ".asset");

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

            var res = new EffekseerModelResource();

            res.path  = resPath;
            res.asset = asset;
            return(res);
        }
예제 #3
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);
                }
            }
        }