예제 #1
0
        public void Write(AssetWriter writer)
        {
            if (HasCurrentChannels(writer.Version))
            {
                writer.Write(CurrentChannels);
            }
            writer.Write(VertexCount);

            if (HasChannels(writer.Version))
            {
                writer.WriteAssetArray(Channels);
                writer.AlignStream(AlignType.Align4);
            }
            if (HasStreams(writer.Version))
            {
                if (IsStreamStatic(writer.Version))
                {
                    for (int i = 0; i < StaticStreamCount; i++)
                    {
                        writer.WriteAsset(Streams[i]);
                    }
                }
                else
                {
                    writer.WriteAssetArray(Channels);
                }
            }

            writer.WriteArray(Data);
            writer.AlignStream(AlignType.Align4);
        }
예제 #2
0
        public void CanSerializeTreeCollection()
        {
            var entity0 = new Entity(new VariableCollection());
            var entity1 = new Entity(new VariableCollection());
            var entity2 = new Entity(new VariableCollection());
            var entity3 = new Entity(new VariableCollection());

            entity1.Parent = entity0;
            entity2.Parent = entity0;
            entity3.Parent = entity1;

            entity0.AddComponent <FakeComp>();
            entity1.AddComponent <FakeComp>();
            entity1.AddComponent <FakeComp>();
            entity2.AddComponent <FakeComp>();
            entity3.AddComponent <FakeComp>();

            collection.Add(entity0);


            Stream stream = new MemoryStream();

            AssetWriter.WriteAsset(stream, collection, new TypeWriterFactory());
            stream.Position = 0;
            var collection2 = AssetReader.ReadAsset <EntityCollection>(stream, new TypeReaderFactory());
        }
예제 #3
0
        internal void _WriteToExternal(string uri, AssetWriter writer)
        {
            this._uri        = uri;
            this._byteLength = _Data.Length;

            writer(uri, _Data);
        }
예제 #4
0
 public void Write(AssetWriter writer)
 {
     writer.Write(Left);
     writer.Write(Right);
     writer.Write(Top);
     writer.Write(Bottom);
 }
 public void Write(AssetWriter writer)
 {
     writer.Write(CompressedFormat);
     writer.Write(UncompressedFormat);
     if (HasRecommendedFormat(writer.Version))
     {
         writer.Write(RecommendedFormat);
     }
     if (HasDesiredFormat(writer.Version))
     {
         writer.Write(DesiredFormat);
     }
     writer.Write(UsageMode);
     writer.Write(ColorSpace);
     if (HasAndroidETC2Fallback(writer.Version))
     {
         writer.Write(AndroidETC2FallbackFormat);
     }
     writer.Write(Width);
     writer.Write(Height);
     writer.Write(CompressionQuality);
     if (HasAndroidETC2Fallback(writer.Version))
     {
         writer.Write(AndroidETC2FallbackDownscale);
         writer.AlignStream();
     }
 }
예제 #6
0
 public void Write(AssetWriter writer)
 {
     writer.Write(Name);
     writer.Write(NameHash);
     writer.Write(FrameIndex);
     writer.Write(FrameCount);
 }
예제 #7
0
 public void Write(AssetWriter writer)
 {
     Renderers.Write(writer);
     if (IsAlign(writer.Version))
     {
         writer.AlignStream();
     }
     Systems.Write(writer);
     if (IsAlign(writer.Version))
     {
         writer.AlignStream();
     }
     if (HasProbesets(writer.Version))
     {
         Probesets.Write(writer);
         writer.AlignStream();
     }
     SystemAtlases.Write(writer);
     if (IsAlign(writer.Version))
     {
         writer.AlignStream();
     }
     if (HasTerrainChunks(writer.Version))
     {
         TerrainChunks.Write(writer);
         if (IsAlign(writer.Version))
         {
             writer.AlignStream();
         }
     }
 }
예제 #8
0
        public void Write(AssetWriter writer)
        {
            Vertices.Write(writer);
            UV.Write(writer);
            if (HasBindPoses(writer.Version))
            {
                BindPoses.Write(writer);
            }

            Normals.Write(writer);
            Tangents.Write(writer);
            Weights.Write(writer);
            NormalSigns.Write(writer);
            TangentSigns.Write(writer);
            if (HasFloatColors(writer.Version))
            {
                FloatColors.Write(writer);
            }

            BoneIndices.Write(writer);
            Triangles.Write(writer);
            if (HasColors(writer.Version))
            {
                Colors.Write(writer);
            }
            if (HasUVInfo(writer.Version))
            {
                writer.Write(UVInfo);
            }
        }
