Hello Unity players I wanted to ask how would I get one scripts to change another
script float?
Such as I have a game score and I want one script to change the gamescore script float
to 1.
But how would I do this?
Thanks!
Hello Unity players I wanted to ask how would I get one scripts to change another
script float?
Such as I have a game score and I want one script to change the gamescore script float
to 1.
But how would I do this?
Thanks!
Make the float you want to edit from the other script public.
If you don’t want to keep a reference to it, make it static as well.
Consiering you want to change the gamescore public static should be the simplest way to do it.
example :
class A
{
public static float ChangeMe;
}
class B : MonoBehavior
{
void Update()
{
A.ChangeMe+=Time.deltaTime;
}
}