FANDOM


RainWorldAtlas

Atlases are basically a fancy word for sprite sheets. It’s just a single image that contains many smaller images within in. All of the graphics for creatures, and all of the icons for the user interface are loaded from these texture atlases, for example.

However, despite the texture atlases being present in the game folder (Assets/Futile/Resources/Atlases), the game doesn't actually load the graphics from there. There's a copy of all these atlas files in the compressed resources.assets file, and it reads it from there instead of being read from disk. So normally, editing the exposed texture atlas images and text files in the Rain World folder will not actually have any effect on the game. The following changes will force the game read all atlas data from disk rather than the .assets file:

FAtlasManager Edit

Replace entire contents of LoadAtlas() with:

if(DoesContainAtlas(atlasPath)) 
    return GetAtlasWithName(atlasPath); 
return ActuallyLoadAtlasOrImage(atlasPath, atlasPath+Futile.resourceSuffix, atlasPath+Futile.resourceSuffix);

Replace entire contents of LoadImage() with:

if(DoesContainAtlas(imagePath)) 
    return GetAtlasWithName(imagePath); 
return ActuallyLoadAtlasOrImage(imagePath, imagePath+Futile.resourceSuffix,"");

FAtlas Edit

Add the following alongside the other "using" statements:

using System.IO;

Add the following new function:

public static string RootFolderDirectory() {
    string directory = System.Reflection.Assembly.GetExecutingAssembly().Location;
    var pathParts = directory.Split(Path.DirectorySeparatorChar);
    string newPath = "";
    for (int i = 0; i < pathParts.Length - 3; i++)
        newPath = newPath + pathParts[i] + Path.DirectorySeparatorChar;
    return newPath;
}

In LoadTexture() replace the line:

_texture = Resources.Load (_imagePath, typeof(Texture)) as Texture;

with:

WWW www = new WWW("file:///" + RootFolderDirectory() + "Assets" + Path.DirectorySeparatorChar + "Futile" + Path.DirectorySeparatorChar + "Resources" + Path.DirectorySeparatorChar + _imagePath + ".png");
_texture = new Texture2D(1, 1, TextureFormat.ARGB32, false);
_texture.anisoLevel = 0;
_texture.filterMode = FilterMode.Point;
www.LoadImageIntoTexture(_texture as Texture2D);

In LoadAtlasData(), replace the lines:

TextAsset textAsset = Resources.Load (_dataPath, typeof(TextAsset)) as TextAsset;
if (textAsset == null)
    throw new FutileException("Couldn't load the atlas data from: " + _dataPath);
Dictionary<string,object> dictionary = textAsset.text.dictionaryFromJson();

with:

string textAsset = File.ReadAllText(RootFolderDirectory() + "Assets" + Path.DirectorySeparatorChar + "Futile" + Path.DirectorySeparatorChar + "Resources" + Path.DirectorySeparatorChar + _dataPath + ".txt");
Dictionary<string, object> dictionary = textAsset.dictionaryFromJson();

… then remove this line from the end of the function:

Resources.UnloadAsset(textAsset);

Editing the Texture Atlases Edit

Once the code changes above have been made, the texture atlas files on disk can be edited freely, and the changes will show up in the game. Each of Rain World’s texture atlases consist of an image file and a text file. The text file maps out the locations, names, and other information of each of the individual images within the big image.

Below is one sample entry from one of the atlas text files:

"mouseSpot.png":
{
	"frame": {"x":169,"y":15,"w":3,"h":6},
	"rotated": false,
	"trimmed": false,
	"spriteSourceSize": {"x":0,"y":0,"w":3,"h":6},
	"sourceSize": {"w":3,"h":6}
},

The name (here: “mouseSpot”) can be anything, but it’s important because it’ll be the name you use in the code later to refer to the specific sprite you want to grab from the atlas. The x/y/w/h values are measured in pixels. X and Y are the offsets from the top left corner of the atlas to the top left corner of the sprite. W and H is the width/height of the sprite. For “spriteSourceSize” you can leave x/y as 0.

Community content is available under CC-BY-SA unless otherwise noted.