Example #1
0
        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);

                UInt32 pointedNodeID = BitConverter.ToUInt32(resource.GetResourceData(), 0);

                postInstallActions.Add((UnityNodeBase rootNode) => {
                    UnityNodeBase referencedNode = FindNodeWithID(rootNode, pointedNodeID);

                    if (referencedNode is UnityAnimationClipNode)
                    {
                        UnityAnimationClipNode animationClip = referencedNode as UnityAnimationClipNode;

                        AnimationClip animation = animationClip.GetAnimationClip();

                        string jsonString  = System.Text.Encoding.UTF8.GetString(resource.GetMetaData());
                        JObject jsonObject = JObject.Parse(jsonString);

                        string fieldName = jsonObject.Value <string>("fieldName");
                        if (resourceResponse != null)
                        {
                            resourceResponse.GetFieldDeserializer.SetField(fieldName, animation);
                        }
                    }
                });

                this.isDeserialized = true;
            }
        }
Example #2
0
        public UnityNodeBase CreateNodeImplementation(string nodeName, PCFResourceType resourceType, UInt32 referenceID)
        {
            UnityNodeBase recreatedNode = null;

            if (this.customCreators != null && this.customCreators.ContainsKey(resourceType))
            {
                recreatedNode = this.customCreators[resourceType](nodeName, resourceType, referenceID);
            }
            else
            {
                switch (resourceType)
                {
                case PCFResourceType.ROOT:
                    recreatedNode = new UnityRootNode(nodeName, referenceID);
                    break;

                case PCFResourceType.OBJECT:
                    recreatedNode = new UnityObjectNode(nodeName, referenceID);
                    break;

                case PCFResourceType.TRANSFORM:
                    recreatedNode = new UnityTransformNode(nodeName, resourceType, referenceID);
                    break;

                case PCFResourceType.TRANSFORMPOINTER:
                    recreatedNode = new UnityTransformPointerNode(nodeName, resourceType, referenceID);
                    break;

                case PCFResourceType.MESH:
                    recreatedNode = new UnityMeshNode(nodeName, resourceType, referenceID);
                    break;

                case PCFResourceType.ANIMATOR:
                    recreatedNode = new UnityAnimatorNode(nodeName, resourceType, referenceID);
                    break;

                case PCFResourceType.AUDIO:
                    recreatedNode = new UnityAudioNode(nodeName, resourceType, referenceID);
                    break;

                case PCFResourceType.AVATAR:
                    recreatedNode = new UnityAvatarReferenceNode(nodeName, resourceType, referenceID);
                    break;

                case PCFResourceType.SKINNEDMESH:
                    recreatedNode = new UnitySkinnedMeshNode(nodeName, resourceType, referenceID);
                    break;

                case PCFResourceType.SCRIPT:
                    recreatedNode = new UnityScriptNode(nodeName, resourceType, referenceID, null);
                    break;

                case PCFResourceType.MATERIAL:
                    recreatedNode = new UnityMaterialNode(nodeName, resourceType, referenceID);
                    break;

                case PCFResourceType.MATERIALPOINTER:
                    recreatedNode = new UnityMaterialPointerNode(nodeName, resourceType, referenceID);
                    break;

                case PCFResourceType.TEXTURE:
                    recreatedNode = new UnityTextureNode(nodeName, resourceType, referenceID);
                    break;

                case PCFResourceType.CAMERA:
                    recreatedNode = new UnityCameraNode(nodeName, resourceType, referenceID);
                    break;

                case PCFResourceType.LIGHT:
                    recreatedNode = new UnityLightNode(nodeName, resourceType, referenceID);
                    break;

                case PCFResourceType.LIGHTPROBES:
                    recreatedNode = new UnityLightProbesNode(nodeName, resourceType, referenceID);
                    break;

                case PCFResourceType.COLLIDER:
                    recreatedNode = new UnityColliderNode(nodeName, resourceType, referenceID);
                    break;

                case PCFResourceType.PRIMITIVE:
                    recreatedNode = new UnityPrimitiveNode(nodeName, resourceType, referenceID);
                    break;

                case PCFResourceType.COLLECTION:
                    recreatedNode = new UnityCollectionNode(nodeName, resourceType, referenceID);
                    break;

                case PCFResourceType.POINTERCOLLECTION:
                    recreatedNode = new UnityPointerCollectionNode(nodeName, resourceType, referenceID);
                    break;

                case PCFResourceType.CLASS:
                    recreatedNode = new UnityClassNode(nodeName, resourceType, referenceID);
                    break;

                case PCFResourceType.INTERNALBUNDLE:
                    recreatedNode = new UnityInternalBundleNode(nodeName, resourceType, referenceID);
                    break;

                case PCFResourceType.GRADIENT:
                    recreatedNode = new UnityGradientNode(nodeName, resourceType, referenceID);
                    break;

                case PCFResourceType.ANIMATION:
                    recreatedNode = new UnityAnimationNode(nodeName, resourceType, referenceID);
                    break;

                case PCFResourceType.ANIMATIONCLIP:
                    recreatedNode = new UnityAnimationClipNode(nodeName, resourceType, referenceID);
                    break;

                case PCFResourceType.ANIMATIONCLIPREFERENCE:
                    recreatedNode = new UnityAnimationClipPointerNode(nodeName, resourceType, referenceID);
                    break;
                }
            }


            return(recreatedNode);
        }