LoadAtlasFromTexture() public method

public LoadAtlasFromTexture ( string name, Texture texture ) : void
name string
texture Texture
return void
Example #1
0
    private void CreateDefaultAtlases()
    {
        //atlas of plain white

        Texture2D plainWhiteTex = new Texture2D(16, 16);

        plainWhiteTex.filterMode = FilterMode.Bilinear;
        plainWhiteTex.wrapMode   = TextureWrapMode.Clamp;

        Color white = Futile.white;

        //Color clear = new Color(1,1,1,0);

        for (int r = 0; r < 16; r++)
        {
            for (int c = 0; c < 16; c++)
            {
                //				if(c == 0 || r  == 0) //clear the 0 edges
                //				{
                //					plainWhiteTex.SetPixel(c,r,clear);
                //				}
                //				else
                //				{
                plainWhiteTex.SetPixel(c, r, white);
                //				}
            }
        }


        plainWhiteTex.Apply();

        atlasManager.LoadAtlasFromTexture("Futile_White", plainWhiteTex);

        whiteElement = atlasManager.GetElementWithName("Futile_White");
    }
Example #2
0
        public static void ApplyPositionChangeHook(On.RoomCamera.orig_ApplyPositionChange orig, RoomCamera rCam)
        {
            WWW       www     = (WWW)typeof(RoomCamera).GetField("www", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance).GetValue(rCam);
            Texture2D texture = rCam.game.rainWorld.persistentData.cameraTextures[rCam.cameraNumber, 0];

            if (ShouldScroll(rCam, GetRoomName(www.url)))
            {
                texture.Resize(www.texture.width, www.texture.height, TextureFormat.ARGB32, false);
            }
            else
            {
                texture.Resize(1400, 800, TextureFormat.ARGB32, false); // default
            }
            texture.Apply();

            FAtlasManager manager = Futile.atlasManager;
            List <FAtlas> atlases = (List <FAtlas>) typeof(FAtlasManager).GetField("_atlases", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance).GetValue(manager);
            Dictionary <string, FAtlasElement> allElementsByName = (Dictionary <string, FAtlasElement>) typeof(FAtlasManager).GetField("_allElementsByName", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance).GetValue(manager);
            FAtlas atlas = manager.GetAtlasWithName("LevelTexture");

            atlases.Remove(atlas);
            allElementsByName.Remove("LevelTexture");
            atlas = null;
            manager.LoadAtlasFromTexture("LevelTexture", texture);

            rCam.ReturnFContainer("Foreground").RemoveChild(rCam.levelGraphic);
            rCam.levelGraphic           = new FSprite("LevelTexture", true);
            rCam.levelGraphic.anchorX   = 0;
            rCam.levelGraphic.anchorY   = 0;
            rCam.levelGraphic.isVisible = true;
            rCam.levelGraphic.shader    = rCam.game.rainWorld.Shaders["LevelColor"];
            rCam.ReturnFContainer("Foreground").AddChild(rCam.levelGraphic);

            rCam.currentCameraPosition = 0;
            orig(rCam);
        }