so my weapon wheel is up and running real good with the new swapping implemented…i just have a few minor problems…
- when i first start the game and open the weapon wheel, the cursor doesn’t appear until i press escape atleast once …
- i have set my weaponwheel so that when the player holds down a certain key (f as of now)…it remains active and disabled…but this causes a strange problem that the sprite swap (embedded in the buttons) doesn’t function correctly when highlighting the button through hover…this problem is solved if i use a GetKeyDown based enable and disable metod…but since i want to keep them both as options…i need to know the solution…
- Since in unity, buttons can be directly controlled by keyboard…the same happens with the buttons on my wheel…with the difference being that the wheel has 16 buttons, since each weapon marker is semicircular and is hence occupied by four buttons each…i want to disable the key bindings of the buttons…
script 1
Here are my UImanager(basically manages the pausing and all)…and weapon wheel script…
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class UImanager : MonoBehaviour
{
public GameObject pausemenu;
public GameObject hud;
public WeaponWheel wheel;
public string pauseavailablity = "available";
public bool pauseactive;
public bool initialpause = false;
public bool pausing;
// Start is called before the first frame update
void Start()
{
hud.SetActive(true);
pausemenu.SetActive(false);
pauseactive = initialpause;
}
public void Resume()
{
FindObjectOfType<AudioManager>().PlayClip("resume1");
pausing = false;
}
public void Pause()
{
FindObjectOfType<AudioManager>().PlayClip("pause1");
pausing = true;
}
// Update is called once per frame
void Update()
{
if(SceneManager.GetActiveScene().buildIndex != 0)
{
if(pauseavailablity == "available")
{
if(Input.GetButtonDown("Cancel") && pausing && !wheel.wheelactive)
{
Resume();
}
else if(Input.GetButtonDown("Cancel") && !pausing && !wheel.wheelactive)
{
Pause();
}
if(pausing)
{
pauseactive = true;
pausemenu.SetActive(true);
Cursor.lockState = CursorLockMode.Confined;
}
else
{
pauseactive = false;
pausemenu.SetActive(false);
}
if(wheel.wheelactive)
{
pauseactive = true;
Cursor.lockState = CursorLockMode.Confined;
}
else if(!pausing)
{
pauseactive = false;
}
}
else
{
Cursor.lockState = CursorLockMode.Confined;
}
}
}
}
script 2
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class UImanager : MonoBehaviour
{
public GameObject pausemenu;
public GameObject hud;
public WeaponWheel wheel;
public string pauseavailablity = "available";
public bool pauseactive;
public bool initialpause = false;
public bool pausing;
// Start is called before the first frame update
void Start()
{
hud.SetActive(true);
pausemenu.SetActive(false);
pauseactive = initialpause;
}
public void Resume()
{
FindObjectOfType<AudioManager>().PlayClip("resume1");
pausing = false;
}
public void Pause()
{
FindObjectOfType<AudioManager>().PlayClip("pause1");
pausing = true;
}
// Update is called once per frame
void Update()
{
if(SceneManager.GetActiveScene().buildIndex != 0)
{
if(pauseavailablity == "available")
{
if(Input.GetButtonDown("Cancel") && pausing && !wheel.wheelactive)
{
Resume();
}
else if(Input.GetButtonDown("Cancel") && !pausing && !wheel.wheelactive)
{
Pause();
}
if(pausing)
{
pauseactive = true;
pausemenu.SetActive(true);
Cursor.lockState = CursorLockMode.Confined;
}
else
{
pauseactive = false;
pausemenu.SetActive(false);
}
if(wheel.wheelactive)
{
pauseactive = true;
Cursor.lockState = CursorLockMode.Confined;
}
else if(!pausing)
{
pauseactive = false;
}
}
else
{
Cursor.lockState = CursorLockMode.Confined;
}
}
}
}
Any and all help is appreciated, Thanks in Advance!