So I'm making a weapon switching dropdown to change your weapon. And the thing is, I want the weapons to unlock on a specific level. The level is stored in my GameSettings class, I know how to access that, but the problem is, I can't get the item's index and disable the item.
My item's code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class item : MonoBehaviour {
public Text label;
public GameSettings settings;
private void Start()
{
if (settings.level >= 1 && label.text != "AK-47")
{
GetComponent().interactable = false;
} else
{
GetComponent().interactable = true;
}
if (settings.level >= 6 && label.text != "AK-47" || label.text != "M4")
{
GetComponent().interactable = false;
}
else
{
GetComponent().interactable = true;
}
if (settings.level >= 17 && label.text != "AK-47" || label.text != "M4" || label.text != "870 Shotgun")
{
GetComponent().interactable = false;
}
else
{
GetComponent().interactable = true;
}
if (settings.level >= 22)
{
GetComponent().interactable = true;
}
}
}
↧