Question by
kubajozwik · Feb 10 at 03:22 PM ·
variables
variables do not save between scripts
using UnityEngine;
using UnityEngine.UI;
public class MainButton : MonoBehaviour
{
public Text AmountDisplay;
public int ClickAmount;
public void Update()
{
AmountDisplay.text = ClickAmount + "";
}
public void ClickTheButton(int multiplier) {
Debug.Log(multiplier);
ClickAmount = ClickAmount + multiplier;
}
}
This is my Main script i want to save variables form his script to my next script
using UnityEngine;
using UnityEngine.UI;
public class Multipliers : MonoBehaviour
{
public int multiplier = 1;
private bool Enable = true;
public GameObject errorMoney;
public GameObject errorEnable;
public void ButtonX2Multiplier(int ClickAmount)
{
Debug.Log(ClickAmount);
if (ClickAmount >= 20 && Enable == true)
{
Enable = false;
ClickAmount = ClickAmount - 20;
multiplier = 2;
}
if(Enable == false)
{
errorMoney.SetActive(true);
}
if(ClickAmount < 20)
{
errorEnable.SetActive(false);
}
}
}
Can someone help my?
Comment
Your answer
Follow this Question
Related Questions
Getting an object's y coordinate 2 Answers
How to change text based on the value of a scrollbar? 1 Answer
Unreferenced label? 0 Answers
Pass a variable into a class on creation 1 Answer
Pickup Animation for Closest Object 1 Answer