从服务器下载时,我在磁盘上保存了两个文件.gaf和.png。我使用此功能创建了gaf实例,但似乎无法正常工作。它显示了错误信息并丢失了资源。
void CreateAsset()
{
string assetName = Ulti.GetPath(storyName + "/") + dataStorySection.arrDataImages[0].gafPath;
if (assetName.EndsWith(".gaf", StringComparison.Ordinal))
{
byte[] fileBytes = null;
using (BinaryReader freader = new BinaryReader(File.OpenRead(assetName)))
{
fileBytes = freader.ReadBytes((int)freader.BaseStream.Length);
}
Debug.LogError("fileBytes : " + fileBytes.Length + " - sizeof(int) : " + sizeof(int));
if (fileBytes.Length > sizeof(int))
{
int header = BitConverter.ToInt32(fileBytes.Take(4).ToArray(), 0);
if (GAFHeader.isCorrectHeader((GAFHeader.CompressionType)header))
{
GAFAnimationAsset animationAsset = ScriptableObject.CreateInstance<GAFAnimationAsset>();
//animationAsset = GAFEditorUtils.SaveAsset(animationAsset, Path.GetDirectoryName(assetName) + "/" + Path.GetFileNameWithoutExtension(assetName) + "_swf.asset");
//GAFResourceManagerInternal.instance.createResources<GAFTexturesResourceInternal>(GafClip.asset);
animationAsset.initialize(fileBytes, "", "");
List<string> lst = animationAsset.resourcesPaths;
//GAFTracking.sendAssetCreatedRequest(assetName);
movieClip.initialize(animationAsset);
movieClip.reload();
movieClip.play();
}
}
}
}
有人可以告诉我怎么做吗?谢谢:)