Sinespace Client  2023.2.17543
Client-side scripting for Sinespace
SineSpace.Scripting.Components.SClickable Class Reference
Inheritance diagram for SineSpace.Scripting.Components.SClickable:
ScriptClassComponent< ClickableBaseInternal >

Public Member Functions

void AddExtraAction (string name, string tooltip, Action e)
 
void AddExtraAction (string name, string tooltip, Closure e)
 Add a new action for the object to perform when clicked. Can be useful for providing multiple choice of an action on click. More...
 
void ClearActions ()
 Removes all actions from the clickable GameObject. More...
 
void OnClick (Action e)
 
void OnClick (Closure e)
 When clicked, the GameObject performs the required action. More...
 
void InvokeClick ()
 Invoke a "click" on a Clickable component, as if the user had clicked on it themselves. More...
 

Properties

bool Enabled [get, set]
 Enable or disable the clickable component from a GameObject. More...
 
string Tooltip [get, set]
 A hint that pops up when the mouse is hovering over the GameObject. More...
 
- Properties inherited from ScriptClassComponent< ClickableBaseInternal >
SGameObject GameObject [get]
 Return the GameObject which component added. More...
 

Member Function Documentation

◆ AddExtraAction() [1/2]

void SineSpace.Scripting.Components.SClickable.AddExtraAction ( string  name,
string  tooltip,
Action  e 
)

◆ AddExtraAction() [2/2]

void SineSpace.Scripting.Components.SClickable.AddExtraAction ( string  name,
string  tooltip,
Closure  e 
)

Add a new action for the object to perform when clicked. Can be useful for providing multiple choice of an action on click.

hostObject = Space.Host.ExecutingObject;
&ndash;Add Clickable component to the GameObject
hostObject.AddClickable();
function ClickMeAndCount ()
local n = 0;
return function ()
n = n+1;
Space.Log("I was clicked " .. n .. " times!");
end
end
local f = ClickMeAndCount ();
hostObject.Clickable.AddExtraAction ("Click me and count", "Prints to the console
how many times I was clicked", f);
&ndash;Add the closure to action.

◆ ClearActions()

void SineSpace.Scripting.Components.SClickable.ClearActions ( )

Removes all actions from the clickable GameObject.

hostObject = Space.Host.ExecutingObject;
hostObject.AddClickable();
function ClickMe ()
Space.Log("I was clicked!");
end
function ClickAndClear ()
Space.Log("No more actions!");
hostObject.Clickable.ClearActions ();
end
hostObject.Clickable.AddExtraAction ("Click me", "Prints I was clicked! to the console", ClickMe);
hostObject.Clickable.AddExtraAction ("Click And Clear", "Clears all actions", ClickAndClear);
&ndash;Add both function to extra action.
&ndash; Now, when the latter option is chosen, the script clears the Clickable component of all actions.

◆ InvokeClick()

void SineSpace.Scripting.Components.SClickable.InvokeClick ( )

Invoke a "click" on a Clickable component, as if the user had clicked on it themselves.

hostObject = Space.Host.ExecutingObject;
hostObject.AddClickable();
function ClickMe()
Space.Log("I was clicked!");
end
hostObject.Clickable.OnClick(ClickMe);
hostObject.Clickable.InvokeClick();

◆ OnClick() [1/2]

void SineSpace.Scripting.Components.SClickable.OnClick ( Action  e)

◆ OnClick() [2/2]

void SineSpace.Scripting.Components.SClickable.OnClick ( Closure  e)

When clicked, the GameObject performs the required action.

hostObject = Space.Host.ExecutingObject;
hostObject.AddClickable();
function ClickAndCount ()
n = 0;
return function ()
n = n+1;
Space.Log("I was clicked " .. n .. " times!");
end
end
local f = ClickAndCount ();
&ndash;Register the closure to clickable.
hostObject.Clickable.OnClick (f);

Property Documentation

◆ Enabled

bool SineSpace.Scripting.Components.SClickable.Enabled
getset

Enable or disable the clickable component from a GameObject.

Scene = Space.Scene
&ndash;Get the scene where you are.
Cube = Scene.Find(“Cube”)
&ndash;Get the cube game object you have set there
Clickable=Cube.AddClickable();
&ndash;Add and get the clickable value.
Clickable.Enabled = false
&ndash;Set clickable active.

◆ Tooltip

string SineSpace.Scripting.Components.SClickable.Tooltip
getset

A hint that pops up when the mouse is hovering over the GameObject.

hostObject = Space.Host.ExecutingObject;
hostObject.AddClickable();
&ndash; Prints an empty string to the console - Tooltip is empty upon initializing.
hostObject.Clickable.Tooltip = "I am clickable!";
&ndash; Now, when a mouse is hovered for a few seconds over the object, "I am clickable!" will appear.
SineSpace.Scripting.Components.SClickable.InvokeClick
void InvokeClick()
Invoke a "click" on a Clickable component, as if the user had clicked on it themselves.
Definition: SClickable.cs:206
SineSpace.Scripting.Components.SClickable.AddExtraAction
void AddExtraAction(string name, string tooltip, Action e)
Definition: SClickable.cs:65
ScriptClassComponent< ClickableBaseInternal >::GameObject
SGameObject GameObject
Return the GameObject which component added.
Definition: ScriptClass.cs:25
SineSpace.Scripting.Components.SClickable.Tooltip
string Tooltip
A hint that pops up when the mouse is hovering over the GameObject.
Definition: SClickable.cs:58
SineSpace.Scripting.Components.SClickable.ClearActions
void ClearActions()
Removes all actions from the clickable GameObject.
Definition: SClickable.cs:130
SineSpace.Scripting.Components.SClickable.OnClick
void OnClick(Action e)
Definition: SClickable.cs:137