using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using UnityEngine.SceneManagement; public class InvSceneSettings : MonoBehaviour { GameObject pPar; GameObject player1; PlayerInventory pInv; public GameObject itemOptPrefab; private Text pointText; private PlayerStats pStats; InventoryManager invMan; Vector3 position; private int pointsLeft; // Start is called before the first frame update void Awake(){ pPar = GameObject.Find("DebugPlayerPrefab"); player1 = pPar.transform.Find("PlayerModel").gameObject; pStats = player1.GetComponent(); pointText = GameObject.Find("PlayerPoints").GetComponentInChildren(); pInv = player1.GetComponent(); player1.GetComponent().enabled = false; pPar.transform.Find("PlayerCam").gameObject.SetActive(false); invMan = GetComponent(); } void Start(){ player1.GetComponent().enabled = true; InitializeItemB(); pointsLeft = pStats.PlayerPoints; pointText.text = "Points Left: " + pointsLeft; } void FixedUpdate(){ itemToEnable(); } private void InitializeItemB(){ int index = 0; if(itemOptPrefab != null){ foreach(var item in invMan.ItemDict){ //Positioning Buttons if(index < 5){ position = new Vector3(((index)),3,0); } else{ position = new Vector3(((index-5)),2,0); } //Creates Button var iOpt = Instantiate(itemOptPrefab, position, Quaternion.identity); //Uses Item Variables to update button iOpt.name = item.Value.itemName; iOpt.transform.SetParent(GameObject.Find("Items").transform); iOpt.transform.localScale = new Vector3(1.5f,1.5f,1.5f); //Button Adds item if it can iOpt.GetComponent