I am having issues with the textures displaying in the container, this is what i have. Can anyone help me?
public GameObject levelbuttonprefab;
public GameObject LevelButtonContainer;
public GameObject ShopButtonPrefab;
public GameObject ShopButtonContainer;
private Transform cameraTransform;
private Transform cameraDesiredLookAt;
private string Player;
private void Start()
{
cameraTransform = Camera.main.transform;
Sprite[] thumbnails = Resources.LoadAll<Sprite>("Levels");
foreach(Sprite thumbnail in thumbnails)
{
GameObject container = Instantiate (levelbuttonprefab) as GameObject;
container.GetComponent<Image> ().sprite = thumbnail;
container.transform.SetParent(LevelButtonContainer.transform, false);
string sceneName = thumbnail.name;
container.GetComponent<Button>().onClick.AddListener (() => LoadLevel(sceneName));
}
Sprite[] textures = Resources.LoadAll<Sprite>(Player);
foreach (Sprite texture in textures)
{
GameObject container = Instantiate(ShopButtonPrefab) as GameObject;
container.GetComponent<Image>().sprite = texture;
container.transform.SetParent(parent: ShopButtonContainer.transform; false);
}
if(cameraDesiredLookAt != null)
{
cameraTransform.rotation = Quaternion.Slerp(cameraTransform.rotation, cameraDesiredLookAt.rotation, 3 * Time.deltaTime);
}
}
This is what i was working on when the problem started.