Unity Ver: 2018.2.2f1
AC Ver: 1.66.2
Hey folks,
I'm wanting to access the main graphic of an inventory item and show it on a menu graphic via script.
I've done this previously with the altlabel of an item like this:
//Access the item in the inventory runtime LIST and extract its altLabel
(AC.PlayerMenus.GetElementWithName("SelectedItem", "SelectedItemLabel") as AC.MenuLabel).label = KickStarter.runtimeInventory.localItems[InventorySelection.activeInventorySlot].altLabel;
However I'm having trouble figuring out what the access / types should be for the main graphic. For instance I've tried:
//Access the item in inventory and extract it's graphic
(AC.PlayerMenus.GetElementWithName("SelectedItem", "SelectedItemGraphic") as AC.MenuGraphic).graphic = KickStarter.runtimeInventory.localItems[InventorySelection.activeInventorySlot].tex;
However visual studio is complaining that it "can't implicty convert type 'UnityEngine.Texture' to 'AC.CursorIconBase".
Could someone clue me into the correct things to use in this instance?
Thanks!
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
The MenuGraphic element's "graphic" variable is of the type CursorIconBase - see the Scripting Guide's entry fot this class here.
However, you can update the element's texture with the SetNormalGraphic method, i.e:
@ChrisIceBox Thanks Chris. I need to do some more learning regarding types and the like!
That's working great.