Skip to main content

SDialogues

Index

Function Name
void ColorPicker (string title, string okbutton, Action< SColor > onChange, Action< SColor > onSelect, Action onCancel, SColor defaultColor)
void YesNoInput (string title, string okbutton, string cancelButton, Action< bool > result)
void TextInput (string title, string okButton, Action< string > result)
void OpenURL (string url, bool newTab = true)
void SendLocalChat (string message, string from)

Functions

ColorPicker

Opens a color picker dialogue.

void ColorPicker(string title, string okbutton, Action< SColor > onChange, Action< SColor > onSelect, Action onCancel, SColor defaultColor)

ParameterTypeDescription
titlestringThe title of the color picker window. Choose something brief and appropriate like 'Select a wall color'.
okbuttonstringThe title of the 'OK' button. Should indicate the action e.g. 'Adjust Wall'.
onChangeAction\<SColor> or ClosureAny color change while the color picker is open will trigger onChange(SColor).
onSelectAction\<SColor> or ClosureTriggers onSelect(SColor) once the "ok" button is pressed.
onCancelAction\<SColor> or ClosureThe title of the 'OK' button. Should indicate the action e.g. 'Adjust Wall'.
defaultColorSColorThe color to open the colour picker with.
--clicking the object will open a color picker that changes the object's color
thisGameObject = Space.Host.ExecutingObject
originalColor = thisGameObject.Renderer.Material.GetColor("_Color")

OnChange = function(SColor)
thisGameObject.Renderer.Material.SetColor("_Color",SColor)
end

OnSelect = function(SColor)
thisGameObject.Renderer.Material.SetColor("_Color",SColor)
end

OnCancel = function()
thisGameObject.Renderer.Material.SetColor("_Color",originalColor)
end

OnClick = function()
Space.Dialogues.ColorPicker("title","okbutton", OnChange, OnSelect, OnCancel, originalColor)
end


thisGameObject.AddClickable()
thisGameObject.Clickable.OnClick(OnClick)

YesNoInput

Opens a simple Yes/No dialogue.

void YesNoInput(string title, string okbutton, string cancelButton, Action< bool > result)

ParameterTypeDescription
titlestringThe question to be asked of the user. Should be a simple statement, e.g. "Save room changes?"
okbuttonstringThe text on the OK button, should indicate the action, e.g. "Save Room"
cancelButtonstringThe text on the cancel button, should indicate the action, e.g. "Not now"
resultAction\<bool>Will fire a callback event depending on the status of the users actions
hostObject = Space.Host.ExecutingObject
local deltaPos = Vector.New(0,100,0)
local teleportTo = hostObject.WorldPosition + deltaPos

function teleportMeUp (b)
if b then
Space.Scene.PlayerAvatar.Teleport(teleportTo)
end
end

function openDialogue ()
Space.Dialogues.YesNoInput ("Ready for a teleport?", "Yes", "No", teleportMeUp)
end

hostObject.SubscribeToEvents()
hostObject.OnMouseDown(openDialogue)

TextInput

Opens a text entry window with room for a single multi-line text field.

void TextInput ( string title, string okButton, Action< string > result)

ParameterTypeDescription
titlestringThe accompanying text. Should be something ala "Enter your username".
okButtonstringThe text displayed on the OK button, should be descriptive, e.g. "Change Username".
resultAction< string >Triggers result(string) once the "Ok" button is pressed.
hostObject = Space.Host.ExecutingObject

printToLog = function (s)
Space.Log(s)
end

function openDialogue ()
Space.Dialogues.TextInput ("Write anything.", "Done", printToLog)
end

hostObject.OnMouseDown(openDialogue)

OpenURL

Opens the specified URL in the in-app web browser, or the system web browser. In some environments the user may be prompted before this is opened.

void OpenURL ( string url, bool newTab = true )

ParameterTypeDescription
urlstringThe web address to open.
newTabboolDoes the URL open in a new browser tab?
-- when the object is clicked, the "sine.space" website is opened
hostObject = Space.Host.ExecutingObject

function openTheWebsite ()
Space.Dialogues.OpenURL("http://sine.space/")
end

hostObject.OnMouseDown(openTheWebsite)

SendLocalChat

Sends a message into the 'Script' chat channel.

void SendLocalChat ( string message, string from )

ParameterTypeDescription
messagestringThe message to appear in the channel.
fromstringThe 'from' username for the message.
hostObject = Space.Host.ExecutingObject

function chatMessage ()
Space.Dialogues.SendLocalChat ("I've been clicked", "Clickable Object")
end

hostObject.OnMouseDown(chatMessage)