예제 #9
0
        public void Write(AssetWriter writer)
        {
            if (HasSkyLightColor(writer.Version))
            {
                SkyLightColor.Write(writer);
                writer.Write(SkyLightIntensity);
            }

            writer.Write(BounceScale);
            writer.Write(IndirectOutputScale);
            writer.Write(AlbedoBoost);
            if (HasTemporalCoherenceThreshold(writer.Version))
            {
                writer.Write(TemporalCoherenceThreshold);
            }
            if (HasDynamicEnv(writer.Version))
            {
                writer.Write(DynamicEnv);
            }
            else
            {
                writer.Write((int)EnvironmentLightingMode);
                writer.Write(EnableBakedLightmaps);
                writer.Write(EnableRealtimeLightmaps);
            }
            writer.AlignStream();
        }
예제 #10
0
 public void Write(AssetWriter writer)
 {
     writer.WriteAsset(Vertex);
     writer.WriteAsset(Normal);
     writer.WriteAsset(Tangent);
     writer.Write(Index);
 }
예제 #11
0
        public override void Write(AssetWriter writer)
        {
            base.Write(writer);

#if UNIVERSAL
            MonoBehaviourLayout layout = writer.Layout.MonoBehaviour;
            if (layout.HasEditorHideFlags)
            {
                writer.Write((uint)EditorHideFlags);
            }
            if (layout.HasGeneratorAsset)
            {
                GeneratorAsset.Write(writer);
            }
#endif

            Script.Write(writer);
            writer.Write(Name);

#if UNIVERSAL
            if (layout.HasEditorClassIdentifier)
            {
                writer.Write(EditorClassIdentifier);
            }
#endif

            if (Structure != null)
            {
                Structure.Write(writer);
            }
        }
예제 #12
0
 public void Write(AssetWriter writer)
 {
     writer.Write(X);
     writer.Write(Y);
     writer.Write(Z);
     writer.Write(W);
 }
예제 #13
0
 public void Write(AssetWriter writer)
 {
     writer.Write(BakedConvexCollisionMesh);
     writer.AlignStream();
     writer.Write(BakedTriangleCollisionMesh);
     writer.AlignStream();
 }
예제 #14
0
 public void Write(AssetWriter writer)
 {
     writer.Write(Data0);
     writer.Write(Data1);
     writer.Write(Data2);
     writer.Write(Data3);
 }
예제 #15
0
        /// <summary>
        /// Called internally by the serializer when the image content is to be written as an external file
        /// </summary>
        /// <param name="writer">The satellite asset writer</param>
        /// <param name="satelliteUri">A local satellite URI</param>
        internal void _WriteToSatellite(AssetWriter writer, string satelliteUri)
        {
            if (_SatelliteImageContent == null)
            {
                _WriteAsBufferView(); return;
            }

            if (_IsPng(_SatelliteImageContent))
            {
                _mimeType = null;
                _uri      = satelliteUri += ".png";
                writer(_uri, new ArraySegment <byte>(_SatelliteImageContent));
                return;
            }

            if (_IsJpeg(_SatelliteImageContent))
            {
                _mimeType = null;
                _uri      = satelliteUri += ".jpg";
                writer(_uri, new ArraySegment <byte>(_SatelliteImageContent));
                return;
            }

            throw new NotImplementedException();
        }
예제 #16
0
        private void WriteBlob(AssetLayout layout, MemoryStream memStream, out uint compressedLength, out uint decompressedLength, int segment)
        {
            using (MemoryStream blobMem = new MemoryStream())
            {
                using (AssetWriter blobWriter = new AssetWriter(blobMem, EndianType.LittleEndian, layout))
                {
                    if (segment == 0)
                    {
                        blobWriter.WriteAssetArray(Entries);
                    }
                    WriteSegment(blobWriter, segment);
                }
                decompressedLength = (uint)blobMem.Length;

                blobMem.Position = 0;
#warning TODO:
                compressedLength = 0;

                /*using (Lz4EncodeStream lz4Stream = new Lz4EncodeStream(blobMem, blobMem.Length))
                 * {
                 *      lz4Stream.Write(memStream);
                 *      compressedLength = lz4Stream.Length;
                 * }*/
            }
        }
예제 #17
0
        public void Write(AssetWriter writer)
        {
            Heights.Write(writer);
            if (HasAlign(writer.Version))
            {
                writer.AlignStream();
            }
            if (HasShifts(writer.Version))
            {
                Shifts.Write(writer);
                writer.AlignStream();
            }

            PrecomputedError.Write(writer);
            MinMaxPatchHeights.Write(writer);
            if (HasDefaultPhysicMaterial(writer.Version))
            {
                DefaultPhysicMaterial.Write(writer);
            }

            writer.Write(Width);
            writer.Write(Height);
            if (HasThickness(writer.Version))
            {
                writer.Write(Thickness);
            }

            writer.Write(Levels);
            Scale.Write(writer);
        }
