Line 15: | Line 15: | ||
''-- Prints an empty string to the console - Tooltip is empty upon initializing.''<br> | ''-- Prints an empty string to the console - Tooltip is empty upon initializing.''<br> | ||
hostObject.Clickable.Tooltip = "I am clickable!";<br> | hostObject.Clickable.Tooltip = "I am clickable!";<br> | ||
− | ''-- Now, when a mouse is hovered for a few seconds over the object, "I am clickable!" will appear.''}} | + | ''-- Now, when a mouse is hovered for a few seconds over the object, "I am clickable!" will appear.''|6=<pre>--Clicking the object will toggle between two different tooltips |
+ | thisGameObject = Space.Host.ExecutingObject | ||
+ | |||
+ | |||
+ | OnClick = function() | ||
+ | if thisGameObject.Clickable.Tooltip == "Turn On" then | ||
+ | thisGameObject.Clickable.Tooltip = "Turn Off" | ||
+ | else | ||
+ | thisGameObject.Clickable.Tooltip = "Turn On" | ||
+ | end | ||
+ | end | ||
+ | |||
+ | |||
+ | thisGameObject.AddClickable() | ||
+ | thisGameObject.Clickable.Tooltip = "Turn On" | ||
+ | thisGameObject.Clickable.OnClick(OnClick)</pre>}} | ||
==Members== | ==Members== |
The SClickable class provides tools to work with the Clickable component, which is responsible for interacting with the object through clicking on it.
Enable or disable the clickable component from a GameObject.
Cube = Scene.Find("Cube");
Clickable=Cube.AddClickable();
Clickable.Enabled = false;
A hint that pops up when the mouse is hovering over the GameObject.
hostObject.AddClickable();
Space.Log(hostObject.Clickable.Tooltip);
-- Prints an empty string to the console - Tooltip is empty upon initializing.
hostObject.Clickable.Tooltip = "I am clickable!";
--Clicking the object will toggle between two different tooltips thisGameObject = Space.Host.ExecutingObject OnClick = function() if thisGameObject.Clickable.Tooltip == "Turn On" then thisGameObject.Clickable.Tooltip = "Turn Off" else thisGameObject.Clickable.Tooltip = "Turn On" end end thisGameObject.AddClickable() thisGameObject.Clickable.Tooltip = "Turn On" thisGameObject.Clickable.OnClick(OnClick)
Add a new action for the object to perform when clicked. Can be useful for providing miltuple choice of an action on click.
hostObject.AddClickable();
function ClickMe ()
end
Add a new action for the object to perform when clicked. Can be useful for providing miltuple choice of an action on click.
hostObject.AddClickable();
function ClickMeAndCount ()
end
local f = ClickMeAndCount ();
hostObject.Clickable.AddExtraAction ("Click me and count", "Prints to the console how many times I was clicked", f);
Removes all actions from the clickable GameObject.
hostObject.AddClickable();
function ClickMe ()
end
function ClickAndClear ()
end
hostObject.Clickable.AddExtraAction ("Click me", "Prints I was clicked! to the console", ClickMe);
hostObject.Clickable.AddExtraAction ("Click And Clear", "Clears all actions", ClickAndClear);
When clicked, the GameObject performs the required action.
hostObject.AddClickable();
local deltaPos = Vector.New(0,0,1);
function MakeMeMove ()
end
hostObject.Clickable.OnClick (MakeMeMove);
When clicked, the GameObject performs the required action.
hostObject.AddClickable();
function ClickAndCount ()
end
local f = ClickAndCount ();
|