Forum rules - please read before posting.

Assigning texture to graphic menu element in runtime

edited July 2019 in Technical Q&A

I have a menu (Unity Prefab) that contains a graphic menu element that I try to assign a texture to in runtime. I tried this:
var graphicElement = PlayerMenus.GetElementWithName("MenuName", "ElementName") as AC.MenuGraphic;
graphicElement.backgroundTexture = Resources.Load("TextureName");

And this:
graphicElement.LoadUnityUI(menu, menu.canvas);
graphicElement.uiImage.sprite = Resources.Load("TextureName");

Nothing fails at runtime (the menu element is found and the resource is loaded), but the texture isn't shown. If I set the texture in the editor, it's shown fine.

Any ideas?
Thanks!

Comments

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.