Hi,
I’m trying to populate a scrollview with buttons and I want to assign different sprites to each button. The code below feels right but it’s not. There’s an error with OnLoadDone not being the right type.
void Start()
{
foreach(ScrollViewMenu m in plantMenu)
{
Button b = Instantiate(menuButton) as Button;
Sprite temp = Addressables.LoadAssetAsync<Sprite>(m.sprite).Completed += OnLoadDone;
b.GetComponent<Button>().GetComponent<Image>().sprite = temp;
}
}
private Sprite OnLoadDone(AsyncOperationHandle<Sprite> obj)
{
return obj.Result as Sprite;
}