I have a program where I am trying to have an array of sprites that I want to change with a button click.
I have the sprites rendering, but when I enter Play mode the button object I have assigned to the Hood/Hair object is disappearing.
Can anyone help me out please?
images and code below:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class SelectionManager : MonoBehaviour {
public SpriteRenderer clothing;
public Button Select;
public Sprite[] clothes;
int num = 0;
void Start () {
clothing = GetComponent<SpriteRenderer> ();
Select = GetComponent<Button> ();
Select.onClick.AddListener(TaskOnClick);
}
void Update () {
clothing.sprite = clothes [num];
}
public void TaskOnClick ()
{
num = +num;
if (num >= clothes.Length)
num = 0;
}
}