I have a game counter I plan to use to sequence a number of events (animations and text) based on two buttons; one to increment the counter and one to reset the counter back to 0. I have setup 3 scripts and am trying to use the onClick function of the new GUI system to modify the counter. All scripts are attached to the same game object.
Just now i am not getting anything to print in the console and neither of the buttons do anything ![]()
The first creates the public static int “nextNum”
using UnityEngine;
using System.Collections;
public class SetButInc : MonoBehaviour {
public static int nextNum;
void Start () {
nextNum=0;
Debug.Log (nextNum);
}
}
The second is attached to the onclick function of the increment button.
using UnityEngine;
using System.Collections;
public class PanelButInc : MonoBehaviour {
public void PanelButtonInc() {
SetButInc.nextNum ++;
}
}
And the third is attached to the onclick function of the reset button.
using UnityEngine;
using System.Collections;
public class LogoButReset : MonoBehaviour {
public void LogoButtonReset() {
SetButInc.nextNum=0;
}
}
Many thanks.
Is SetButInc actually attached to a GameObject in the scene? If that script doesn't debug in Start(), then your other scripts won't do anything.
– SpinnernicholasAll three scripts are attached to a UI Manager GameObject. Not sure how to amend the script based on your 2nd comment?
– neeeb