private void Start() { GameEvents.SaveInitiated += SaveInventory; UIEventHandler.OnItemRemovedFromInventory += RemoveItem; inventoryDetailsPanel1 = Resources.FindObjectsOfTypeAll <InventoryUIDetails>(); inventoryDetailsPanel = inventoryDetailsPanel1[0]; LoadInvetory(); if (Instance != null && Instance != this) { Destroy(gameObject); } else { Instance = this; } }
void Awake() { if (Instance != null && Instance != this) { Destroy(gameObject); } else { Instance = this; } userInterface = this.transform.Find("UserInterface").gameObject; inventoryUIController = Instantiate(Resources.Load <GameObject>("UI/Inventory")); inventoryUIController.transform.SetParent(userInterface.transform); inventoryPanel = Instantiate(Resources.Load <GameObject>("UI/Inventory_Panel")); inventoryPanel.transform.SetParent(userInterface.transform, false); // TODO: Move this to its own file characterPanel = Instantiate(Resources.Load <GameObject>("UI/Character/Character_Panel")); characterPanel.transform.SetParent(userInterface.transform, false); characterPanel.SetActive(false); characterPanel.GetComponent <CharacterPanel>().player = GetComponent <Player>(); characterPanel.GetComponent <CharacterPanel>().InitializeStats(); characterPanel.GetComponent <CharacterPanel>().InitializeLevel(); // END TODO playerWeaponController = GetComponent <PlayerWeaponController>(); consumableController = GetComponent <ConsumableController>(); inventoryDetailsPanel = inventoryPanel.transform.GetChild(1).GetComponent <InventoryUIDetails>(); GiveItem("sword"); GiveItem("staff"); GiveItem("potion_log"); }