You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/en-us/input/mobile.md
+22-81Lines changed: 22 additions & 81 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,8 +7,7 @@ Over half of all Roblox sessions are played on mobile devices, so it's important
7
7
8
8
When designing a mobile experience, consider the [device orientation](#device-orientation) that you intend user's to use in your experience, then implement your inputs with `Class.ContextActionService` to perform the following mobile-related input tasks:
9
9
10
-
-[Create on-screen buttons](#adding-mobile-buttons) visible only on mobile devices.
11
-
-[Customize the mobile buttons and UI](#customizing-button-ui) to create a unique mobile experience.
10
+
-[Create on-screen buttons](#custom-mobile-buttons) visible only on mobile devices.
12
11
-[Setup context dependent inputs](#context-dependent-inputs) that allows the same button or input to perform a different action depending on the situation.
13
12
-[Detect other input devices](#detecting-other-devices), such as a mouse or keyboard connected to a mobile tablet, to provide the correct on-screen prompts to the user.
14
13
@@ -165,11 +164,9 @@ When `Class.StarterPlayer.AutoJumpEnabled` is enabled, the user's character auto
165
164
166
165
Disable `Class.StarterPlayer.AutoJumpEnabled` to disable this feature and force users to jump only using their key bindings.
167
166
168
-
## Adding Mobile Buttons
167
+
## Custom Mobile Buttons
169
168
170
-
To add mobile buttons, use the `Class.ContextActionService:BindAction()` method.
171
-
172
-
The `Class.ContextActionService:BindAction()|BindAction()` method takes the following parameters:
169
+
To add custom mobile buttons, use the `Class.ContextActionService:BindAction()` method which takes the following parameters:
173
170
174
171
<table>
175
172
<thead>
@@ -181,25 +178,25 @@ The `Class.ContextActionService:BindAction()|BindAction()` method takes the foll
181
178
</thead>
182
179
<tbody>
183
180
<tr>
184
-
<td>actionName</td>
181
+
<td>`actionName`</td>
185
182
<td>string</td>
186
183
<td>An identifier string for the action you are binding. You can use the actionName with other functions in `Class.ContextActionService` to edit the binding.</td>
187
184
</tr>
188
185
<tr>
189
-
<td>functionToBind</td>
186
+
<td>`functionToBind`</td>
190
187
<td>function</td>
191
188
<td>The function to call when the specified input is triggered. This function receives three arguments:
192
189
<ul><li> A string equal to the actionName.</li>
193
190
<li> A `Enum.UserInputState` which defines the input state when it called the function.</li>
194
191
<li> The `Class.InputObject` used in the function call.</li></ul></td>
195
192
</tr>
196
193
<tr>
197
-
<td>createTouchButton</td>
194
+
<td>`createTouchButton`</td>
198
195
<td>boolean</td>
199
196
<td>When true, creates an on-screen button when the game is running on a mobile device.</td>
200
197
</tr>
201
198
<tr>
202
-
<td>inputTypes</td>
199
+
<td>`inputTypes`</td>
203
200
<td>tuple</td>
204
201
<td>The inputs you intend to bind to the function, such as enum values from a `Enum.KeyCode`.</td>
To remove a mobile button from the screen, call `Class.ContextActionService:UnbindAction()|UnbindAction()` using the actionName string you passed to `Class.ContextActionService:BindAction()|BindAction()`.
227
-
228
-
Use the following code sample to unbind the previously created Interact action:
229
-
230
-
```lua
231
-
-- Unbind action by name
232
-
ContextActionService:UnbindAction("Interact")
233
-
```
234
-
235
-
## Customizing Button UI
236
-
237
-
You can use one of the several functions from `Class.ContextActionService` to customize the on-screen buttons that are created by `Class.ContextActionService:BindAction()|BindAction()`.
221
+
<Alertseverity="info">
222
+
To remove a mobile button from the screen, call `Class.ContextActionService:UnbindAction()|UnbindAction()` using the `actionName` string you passed to `Class.ContextActionService:BindAction()|BindAction()`.
223
+
</Alert>
238
224
239
-
### Button Text
225
+
Once a custom button is added, you can use one of the several functions from `Class.ContextActionService` to customize the on-screen buttons that are created by `Class.ContextActionService:BindAction()|BindAction()`.
240
226
241
-
To change the text label for a mobile button, call `Class.ContextActionService:SetTitle()|SetTitle()` with the actionName string and a title:
227
+
- To change the text label for a mobile button, call `Class.ContextActionService:SetTitle()|SetTitle()` with the `actionName` string and a title string.
228
+
- To use a custom image just like other GUI buttons, call `Class.ContextActionService:SetImage()|SetImage()` method, replacing the example asset ID below with an image of your choice.
229
+
- To set a button's position, call `Class.ContextActionService:SetPosition()|SetPosition()` with a `Datatype.UDim2` position value.
242
230
243
231
```lua
244
232
-- Set button label to "Talk"
245
233
ContextActionService:SetTitle("Interact", "Talk")
246
-
```
247
-
248
-
### Button Image
249
-
250
-
Mobile buttons can use custom images just like other GUI buttons using the `Class.ContextActionService:SetImage()|SetImage()` method.
251
-
252
-
Use the following sample code to set a button image, replacing the asset ID with an image of your choice:
By default, a new button's position appears near the lower right section of the screen. You should carefully consider button placement on mobile devices and keep in mind the positions of thumbs and hands.
262
-
263
-
Use the following sample code to set a button's position with the `Class.ContextActionService:SetPosition()|SetPosition()` method:
When developing for mobile devices you may often want to change what a single button does based on the context. Since screen space on mobile devices is limited, use contextual buttons that perform different actions based on what the character is able to do.
273
243
274
-
For example, you can display an active "Collect" button when the user is standing near a chest of gold:
At another point in the game, you can change the button to "Talk" when the user is standing near an NPC. Instead of adding and removing the existing button, you can simply use `Class.ContextActionService:BindAction()` on the existing Interact action, changing the function and button image.
298
-
299
-
Use the following code sample to set the existing button label to "Talk" and bind it to a function named talkToNPC():
260
+
At another point during gameplay, you can change the button to "Talk" when the user is standing near an NPC. Instead of removing the existing button to place another, you can simply call `Class.ContextActionService:BindAction()|BindAction()` on the existing `"Interact"` action, changing the target function and button title:
In cross-platform experiences, it is necessary to know the user's current device in order to adjust the UI and display correct key binding prompts.
310
-
311
-
For example, if a user approaches a treasure chest and there's an action bound to collecting the gold, you can show mobile users an on-screen "Collect" button and desktop users an on-screen "T" key icon.
312
-
313
-
Keep in mind that a mobile device can also have a [mouse and keyboard](./mouse-and-keyboard.md) or [gamepad](./gamepad.md) plugged in. It is also possible that a desktop has a `Class.UserInputService.TouchEnabled|touchscreen` enabled. It is important to reference the user's preferred input options by displaying input options for the actively used device.
In these cases, you can use `Class.UserInputService` to detect which input devices are enabled. If multiple input devices are enabled, use `Class.UserInputService:GetLastInputType()` to get the user's last used input device to display on the UI.
327
-
328
-
You can use the following `Class.ModuleScript`, placed within `Class.ReplicatedStorage` and renamed to **UserInputModule**, to fetch the user's input type, after which you can adapt the UI layout or context to your experience's specific needs.
269
+
In cross-platform experiences, it's important to reference the user's preferred input options by displaying input options for the actively used device. For example, a mobile device can have a [mouse and keyboard](./mouse-and-keyboard.md) or [gamepad](./gamepad.md) connected, or it's possible that a desktop has a touchscreen enabled. If multiple input sources are enabled, you can use `Class.UserInputService:GetLastInputType()|GetLastInputType()` to get the user's last used input device.
329
270
330
-
Use the following `Class.ModuleScript`to check for enabled input devices and the last used input device:
271
+
As a foundation, you can use the following `Class.ModuleScript`, placed within `Class.ReplicatedStorage` and renamed to **UserInputModule**, to fetch the user's input type, after which you can adapt the UI layout or context to your experience's specific needs.
Copy file name to clipboardExpand all lines: content/en-us/projects/assets/index.md
+15-15Lines changed: 15 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,20 +5,20 @@ description: An overview of how assets work on the platform.
5
5
6
6
Almost everything in Roblox is represented as a cloud-based asset with a unique corresponding ID. This ID is typically in the form of `rbxassetid://[ID]`, which gets applied to various instances as a property that's appropriate for that particular asset type. For example, `Class.Texture`, `Class.MeshPart`, and `Class.Sound` instances reference image, mesh, and audio assets through their respective `Class.Texture.TextureID|TextureID`, `Class.MeshPart.MeshID|MeshID`, and `Class.Sound.SoundID|SoundID` properties.
7
7
8
-
<table>
9
-
<tbody>
10
-
<tr>
11
-
<td><img src="../../assets/modeling/textures-decals/Texture-Example-Grafitti04.png" alt="A decal asset of a young woman with a button for an eye." width="90%" /></td>
<img src="../../assets/modeling/textures-decals/Texture-Example-Grafitti04.png" alt="A decal asset of a young woman with a button for an eye." width="90%" />
This cloud-based asset system allows you to store assets through Roblox and reuse them across the platform in various contexts, such as in different objects and places, without maintaining local copies as part of each saved Studio experience. You can find millions of project assets in the [Creator Store][CreatorMarketplaceURL], equip avatar assets in the [Marketplace][MarketplaceURL], or you can create your own assets and [import](#asset-management) them directly into Studio through the asset management tools.
24
24
@@ -214,7 +214,7 @@ The content folder's location depends on the user's operating system:
214
214
</tr>
215
215
<tr>
216
216
<td>`GameThumbnail`</td>
217
-
<td>ID for an experience (`Class.DataModel.GameId`); shows the experience's primary [thumbnail](../../production/promotion/thumbnails.md)</td>
217
+
<td>ID for an experience (`Class.DataModel.GameId`); shows the experience's primary [thumbnail](../../production/publishing/thumbnails.md)</td>
Copy file name to clipboardExpand all lines: content/en-us/projects/index.md
+14-14Lines changed: 14 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,20 +24,20 @@ objects are available and how to organize and use them, see
24
24
25
25
In Roblox, assets such as images, meshes, and audio are stored as **cloud-based assets**, so you don't need to bundle local copies into a saved Studio experience. Each asset in the cloud is assigned a unique **asset ID** from which multiple experiences can utilize them. You can create assets directly in Studio, such as models, or import assets like images, audio, and meshes from other tools.
26
26
27
-
<table>
28
-
<tbody>
29
-
<tr>
30
-
<td><img src="../assets/modeling/textures-decals/Texture-Example-Grafitti04.png" alt="A decal asset of a young woman with a button for an eye." width="90%" /></td>
<img src="../assets/modeling/textures-decals/Texture-Example-Grafitti04.png" alt="A decal asset of a young woman with a button for an eye." width="90%" />
By default, assets are private to your experience and you can use an asset in any place by referencing its ID. You can also distribute them to the community in the [Creator Store](https://create.roblox.com/store/), so others can use them as well.
0 commit comments