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); }
public override void Serialize(SerializedAssets serializedAssets, object[] serializeOptions, NodeBase objNode, List <Action <NodeBase> > postSerializeActions) { #if UNITY_EDITOR //Make sure this is always 36 characters long. this.referenceID = this.rootNode.GenerateID(); ComponentNode componentNode = new ComponentNode(PCFResourceType.TEXTURE, referenceID, null); //Component nodes must always be parented to objNodes. objNode.AddChildNode(componentNode); if (this.texture != null) { TextureSerializeOpts serializeOption = null; for (int i = 0; i < serializeOptions.Length; i++) { object opt = serializeOptions[i]; if (opt is TextureSerializeOpts) { serializeOption = opt as TextureSerializeOpts; break; } } if (serializeOption == null) { return; } //Create serialized asset by converting data to a bytearray and give it to the constructor. AssetResource resource = new AssetResource(false); TextureDataFormat format = TextureDataFormat.Empty; byte[] textureData = serializeOption.PackageTexture(this.texture, serializedAssets, referenceID, ref format); JObject metaData = new JObject(); metaData["width"] = this.texture.width; metaData["height"] = this.texture.height; metaData["textureFormat"] = (int)format; byte[] metaDataBuffer = System.Text.Encoding.UTF8.GetBytes(metaData.ToString(Formatting.None)); resource.Serialize(referenceID, MetaDataType.JSON, metaDataBuffer, textureData); serializedAssets.AddResource(referenceID, PCFResourceType.TEXTURE, resource); //Nodes store their resource when serializing componentNode.SetSerializer(this); } #endif }