Forum rules - please read before posting.

Can't get global integer variable through script

edited November 2020 in Technical Q&A

How do I get global integer variable? Using 1.50f AC unity 5.2.4
I'm trying this

using UnityEngine;
using System.Collections;

namespace AC
public class VarableTest: MonoBehaviour {
GVar MyVar;
// Use this for initialization

void Start () {
        MyVar= AC.GlobalVariables.GetVariable (228);


// Update is called once per frame
void Update ()
        if (MyVar.IntegerValue = 20)
            Debug.Log ("test");


It's giving me this
Assets/VarableTest.cs(21,38): error CS1061: Type AC.GVar' does not contain a definition forIntegerValue' and no extension method IntegerValue' of typeAC.GVar' could be found (are you missing a using directive or an assembly reference?)

if I use
if (MyVar = 20)

it gives
Cannot implicitly convert type int' toAC.GVar'


  • The Scripting Guide is for the current release - it won't apply for such an outdated version.

    Read "val" instead of "IntegerValue", and you comparison checks require two equal signs:

    if (MyVar.val == 20)
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.