public override void Deserialize(Dictionary <PCFResourceType, DataBlockBase> dataBlocks, UnityNodeBase parentNode, ResourceResponse resourceResponse, List <Action <UnityNodeBase> > postInstallActions, bool optimizedLoad) { if (!this.isDeserialized) { ResourceBlock dataBlock = dataBlocks[resourceType] as ResourceBlock; AssetResource resource = dataBlock.GetResource(this.referenceID); string jsonString = System.Text.Encoding.UTF8.GetString(resource.GetMetaData()); JObject jsonObject = JObject.Parse(jsonString); animationClip = new AnimationClip(); animationClip.name = jsonObject.Value <string>("name"); animationClip.frameRate = jsonObject.Value <float>("frameRate"); animationClip.wrapMode = (UnityEngine.WrapMode)jsonObject.Value <int>("wrapMode"); animationClip.legacy = true; SerializedAnimationClip serializedAnimationClip = ProtocolBufferSerializer.DeserializeAnimationClipData(resource.GetResourceData()); foreach (int key in serializedAnimationClip.AnimationChannels.Keys) { SerializedAnimationChannelName channel = (SerializedAnimationChannelName)key; SerializedAnimationKeyFrame[] keyFrames = serializedAnimationClip.GetChannel(channel); AnimationCurve curve = CreateAnimationCurve(serializedAnimationClip.PostWrapMode, serializedAnimationClip.PreWrapMode, keyFrames); animationClip.SetCurve("", typeof(Transform), AnimationClipUtils.GetAnimationClipChannelName(channel), curve); } string fieldName = jsonObject.Value <string>("fieldName"); if (resourceResponse != null) { resourceResponse.GetFieldDeserializer.SetField(fieldName, animationClip); } this.isDeserialized = true; } }
public static string GetAnimationClipChannelName(SerializedAnimationChannelName channel) { return(AnimationClipChannelNames[channel]); }