public void Serialize(UABPacker packer, UABField field, ref object value, List <ISerializer> serializers)
        {
            field.serializatorId = this.GetId();
            field.fieldType      = FieldType.BinaryType;
            var sprite = (value as Sprite);

            if (packer == null)
            {
                                #if UNITY_EDITOR
                var oldReadable = TextureSerializerHelper.PrepareForEncode(sprite.texture);
                var bytes       = sprite.texture.EncodeToPNG();
                TextureSerializerHelper.CompleteEncoding(sprite.texture, oldReadable);
                field.data = System.Convert.ToBase64String(bytes);
                                #endif
            }
            else
            {
                var data = new Data();
                data.spriteRect          = sprite.rect;
                data.spritePivot         = sprite.pivot;
                data.spritePixelsPerUnit = sprite.pixelsPerUnit;
                data.spriteExtrude       = 0u;
                data.spriteMeshType      = SpriteMeshType.FullRect;
                data.spriteBorder        = sprite.border;
                field.fields             = packer.Serialize(data, serializers);
            }
        }
예제 #2
0
        public void Serialize(UABPacker packer, UABField field, ref object value, List <ISerializer> serializers)
        {
            field.serializatorId = this.GetId();
            var data = new Data();
            var tr   = value as AnimationCurve;

            data.keys    = tr.keys;
            field.fields = packer.Serialize(data, serializers);
        }
예제 #3
0
        public void Serialize(UABPacker packer, UABField field, ref object value, List <ISerializer> serializers)
        {
            field.serializatorId = this.GetId();
            var tr   = value as Transform;
            var data = new Data();

            data.position = tr.localPosition;
            data.rotation = tr.localEulerAngles;
            data.scale    = tr.localScale;
            field.fields  = packer.Serialize(data, serializers);
        }
예제 #4
0
        public void Serialize(UABPacker packer, UABField field, ref object value, List <ISerializer> serializers)
        {
            field.serializatorId = this.GetId();
            var tr   = value as RectOffset;
            var data = new Data();

            data.x       = tr.left;
            data.y       = tr.right;
            data.z       = tr.top;
            data.w       = tr.bottom;
            field.fields = packer.Serialize(data, serializers);
        }
        public void Serialize(UABPacker packer, UABField field, ref object value, List <ISerializer> serializers)
        {
            field.serializatorId = this.GetId();
            var v    = (Gradient)value;
            var data = new Data();

                        #if UNITY_5_5_OR_NEWER
            data.mode = v.mode;
                        #endif
            data.colorKeys = v.colorKeys;
            data.alphaKeys = v.alphaKeys;
            field.fields   = packer.Serialize(data, serializers);
        }
        public void Serialize(UABPacker packer, UABField field, ref object value, List <ISerializer> serializers)
        {
            field.serializatorId = this.GetId();
            var animator = value as Animator;
            var data     = new Data();

            data.avatar = animator.avatar;
            data.runtimeAnimatorController = animator.runtimeAnimatorController;
            data.cullingMode            = animator.cullingMode;
            data.updateMode             = animator.updateMode;
            data.applyRootMotion        = animator.applyRootMotion;
            data.linearVelocityBlending = animator.linearVelocityBlending;
            field.fields = packer.Serialize(data, serializers);
        }
예제 #7
0
        public void Serialize(UABPacker packer, UABField field, ref object value, List <ISerializer> serializers)
        {
            field.serializatorId = this.GetId();
            var tr   = value as RectTransform;
            var data = new Data();

            data.position         = tr.localPosition;
            data.rotation         = tr.localEulerAngles;
            data.scale            = tr.localScale;
            data.anchoredPosition = tr.anchoredPosition;
            data.anchorMax        = tr.anchorMin;
            data.anchorMin        = tr.anchorMax;
            data.sizeDelta        = tr.sizeDelta;
            data.pivot            = tr.pivot;
            field.fields          = packer.Serialize(data, serializers);
        }
        public void Serialize(UABPacker packer, UABField field, ref object value, List <ISerializer> serializers)
        {
            field.serializatorId = this.GetId();
            field.fieldType      = FieldType.BinaryType;

            if (packer == null)
            {
                var bytes = MeshSerializerHelper.WriteMesh(value as Mesh, saveTangents: true);
                if (bytes != null)
                {
                    field.data = System.Convert.ToBase64String(bytes);
                }
            }
            else
            {
                var data = new Data();
                field.fields = packer.Serialize(data, serializers);
            }
        }
        public void Serialize(UABPacker packer, UABField field, ref object value, List <ISerializer> serializers)
        {
            field.serializatorId = this.GetId();
            var data = new Data();
            var tr   = (UnityEngine.ParticleSystem.MinMaxGradient)value;

            data.mode = tr.mode;
                        #if UNITY_5_5_OR_NEWER
            data.color = tr.color;
                        #endif
            data.colorMin = tr.colorMin;
            data.colorMax = tr.colorMax;
                        #if UNITY_5_5_OR_NEWER
            data.gradient = tr.gradient;
                        #endif
            data.gradientMin = tr.gradientMin;
            data.gradientMax = tr.gradientMax;
            field.fields     = packer.Serialize(data, serializers);
        }
 public void Serialize(UABPacker packer, UABField field, ref object value, List <ISerializer> serializers)
 {
     field.serializatorId = this.GetId();
     field.fieldType      = FieldType.BinaryType;
     if (packer == null)
     {
                         #if UNITY_EDITOR
         var oldReadable = TextureSerializerHelper.PrepareForEncode(value as Texture);
         var texture     = (value as Texture2D);
         var bytes       = texture.EncodeToPNG();
         TextureSerializerHelper.CompleteEncoding(texture, oldReadable);
         field.data = System.Convert.ToBase64String(bytes);
                         #endif
     }
     else
     {
         var data = new Data();
         field.fields = packer.Serialize(data, serializers);
     }
 }
