(→Members) |
|||
Line 2: | Line 2: | ||
==Members== | ==Members== | ||
− | {{ScriptFunction|void|InvokeEvent|(string name);|Invokes a UnityEvent attached to the Scripting Runtime component this script is executing in.}} | + | {{ScriptFunction|void|InvokeEvent|(string name);|Invokes a UnityEvent attached to the Scripting Runtime component this script is executing in.| |
− | {{ScriptFunction|void|Stop|();|Pauses the current script until it is manually restarted, at the end of the current function/method; consider using return as well}} | + | function InvokeExample()<br> |
− | {{ScriptFunction|SGameObject|ExecutingObject|{ get; }|Returns the SGameObject this script is attached to}} | + | Space.Log("Invoke Event");<br> |
− | {{ScriptFunction|string|Language|{ get; }|Returns the English name for the users language, e.g. 'English', 'French', 'Chinese'}} | + | end<br> |
+ | ''--Attach the upon function to Scripting Runtime/Unity Interfaces/Events,Named "InvokeExample.''<br><br> | ||
+ | Space.Host.InvokeEvent("InvokeExample");<br> | ||
+ | ''--print "Invoke Event" to the console.'' | ||
+ | }} | ||
+ | |||
+ | {{ScriptFunction|void|Stop|();|Pauses the current script until it is manually restarted, at the end of the current function/method; consider using return as well.|5= | ||
+ | local trans=Space.Host.ExecutingObject;<br> | ||
+ | trans.SubscribeToEvents();<br><br> | ||
+ | function Running()<br> | ||
+ | Space.Log("Running")<br> | ||
+ | end<br><br> | ||
+ | trans.OnUpdate(Running)<br><br> | ||
+ | Space.Host.InvokeDelayed(function()<br> | ||
+ | Space.Log("Stop")<br> | ||
+ | Space.Host.Stop()<br> | ||
+ | end,5)<br><br> | ||
+ | ''--After print the "Stop","Running" won't display anymore.'' | ||
+ | }} | ||
+ | |||
+ | {{ScriptFunction|SGameObject|ExecutingObject|{ get; }|Returns the SGameObject this script is attached to.|5= | ||
+ | local obj=Space.Host.ExecutingObject;<br> | ||
+ | Space.Log(obj.Name);<br> | ||
+ | ''--print object name to the console.'' | ||
+ | }} | ||
+ | |||
+ | {{ScriptFunction|string|Language|{ get; }|Returns the English name for the users language, e.g. 'English', 'French', 'Chinese'| | ||
+ | Space.Log(Space.Host.Language);<br> | ||
+ | ''--print current system language in English.'' | ||
+ | }} | ||
+ | |||
{{ScriptFunction|void|StartCoroutine|(DynValue func);|Executes the specified function as a coroutine.| | {{ScriptFunction|void|StartCoroutine|(DynValue func);|Executes the specified function as a coroutine.| | ||
local function myCoroutine() | local function myCoroutine() |
The SHost class represents the scripting runtime.
Invokes a UnityEvent attached to the Scripting Runtime component this script is executing in.
function InvokeExample()
Space.Log("Invoke Event");
end
--Attach the upon function to Scripting Runtime/Unity Interfaces/Events,Named "InvokeExample.
Space.Host.InvokeEvent("InvokeExample");
--print "Invoke Event" to the console.
Pauses the current script until it is manually restarted, at the end of the current function/method; consider using return as well.
trans.SubscribeToEvents();
function Running()
Space.Log("Running")
end
trans.OnUpdate(Running)
Space.Host.InvokeDelayed(function()
Space.Log("Stop")
Space.Host.Stop()
end,5)
Returns the SGameObject this script is attached to.
Space.Log(obj.Name);
Returns the English name for the users language, e.g. 'English', 'French', 'Chinese'
Space.Log(Space.Host.Language);
--print current system language in English.
Executes the specified function as a coroutine.
local function myCoroutine()
-- 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);
end
Space.Host.StartCoroutine(myCoroutine);
|