hello everyone
i am in the process of making a weapon switching/looting script
here is how my system works: player interacts with the item of the floor.
the script gets a message that the player has the item = true. The GUI button for the item is drawn. If the button is pressed then the item is shown as your current equipped item.
using UnityEngine;
using System.Collections;
public class MainGUI : MonoBehaviour
{
public bool _displayinventory = true;
public bool _displaycharacterwindow;
public GUISkin myskin;
public GameObject curwep;
public GameObject PhotonCanon;
public GameObject RxBlaster;
public static bool _hasPhotonCanon = false;
public static bool _hasRxblaster = false;
// Update is called once per frame
void Update ()
{
}
void OnGUI ()
{
GUI.skin = myskin;
if (_hasPhotonCanon) {
//Debug.Log ("you have obtained a photon canon");
if (GUI.Button (new Rect (460, 750, 90, 70), "", "photoncanon")) {
curwep = PhotonCanon;
Debug.Log ("i iwll equip to you" + curwep.ToString ());
}
}
if (_hasRxblaster) {
//Debug.Log ("you have obtained a Rx-Blaster");
if (GUI.Button (new Rect (570, 750, 90, 70), "", "Rx-blaster")) {
Debug.Log ("i wll equip to you RX ON !!!!" + curwep.ToString ());
curwep = RxBlaster;
}
}
}
}
Here is the problem. first of all i am trying to make it so that the previous item that i had equipped turns off ( the gameobject turns off) and then the new item that has now been assigned to be the current weapon (curwep) turns on (the gamobject turns on).
I have attached my code. Can someone please take a look at this and please tell me how i should approach what i am trying to do
by the way this is all written in c# for those of you who haven't noticed.
Thanks in advance
Regards