Create the canvas text using the Create menu. If you're using ORK's menu system alongside your own separate canvas prefab, you might get 2 Event Systems (the one you already had plus the one ORK creates) Should you get that error, just delete your Event System from the scene hierarchy.
Attach a new C# script directly to the Text object. Call it whatever. Make sure to include Unity's UI namespace as well as ORK's namespace. Declare a public Text object so you can drag the Text component onto your script. Now that it has a reference to the text variable, anything you do to it will be reflected immediately.
Below is a sample code using the spacebar to update the text. Just make "variableKey" into the key of your ORK Global Variable.
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using ORKFramework;
public class ORKTextTest : MonoBehaviour { public Text textVariable;
If you're using ORK's menu system alongside your own separate canvas prefab, you might get 2 Event Systems (the one you already had plus the one ORK creates)
Should you get that error, just delete your Event System from the scene hierarchy.
Attach a new C# script directly to the Text object. Call it whatever.
Make sure to include Unity's UI namespace as well as ORK's namespace.
Declare a public Text object so you can drag the Text component onto your script.
Now that it has a reference to the text variable, anything you do to it will be reflected immediately.
Below is a sample code using the spacebar to update the text.
Just make "variableKey" into the key of your ORK Global Variable.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using ORKFramework;
public class ORKTextTest : MonoBehaviour
{
public Text textVariable;
void Update ()
{
if(Input.GetKeyDown(KeyCode.Space))
textVariable.text = ORK.Game.Variables.GetString ("variableKey").ToString();
}
}
Other types of variable are supported but be aware that each type has it's own Getter.
ORK.Game.Variables.GetBool;
ORK.Game.Variables.GetFloat;
ORK.Game.Variables.GetVector3;
They all return the appropriate type, but all use a key string to fetch.