Hi there,
Just wondering if there is a way to load a sprite outside the Assets file.
I have a folder in the unity game files named “Textures” where i keep all sorts of png files for my textures
int pathStart = line.IndexOf("(") + "(".Length;
int pathEnd = line.LastIndexOf(")");
string path = line.Substring(pathStart, pathEnd - pathStart);
Sprite voxelTexture = AssetDatabase.LoadAssetAtPath<Sprite>(path);
foreach(GameObject voxel in voxels) {
if(voxel.name == currentVoxelId) {
voxel.GetComponent<voxelVariables>().voxelTexture = voxelSpriteTexture;
}
}
Each time i run this script the path returns as “textures/voxels/00_texture1.png” which is correct, but it doesn’t load. The only way i can make it load is by changing the sprite path to
Sprite voxelTexture = AssetDatabase.LoadAssetAtPath<Sprite>("Assets/" + file);
And adding the texture files in the Assets file.
Is there a way to load these textures outside the Assets files?