Ejemplo n.º 1
0
        void InitWhiteSprite()
        {
            var env = World.TinyEnvironment();
            var mgr = EntityManager;

            if (env.whiteSpriteEntity == Entity.Null)
            {
                env.whiteSpriteEntity = mgr.CreateEntity();
            }
            var e = env.whiteSpriteEntity;

            if (mgr.HasComponent <Sprite2D>(e))
            {
                return;
            }

            Image2D im = new Image2D();

            mgr.AddComponentData(e, im);
            Image2DAlphaMask mask = new Image2DAlphaMask();

            mask.threshold = .5f;
            mgr.AddComponentData(e, mask);

            Image2DLoadFromFile ftrigger = new Image2DLoadFromFile();

            mgr.AddComponentData(e, ftrigger);

            mgr.AddBufferFromString <Image2DLoadFromFileImageFile>(e, "::white1x1");

            Sprite2D sp = new Sprite2D();

            sp.image       = e;
            sp.pivot       = new float2(.5f, .5f);
            sp.imageRegion = new Rect {
                x = 0.0f, y = 0.0f, width = 1.0f, height = 1.0f
            };
            sp.pixelsToWorldUnits = 1f;
            mgr.AddComponentData(e, sp);
        }
Ejemplo n.º 2
0
        bool VerifyImageForSprite(Entity e, ref Sprite2D sprite, out Image2D image)
        {
            var mgr = EntityManager;

            // verify image
            if (sprite.image == Entity.Null) // fixup invalid ref to point to self
            {
                sprite.image = e;
            }
            if (!mgr.Exists(sprite.image) || !cachedGetImage2D.Exists(sprite.image))
            {
                var env = World.TinyEnvironment();
                sprite.image = env.whiteSpriteEntity;
            }
            image = cachedGetImage2D[sprite.image];
            if (image.status != ImageStatus.Loaded)
            {
                return(false);
            }
            // TODO: add back in all the debug only checks

            return(true);
        }