Heyo,
I've built a little system that puts a notifications badge on a button in my UI, much like how it looks on an iPhone. When I click the button (called Dossier Button) to open the associated menu (called Dossier), I want to clear the badge.
In the script that governs the Dossier menu, it has this:
AC.MenuLabel notifier;
void Start() {
notifier = (AC.MenuLabel) PlayerMenus.GetElementWithName("Dossier Button", "Notifications badge");
}
void Update() {
//see whether there are any notifications, and if so, display the badge
string notifications = GameObject.FindWithTag(Tags.persistentEngine).GetComponent<RuntimeVariables>().GetVarValue(0);
if (notifications != "0") {
notifier.isVisible = true;
}
else {
notifier.isVisible = false;
}
}
This works perfectly when I modify the value from the AC Variables menu. However, it does not work when I call it from the Menusystem.cs like this:
public static void OnMenuEnable (Menu _menu) {
if (_menu.title == "Dossier") {
//clear the notifications badge
GameObject.FindWithTag(Tags.persistentEngine).GetComponent<RuntimeVariables>().SetValue(0, "0");
}
Turning the badge off manually in the same code block does nothing either. Any idea why that is?
Comments
Word of warning: 1.32 changes the syntax slightly for setting/getting variables. Your new code would be:
GlobalVariables.GetBooleanValue (0)
and
GlobalVariable.SetBooleanValue (0, false);