Hi, i’ve been following this tutorial on inventory systems,
I’m having trouble removing them, I can’t even get them to debug anything (regardless whether its the right button thats pressed)
EDIT: This is attached to my main camera of the standard asset character controller
This is my script, although the error I think is somewhere in the drawmywindow function - Thanks
void Update(){
if (Input.GetKeyDown (KeyCode.Escape)) {
showInventory = !showInventory;
}
ray = Camera.main.ScreenPointToRay (Input.mousePosition);
if (Input.GetButtonDown ("Fire1")) {
if (Physics.Raycast (ray, out hit, 20)) {
for (int i = 0; i < bag.Length; i++) {
if (hit.collider.tag == bag*.id.ToString ()) {*
_ Inventory.Add (bag*);_
_ Destroy (hit.collider.gameObject);_
_ }_
_ }_
_ }_
_ }_
_ pos = transform.position;_
_ pos.x += 20;_
_ } // End update*_
* void OnGUI(){*
* if (showInventory == true) {*
* windowRect = GUI.Window (0, windowRect, DoMyWindow, “Inventory”);*
* }*
* }*
* void DoMyWindow(int windowID) {*
* int y = 20;*
* GUI.DragWindow(new Rect( 0,0,windowLength,20));*
* for(int i = 0; i < Inventory.Count; i++){*
_ if(GUI.Button (new Rect(20, y, 64, 64), Inventory*.icon)){
Debug.Log(“button clicked”);
Instantiate(Inventory.player,pos,transform.rotation);
Inventory.RemoveAt(i);
}
y+=70;
}
}//End DoMyWindow*_