Home Access public static variable from another script Unity
Reply: 0

Access public static variable from another script Unity

user714
1#
user714 Published in April 27, 2018, 6:42 am

I am trying to access and change of the value of a variable from another script, I have watched various different tutorial on youtube but cannot seems to do it. It always come up with an error as following:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GlobalValues : MonoBehaviour
{

    public static bool c2u;

}

And the other script

public class Choosing : MonoBehaviour {
private void Start()
{
    GlobalValues.c2u = false;
}
}

In the "Choosing" script, the GlobalValues always shows "'GlobalValues' does not exist in this current context". What can i do to fix this problem

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.345927 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO