|
| 1 | +--- |
| 2 | +title: Props |
| 3 | +--- |
| 4 | + |
| 5 | +import { Callout } from 'fumadocs-ui/components/callout'; |
| 6 | + |
| 7 | +## What Are Props? |
| 8 | + |
| 9 | +Props are interactive objects which can be loaded into a Basis scene and synchronised across a network. |
| 10 | + |
| 11 | +## How to Create a Prop |
| 12 | + |
| 13 | +- Select a game object and add a Basis Prop component to it. |
| 14 | +- Enter an Asset Bundle Name. |
| 15 | +- Optionally, add an Asset Bundle Description. |
| 16 | +- Press the 'Create Prop Bee File' button and wait for this process to complete. |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | +- The results will be opened in a new window automatically as shown below. |
| 21 | + |
| 22 | + |
| 23 | + |
| 24 | +## How to Create a Network Synced Prop |
| 25 | + |
| 26 | +Props can be network synced and generated at runtime. Below is example of how to load a network synced Pickup Interactable cube: |
| 27 | + |
| 28 | +- Add a cube object in the scene hierarchy. |
| 29 | + |
| 30 | + |
| 31 | + |
| 32 | +- Add a Basis Pickup Interactable component. This allows a local player to pick up and move the cube. |
| 33 | + |
| 34 | + |
| 35 | + |
| 36 | +- Add a Basis Object Sync Networking component. This allows the cube to be synced for all players. |
| 37 | + |
| 38 | + |
| 39 | + |
| 40 | +- Add a Basis Prop component, enter an Asset Bundle Name and press the 'Create Prop Bee File' button. The generated .bee files will be used by the Basis Runtime Loader to load the network synced cube into a scene. |
| 41 | + |
| 42 | + |
| 43 | + |
| 44 | +### Spawning the Prop into a Scene Using the Runtime Loader |
| 45 | + |
| 46 | +- Create an empty game object and give it a suitable name. |
| 47 | + |
| 48 | +- Attach the Runtime Loader component to it. |
| 49 | + |
| 50 | +- Enter your generated prop password and .bee url. |
| 51 | + |
| 52 | +- Select Persistent to ensure synced changes persist for late-joining players. |
| 53 | + |
| 54 | + |
| 55 | + |
| 56 | +- In the Unity Editor toolbar, select Basis and click on the Loadable Config Editor. This Basis config editor is used to genertate XML files which Basis can use to spawn props into a scene. |
| 57 | + |
| 58 | + |
| 59 | + |
| 60 | +- Enter 0 for the mode value. The 0 simply means that this is a loadable prop. |
| 61 | + |
| 62 | +- Enter the same generated password and .bee url used previously. |
| 63 | + |
| 64 | +- Select Persist to ensure synced changes persist for late-joining players. |
| 65 | + |
| 66 | +- Click 'Save XML' and enter an appropriate file name to generate an XML file for the network synced pickup cube |
| 67 | + |
| 68 | + |
| 69 | + |
| 70 | +- The generated XML will be located in: *Basis\Basis Server\BasisServerConsole\bin\Debug\net9.0\initialresources* |
| 71 | + |
| 72 | + |
| 73 | + |
| 74 | +- Its output should look something like this: |
| 75 | + |
| 76 | + |
| 77 | + |
| 78 | +### Checking the Server to Confirm the Prop Loads |
| 79 | + |
| 80 | +- You can check if your prop is loaded correctly by the server. To do so, run the *BasisNetworkConsole.exe*, which is located at *Basis\Basis Server\BasisServerConsole\bin\Debug\net9.0*. |
| 81 | + |
| 82 | +- *Note:* |
| 83 | + - You will need to register yourself as an admin for the prop to be able to load. You can do this by entering entering the command */admin add* did:key:\<YOUR-KEY\> or by editing *Basis\Basis Server\BasisServerConsole\bin\Debug\net9.0\config\admins.xml*. |
| 84 | + - You can find your key by opening up the Basis application and selecting your player's UUID in the Admin settings. |
| 85 | + |
| 86 | + |
| 87 | + |
| 88 | +### Setting up the Basis Scene and Testing the Pickup Cube |
| 89 | + |
| 90 | +- Before you can test out the network synced pickup cube, ensure that your scene has a Basis Scene component attached to an empty game object. |
| 91 | + |
| 92 | +- Click 'Create Scene Bee File'. |
| 93 | + |
| 94 | +- Open up the Load Config editor again. |
| 95 | + |
| 96 | +- Enter your generated scene password and .bee url. |
| 97 | + |
| 98 | +- Ensure Persistent is selected so that synced changes persist for late-joining players. |
| 99 | + |
| 100 | + |
| 101 | + |
| 102 | +- Open up the 'Initialization' scene and press play. This initialises the created scene and network objects. The next time when you load the scene through the server while running the basis application, all players will be able to interact with the network synced cube. |
| 103 | + |
| 104 | + |
0 commit comments