Forum rules - please read before posting.

update ac menu element (graphic) with another image by script

Hi Chris,

I am trying to change the image of a AC menu element by script but fail, would you pls help?

I am trying to script like this:
AC.MenuGraphic test = AC.PlayerMenus.GetElementWithName ("Canvas", "CharacterPortrait") as AC.MenuGraphic;
test.uiImage.sprite = GameObject.Find("xxx").GetComponent().sprite;

I would like to replace image of an AC menu graphic with one of a sprite object in the scene by script. How can I do this? Would you pls have some advice, thanks a lot.

Comments

  • You can use the MenuGraphic's SetNormalGraphicTexture function, passing in the sprite's original texture:

    test.SetNormalGraphicTexture (GameObject.Find("xxx").GetComponent().sprite.texture);
    

    If you're setting this to a sprite in script, however, you may be better off not linking it to the Menu Manager as a Graphic element - and instead just affecting the Image component directly.

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.