Return to Unity Plugin

How to load .gaf file and from disk ?

All about Unity plug-in

How to load .gaf file and from disk ?

Postby hai quoc » June 5th, 2019, 2:30 am

Hi everyone. I have 2 files .gaf and .png saved at disk when I downloaded from server. And Im using this function to create gaf instance but seem like not working. It showed error gaf missing resources.

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();
}
}
}
}

Can someone show me how ? Thank you :)
User avatar
hai quoc
 
Posts: 1
Joined: May 20th, 2019, 11:36 pm

Re: How to load .gaf file and from disk ?

Postby Nidhi Ajwani » August 29th, 2019, 8:30 pm

Hi,

Did you find a way to do this ? This is something that even I need to do.
User avatar
Nidhi Ajwani
 
Posts: 2
Joined: August 28th, 2019, 1:17 am

Return to Unity Plugin

Who is online

Users browsing this forum: No registered users and 5 guests