예제 #1
0
        public static unsafe FakeStruct LoadFromObject(Component com, DataBuffer buffer)
        {
            var img = com as RawImage;

            if (img == null)
            {
                return(null);
            }
            FakeStruct    fake = new FakeStruct(buffer, RawImageData.ElementSize);
            RawImageData *data = (RawImageData *)fake.ip;

            data->uvRect = img.uvRect;
            data->color  = img.color;
            if (img.texture != null)
            {
                var tn = img.texture.name;
                var an = ElementAsset.TxtureFormAsset(img.texture.name);
                data->assetName   = buffer.AddData(an);
                data->textureName = buffer.AddData(tn);
            }
            if (img.material != null)
            {
                data->shader = buffer.AddData(img.material.shader.name);
            }
            return(fake);
        }
예제 #2
0
        public static unsafe FakeStruct LoadFromObject(Component com, DataBuffer buffer)
        {
            var img = com as Image;

            if (img == null)
            {
                return(null);
            }
            FakeStruct fake = new FakeStruct(buffer, ImageData.ElementSize);
            ImageData *data = (ImageData *)fake.ip;

            data->alphaHit       = img.alphaHitTestMinimumThreshold;
            data->fillAmount     = img.fillAmount;
            data->fillCenter     = img.fillCenter;
            data->fillClockwise  = img.fillClockwise;
            data->fillMethod     = img.fillMethod;
            data->fillOrigin     = img.fillOrigin;
            data->preserveAspect = img.preserveAspect;
            data->type           = img.type;
            data->color          = img.color;
            if (img.sprite != null)
            {
                var tn = img.sprite.texture.name;
                var sn = img.sprite.name;
                var an = ElementAsset.TxtureFormAsset(img.sprite.texture.name);
                data->assetName   = buffer.AddData(an);
                data->textureName = buffer.AddData(tn);
                data->spriteName  = buffer.AddData(sn);
            }
            if (img.material != null)
            {
                data->shader = buffer.AddData(img.material.shader.name);
            }
            return(fake);
        }
예제 #3
0
        public static void LoadToObject(Component game, ref RawImageData dat, RawImageElement image)
        {
            var a = game.GetComponent <RawImage>();

            if (a == null)
            {
                return;
            }
            a.uvRect        = dat.uvRect;
            a.color         = dat.color;
            a.raycastTarget = false;
            if (image.shader != "Default UI Material")
            {
                a.material = new Material(Shader.Find(image.shader));
            }
            if (image.textureName != null)
            {
                a.texture = ElementAsset.FindTexture(image.assetName, image.textureName);
            }
            else
            {
                a.texture = null;
            }
            image.Context = a;
        }
예제 #4
0
        public static void LoadToObject(Component game, ref ImageData dat, ImageElement image)
        {
            var a = game.GetComponent <Image>();

            if (a == null)
            {
                return;
            }
            a.enabled = true;
            a.alphaHitTestMinimumThreshold = dat.alphaHit;
            a.fillAmount     = dat.fillAmount;
            a.fillCenter     = dat.fillCenter;
            a.fillClockwise  = dat.fillClockwise;
            a.fillMethod     = dat.fillMethod;
            a.fillOrigin     = dat.fillOrigin;
            a.preserveAspect = dat.preserveAspect;
            a.type           = dat.type;
            a.raycastTarget  = false;
            a.color          = dat.color;
            if (image.shader != "Default UI Material")
            {
                a.material = new Material(Shader.Find(image.shader));
            }
            if (image.spriteName != null)
            {
                a.sprite = ElementAsset.FindSprite(image.assetName, image.textureName, image.spriteName);
            }
            else
            {
                a.sprite = null;
            }
            image.Context = a;
        }