예제 #18
0
 public void Write(AssetWriter writer)
 {
     writer.Write(R);
     writer.Write(G);
     writer.Write(B);
     writer.Write(A);
 }
예제 #19
0
        public void Write(AssetWriter writer)
        {
            Patches.Write(writer);
            DetailPrototypes.Write(writer);
            writer.Write(PatchCount);
            writer.Write(PatchSamples);
            RandomRotations.Write(writer);
            if (HasAtlasTexture(writer.Version))
            {
                AtlasTexture.Write(writer);
            }

            WavingGrassTint.Write(writer);
            writer.Write(WavingGrassStrength);
            writer.Write(WavingGrassAmount);
            writer.Write(WavingGrassSpeed);
            if (HasDetailBillboardShader(writer.Version))
            {
                DetailBillboardShader.Write(writer);
                DetailMeshLitShader.Write(writer);
                DetailMeshGrassShader.Write(writer);
            }

            TreeDatabase.Write(writer);
            if (!HasAtlasTexture(writer.Version))
            {
                PreloadTextureAtlasData.Write(writer);
            }
        }
예제 #20
0
 public void Write(AssetWriter writer)
 {
     writer.Write(X);
     writer.Write(Y);
     writer.Write(Width);
     writer.Write(Height);
 }
예제 #21
0
        public void Write(AssetWriter writer)
        {
            Sprites.Write(writer);
            if (SpriteMetaData.HasOutline(writer.Version))
            {
                Outline.Write(writer);
            }
            if (SpriteMetaData.HasPhysicsShape(writer.Version))
            {
                PhysicsShape.Write(writer);
            }
            if (SpriteMetaData.HasBones(writer.Version))
            {
                Bones.Write(writer);
                writer.Write(SpriteID);
            }
            if (SpriteMetaData.HasInternalID(writer.Version))
            {
                writer.Write(InternalID);
            }
            if (SpriteMetaData.HasBones(writer.Version))
            {
                Vertices.Write(writer);
                Indices.Write(writer);
                Edges.Write(writer);
                writer.AlignStream();

                Weights.Write(writer);
                writer.AlignStream();
            }
            if (HasSecondaryTextures(writer.Version))
            {
                SecondaryTextures.Write(writer);
            }
        }
예제 #22
0
        /// <summary>
        /// Called internally by the serializer when the buffer content is to be written as an external file
        /// </summary>
        /// <param name="writer">The satellite asset writer</param>
        /// <param name="satelliteUri">A local satellite URI</param>
        internal void _WriteToSatellite(AssetWriter writer, string satelliteUri)
        {
            this._uri        = satelliteUri;
            this._byteLength = _Content.Length;

            writer(satelliteUri, new ArraySegment <byte>(_Content.GetPaddedContent()));
        }
예제 #23
0
 public void Write(AssetWriter writer)
 {
     Target.Write(writer);
     writer.Write(PropertyPath);
     writer.Write(Value);
     ObjectReference.Write(writer);
 }
예제 #24
0
 public void Write(AssetWriter writer)
 {
     writer.Write(Stream);
     writer.Write(Offset);
     writer.Write(Format);
     writer.Write(RawDimension);
 }
예제 #25
0
 public void Write(AssetWriter writer)
 {
     Color0.Write(writer);
     Color1.Write(writer);
     Color2.Write(writer);
     Color3.Write(writer);
     Color4.Write(writer);
 }
예제 #26
0
 public void Write(AssetWriter writer)
 {
     writer.Write(NumItems);
     writer.Write(Data);
     writer.AlignStream(AlignType.Align4);
     writer.Write(BitSize);
     writer.AlignStream(AlignType.Align4);
 }
예제 #27
0
 public void Write(AssetWriter writer)
 {
     Bounds.Write(writer);
     LayerIndices.Write(writer);
     writer.AlignStream();
     NumberOfObjects.Write(writer);
     writer.AlignStream();
 }
예제 #28
0
 public void Write(AssetWriter writer)
 {
     TextureImportInstructions.Write(writer);
     SourceTextureInformation.Write(writer);
     if (HasImportInspectorWarnings(writer.Version))
     {
         writer.Write(ImportInspectorWarnings);
     }
 }
예제 #29
0
        public virtual void Write(AssetWriter writer)
        {
            ObjectLayout layout = writer.Layout.Object;

            if (layout.HasHideFlag)
            {
                writer.Write((uint)ObjectHideFlags);
            }
        }
예제 #30
0
        public override void Write(AssetWriter writer)
        {
            base.Write(writer);

            if (HasGameObject(writer.Flags))
            {
                GameObject.Write(writer);
            }
        }