Синтаксис:
Используется csharp
public class BtnManager : MonoBehaviour {
public Sprite n, o, c;
[HideInInspector]
Image curImage;
void Awake()
{
curImage = GetComponent<Image>();
Debug.Log(curImage.sprite); //просто так. выводит тот спрайт, который стоит
}
void OnClick()
{
curImage.sprite = c; //здесь выскакивают ошибки null reference exception
Debug.Log(curImage.sprite); //и здесь
}
void OnMouseEnter()
{
curImage.sprite = o; //а ещё тут
Debug.Log(curImage.sprite); //и опять ошибка
}
void OnMouseExit()
{
curImage.sprite = n;//ну и здесь, конечно же
}
}
public Sprite n, o, c;
[HideInInspector]
Image curImage;
void Awake()
{
curImage = GetComponent<Image>();
Debug.Log(curImage.sprite); //просто так. выводит тот спрайт, который стоит
}
void OnClick()
{
curImage.sprite = c; //здесь выскакивают ошибки null reference exception
Debug.Log(curImage.sprite); //и здесь
}
void OnMouseEnter()
{
curImage.sprite = o; //а ещё тут
Debug.Log(curImage.sprite); //и опять ошибка
}
void OnMouseExit()
{
curImage.sprite = n;//ну и здесь, конечно же
}
}