Hello, this could be a complicated topic I want to ask about so here it is. I am creating a game that can basically have modding features by outside code using JSON, and part of it is having textures being imported on to it outside of the game in a directory. The game would be a 2D block “minecraft off-brand” game, and why I add this info is because the blocks will all be Tiles (Note: note the “Tiles” later) and not separate Gameobjects. I have been successful at like detecting .txt files and reading them so what block and what their info was gonna be. But the problem was their textures, if you wanted to make or code a block, you would have to include their texture (which is a 16x16 picture btw). But then as it is imported by code inside unity in my script, the Texture gets small, and I had no way to fix it, here is an example of it:
so here is the code for the import:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public static class ImageFileManager
{
public static readonly string IMAGE_FOLDER =
Application.persistentDataPath + "/textures/";
public static Sprite GetCustomImageSprite(JsonBlockClass jsonBlock)
{
Sprite sprite = null;
Texture2D tex;
tex = new Texture2D(16, 16, TextureFormat.DXT1, false);
WWW www = new WWW("file:" + IMAGE_FOLDER +
jsonBlock.imageName);
www.LoadImageIntoTexture(tex);
sprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height),
Vector2.zero);
return sprite;
}
}
Please Help, if anyone could, Thanks.