hostObject = Space.Host.ExecutingObjecthostObject.AddClickable()functionClickMe ()Space.Log("I was clicked!")endfunctionClickAndClear ()Space.Log("No more actions!")hostObject.Clickable.ClearActions ()endhostObject.Clickable.AddExtraAction ("LogButton", "Prints I was clicked! to the console", ClickMe)hostObject.Clickable.AddExtraAction ("ClearButton", "Clears all actions", ClickAndClear)-- Now, when the latter option is chosen, the script clears the Clickable component of all actions.
OnClick
void OnClick (Closure e)
When clicked, the GameObject performs the required action.
hostObject = Space.Host.ExecutingObjecthostObject.AddClickable()deltaPos = Vector.New(0,0,1)functionMakeMeMove ()hostObject.WorldPosition = hostObject.WorldPosition + deltaPosendhostObject.Clickable.OnClick (MakeMeMove);-- Now, every time an object is clicked, it moves by 1 in the positive Z direction.
Properties
Enabled
bool Enabledgetset
Enable or disable the clickable component from a GameObject.
--Clicking the object will disable the component, making it only clickable oncethisGameObject = Space.Host.ExecutingObjectOnClick=function() thisGameObject.Clickable.Enabled =falseendthisGameObject.AddClickable()thisGameObject.Clickable.Tooltip ="Click to activate"thisGameObject.Clickable.OnClick(OnClick)
Tooltip
string Tooltipgetset
A hint that pops up when the mouse is hovering over the GameObject.
--Clicking the object will toggle between two different tooltipsthisGameObject = Space.Host.ExecutingObjectOnClick=function()if thisGameObject.Clickable.Tooltip =="Turn On" then thisGameObject.Clickable.Tooltip ="Turn Off"else thisGameObject.Clickable.Tooltip ="Turn On"endendthisGameObject.AddClickable()thisGameObject.Clickable.Tooltip ="Turn On"thisGameObject.Clickable.OnClick(OnClick)
GameObject
SGameObject GameObjectget
Returns a reference to the GameObject of this component.