Invokes a UnityEvent attached to the Scripting Runtime component this script is executing in.
Parameter
Type
Description
Space.Host.InvokeEvent("EventName")
Stop
void Stop ()
Pauses the current script until it is manually restarted, at the end of the current function/method; consider using return as well.
Space.Host.Stop()
local trans=Space.Host.ExecutingObject;trans.SubscribeToEvents();functionRunning() Space.Log("Running")endtrans.OnUpdate(Running)Space.Host.InvokeDelayed(function() Space.Log("Stop") Space.Host.Stop()end,5)--After print the "Stop","Running" won't display anymore.
InvokeDelayed
void InvokeDelayed (Closure c, float delay)
Invoke the closure after the delayed time.
Parameter
Type
Description
Space.Host.InvokeDelayed(AFunction, 10)
--Clicking this object makes it destroy itself after 5 secondsthisObject = Space.Host.ExecutingObjectfunctionDeleteFunction() thisObject.Destroy()endfunctionOnClickFunction() Space.Host.InvokeDelayed(DeleteFunction,10)endthisObject.AddClickable()thisObject.Clickable.OnClick(OnClickFunction)
localfunctionmyCoroutine()-- The yield statement is a special kind of return, that ensures that the function will continue from the line once the coroutine resumes.-- Placing a float value inside of the yield will result in a delayed execution.-- Example: coroutine.yield(0.5) will wait 0.5 seconds before continuing the execution of the coroutine.-- This will print the current players active time. Space.Log(Space.Time);-- Execution of this coroutine will be halted for 10 seconds.coroutine.yield(10);-- This will print the current players active time, which will be 10 seconds greater then the previous as a result of the yield Space.Log(Space.Time);endSpace.Host.StartCoroutine(myCoroutine);
ReferenceExists
bool ReferenceExists (string name)
Return true when the reference object exists and is not empty.
Return true when the reference object exists and is not empty.
Parameter
Type
Description
existsNotEmpty = Space.Host.ReferenceExistsAndNotEmpty("obj")--Print "false" to console if didn't set the object named "obj" to the Object References or attach the reference to "obj".
--Clicking this object makes it destroy the object we linked in the references sectionthisObject = Space.Host.ExecutingObjectdObject = Space.Host.GetReference("theObjectToBeDestroyed")functionOnClickFunction() dObject.Destroy()endthisObject.AddClickable()thisObject.Clickable.OnClick(OnClickFunction)
Evaluate
void Evaluate (string script)
Executes given Lua code/script. (white-label only)
A reference to the GameObject that is executing this script. (The GameObject that this Scripting Runtime component is attached to).
object = Space.Host.ExecutingObject
Language
string Languageget
Returns the English name for the users language, e.g. 'English', 'French', 'Chinese'
lang = Space.Host.Language
--Makes a UIText show a different message according to the client's languageTextObject = Space.Host.GetReference("TextObject") --add to references section of Scripting Runtime componentlanguage = Space.Host.Languageif language =="English" then TextObject.UIText.Text ="Welcome!"elseif language =="Dutch" then TextObject.UIText.Text ="welkom!"elseif language =="French" then TextObject.UIText.Text ="bienvenue!"else TextObject.UIText.Text ="Welcome!"end