- Home /
Ingame Texture Switcher
Is it possible to add something that allows the player to add his own Texturepack to my Game and select it? So that he can play with his Textures? Like its made in Minecraft (No my game is not like Minecraft).
Thank you :)
Comment
Best Answer
Answer by DajBuzi · Jul 24, 2014 at 09:59 AM
You can try something like this:
using UnityEngine;
using System.Collections;
using System.IO;
public class Test : MonoBehaviour
{
private string pathToResources;
public Texture2D textureAtlas;
public void Start()
{
pathToResources = Application.dataPath + Path.DirectorySeparatorChar + "myResources";
if(!File.Exists(pathToResources))
Directory.CreateDirectory(pathToResources);
textureAtlas = textureAtlas.LoadImage(File.ReadAllBytes(pathToResources + Path.DirectorySeparatorChar + "Atlas.png"));
}
}
and then I would have to load the textures from this "Test" Script? So i would have to do something like Test.textureAtlas and then I would get the Atlas. But I would have to make the textureAtlas static then. I will try it :) Thank you :)