public override void SerializePCF(GameObject go, string outputDirectory, Action <bool, string> OnComplete)
        {
            Debug.Log("serialize generic object to directory: " + outputDirectory);

            DirectoryInfo outDir = new DirectoryInfo(outputDirectory);

            if (!outDir.Exists)
            {
                outDir.Create();
            }

            //These export objects are custom to our project, override if specific behaviour needed.
            object[] opts = new object[4];
            opts[0] = new TextureSerializeOpts(TexturePackageOptions.ASTCPackage);
            opts[1] = new AvatarSerializeOpts("Transform");
            opts[2] = new AudioSerializeOpts();
            opts[3] = new LightprobeSerializeOpts(Path.Combine(Application.dataPath, "LightingData"));

            string outputFile = Path.Combine(outputDirectory, go.name + ".pcf");

            ExportUtils.AddVersionInfo(go);
            SerializeContent(go, opts, outputDirectory, outputFile, PCFfileType.Unknown);
            ExportUtils.AddChecksum(outputFile);

            OnComplete(true, "Success exporting content: " + go.name);
        }
示例#2
0
        public override void Serialize(SerializedAssets serializedAssets, object[] serializeOptions, NodeBase objNode, List <Action <NodeBase> > postSerializeActions)
        {
            //Make sure this is always 36 characters long.
            this.referenceID = this.rootNode.GenerateID();

            AvatarSerializeOpts serializeOption = null;

            for (int i = 0; i < serializeOptions.Length; i++)
            {
                object opt = serializeOptions[i];

                if (opt is AvatarSerializeOpts)
                {
                    serializeOption = opt as AvatarSerializeOpts;
                    break;
                }
            }

            if (serializeOption == null)
            {
                return;
            }

            ComponentNode componentNode = new ComponentNode(PCFResourceType.AVATAR, referenceID, null);

            //Component nodes must always be parented to objNodes.
            objNode.AddChildNode(componentNode);

            JObject metaData = serializeOption.SerializeAvatar(this.parentGO, this.animator);

            //Create serialized asset by converting data to a bytearray and give it to the constructor.
            AssetResource resource = new AssetResource(false);

            byte[] metaDataBuffer = System.Text.Encoding.UTF8.GetBytes(metaData.ToString(Formatting.None));
            resource.Serialize(referenceID, MetaDataType.JSON, metaDataBuffer, null);

            serializedAssets.AddResource(referenceID, PCFResourceType.AVATAR, resource);

            //Nodes store their resource when serializing
            componentNode.SetSerializer(this);
        }