SDialogues

Index

Functions

ColorPicker

Opens a color picker dialogue.

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

--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)

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)

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 )

-- 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 )

hostObject = Space.Host.ExecutingObject

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

hostObject.OnMouseDown(chatMessage)

Last updated

Sinespace® is a registered trademark of Sine Wave Entertainment Ltd, All Rights Reserved.