예제 #11
0
 public void Serialize(UABPacker packer, UABField field, ref object value, List <ISerializer> serializers)
 {
     field.serializatorId = this.GetId();
     field.fields         = packer.Serialize(value, serializers);
 }
        public void Serialize(UABPacker packer, UABField field, ref object value, List <ISerializer> serializers)
        {
            field.serializatorId = this.GetId();
            var ps   = value as ParticleSystem;
            var data = new Data();

                        #if UNITY_5_5_OR_NEWER
            data.useAutoRandomSeed = ps.useAutoRandomSeed;
            if (data.useAutoRandomSeed == false)
            {
                data.randomSeed = ps.randomSeed;
            }
            else
            {
                data.randomSeed = 0;
            }
                        #endif

                        #if UNITY_5_5_OR_NEWER
            data.main = UABUtils.CopyFromParticleSystemModule(ps.main, data.main);
            {
                data.emission.data = UABUtils.CopyFromParticleSystemModule(ps.emission, data.emission.data);
                var bursts = new UnityEngine.ParticleSystem.Burst[ps.emission.burstCount];
                ps.emission.GetBursts(bursts);
                data.emission.bursts = new Data.EmissionModule.Burst[bursts.Length];
                for (int i = 0; i < bursts.Length; ++i)
                {
                    data.emission.bursts[i] = new Data.EmissionModule.Burst();
                    UABUtils.CopyFromParticleSystemModule(bursts[i], data.emission.bursts[i]);
                }
            }
                        #endif
            data.shape = UABUtils.CopyFromParticleSystemModule(ps.shape, data.shape);
            data.velocityOverLifetime      = UABUtils.CopyFromParticleSystemModule(ps.velocityOverLifetime, data.velocityOverLifetime);
            data.limitVelocityOverLifetime = UABUtils.CopyFromParticleSystemModule(ps.limitVelocityOverLifetime, data.limitVelocityOverLifetime);
            data.inheritVelocity           = UABUtils.CopyFromParticleSystemModule(ps.inheritVelocity, data.inheritVelocity);
            data.forceOverLifetime         = UABUtils.CopyFromParticleSystemModule(ps.forceOverLifetime, data.forceOverLifetime);
            data.colorOverLifetime         = UABUtils.CopyFromParticleSystemModule(ps.colorOverLifetime, data.colorOverLifetime);
            data.colorOverLifetime         = UABUtils.CopyFromParticleSystemModule(ps.colorOverLifetime, data.colorOverLifetime);
            data.sizeOverLifetime          = UABUtils.CopyFromParticleSystemModule(ps.sizeOverLifetime, data.sizeOverLifetime);
            data.sizeBySpeed          = UABUtils.CopyFromParticleSystemModule(ps.sizeBySpeed, data.sizeBySpeed);
            data.rotationOverLifetime = UABUtils.CopyFromParticleSystemModule(ps.rotationOverLifetime, data.rotationOverLifetime);
            data.rotationBySpeed      = UABUtils.CopyFromParticleSystemModule(ps.rotationBySpeed, data.rotationBySpeed);
            data.externalForces       = UABUtils.CopyFromParticleSystemModule(ps.externalForces, data.externalForces);
            data.rotationBySpeed      = UABUtils.CopyFromParticleSystemModule(ps.rotationBySpeed, data.rotationBySpeed);
                        #if UNITY_5_5_OR_NEWER
            data.noise = UABUtils.CopyFromParticleSystemModule(ps.noise, data.noise);
                        #endif
            data.collision = UABUtils.CopyFromParticleSystemModule(ps.collision, data.collision);
                        #if UNITY_5_5_OR_NEWER
            data.trigger = UABUtils.CopyFromParticleSystemModule(ps.trigger, data.trigger);
            {
                data.subEmitters.data        = UABUtils.CopyFromParticleSystemModule(ps.subEmitters, data.subEmitters.data);
                data.subEmitters.subEmitters = new ParticleSystem[ps.subEmitters.subEmittersCount];
                data.subEmitters.properties  = new ParticleSystemSubEmitterProperties[ps.subEmitters.subEmittersCount];
                data.subEmitters.types       = new ParticleSystemSubEmitterType[ps.subEmitters.subEmittersCount];
                for (int i = 0; i < ps.subEmitters.subEmittersCount; ++i)
                {
                    data.subEmitters.subEmitters[i] = ps.subEmitters.GetSubEmitterSystem(i);
                    data.subEmitters.properties[i]  = ps.subEmitters.GetSubEmitterProperties(i);
                    data.subEmitters.types[i]       = ps.subEmitters.GetSubEmitterType(i);
                }
            }
                        #endif
            data.textureSheetAnimation = UABUtils.CopyFromParticleSystemModule(ps.textureSheetAnimation, data.textureSheetAnimation);
                        #if UNITY_5_5_OR_NEWER
            data.lights = UABUtils.CopyFromParticleSystemModule(ps.lights, data.lights);
            data.trails = UABUtils.CopyFromParticleSystemModule(ps.trails, data.trails);
                        #endif

            field.fields = packer.Serialize(data, serializers);
        }