Integrating the code
Now that we have our HUD design up and running, we will need to integrate the UI elements with the actual code that will be deriving them. There are a few scripts that will be created to support the new UI features and a few that will be updated to glue everything together.
The following scripts have been created: ActiveInventoryItemUi.cs
, ActiveSpecialItemUi.cs
, and HudElementUi.cs
.
The listing of these scripts is as follows:
using UnityEngine.EventSystems; namespace com.noorcon.rpg2e { public class ActiveSpecialItemUi : EventTrigger { public override void OnPointerClick(PointerEventData data) { InventoryItem iia = gameObject.GetComponent<ActiveInventoryItemUi>().item; switch (iia.Category) { case BaseItem.ItemCatrgory.Health: { // add the item to the special items panel GameMaster.instance.Ui.ApplySpecialInventoryItem(iia); Destroy(gameObject); break; } case BaseItem.ItemCatrgory.Potion: { break; } } } } } using UnityEngine; using UnityEngine.UI; namespace com.noorcon...