Hi i was wondering how would i make it so that i could use the UI Button to switch weapons (Since I’m developing for android). Here’s the script here :
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class SwitchWeaponsScript : MonoBehaviour
{
public GameObject weapon1;
public GameObject weapon2;
void Update(GameObject SwitchWeaponButton)
{
if (SwitchWeaponButton.GetButtonDown)
{
switchWeapon();
}
}
void switchWeapon()
{
if (weapon1.activeSelf)
{
weapon1.SetActive(false);
weapon2.SetActive(true);
}
else
{
weapon1.SetActive(true);
weapon2.SetActive(false);
}
}
}
I don’t understand if i should use GetButtonDown, GetButtonUp etc. Please Help
Thanks in advance