Unity Skyboxes and Scenes

Three questions:

  1. If I create a Needle experience from Unity that has multiple Scenes, how do I switch between those Scenes at runtime?

  2. Can I use the Skybox feature of Unity Camera to set a unique Skybox for each Scene?

  3. If I am using the Multiplayer features of Needle, if I send a bunch of users to a URL so that they are all loaded into the experience, do they all need to be in the same Scene or can they still communicate if they are in different Scenes from one another?

Hi Aaron, here’s some information to address your questions regarding Unity skyboxes and scene handling in a Needle experience:

  1. To switch between multiple scenes at runtime, you generally load and unload scenes using AssetReferences. Needle Engine offers a SceneSwitcher component (see its API in the samples and docs at SceneSwitcher.d.ts.md) that you configure with your scene assets. At runtime you can call methods like switchScene(asset) to load a new scene and remove the current one. This lets you create transitions between scenes, loading only what you need in the Three.js scene graph.

  2. Regarding unique skyboxes, Unity’s Camera component includes a Skybox property, but in a Needle web experience the background is managed by the Three.js scene. When you load a scene via the SceneSwitcher, you can opt to update the Three.js background (or lighting environment) from the loaded scene’s settings. In practice, if you want to have a different skybox per scene, each scene should be set up with its own skybox asset. Then either the SceneSwitcher or a custom Behaviour can assign that skybox to the active Three.js scene. Note that if you share a single camera across scenes, you’ll have to manually update its skybox when switching scenes.

  3. For multiplayer experiences in Needle, the networking is typically tied to a single shared world instance. That means all connected users need to be in the same scene to easily communicate. Although you could theoretically load different scenes locally (for example, to separate non-critical visual elements), for synchronized multiplayer interactions it’s best to have everyone in the same scene. Otherwise you must implement additional code to bridge network state between different loaded scenes.

I hope this helps you advance with your Unity-Needle project. Feel free to ask further questions if you need clarifications or more detailed samples.

1 replies left - Become PRO for more replies.
thread_7EEbmikyguQBDWHSb1lcdsvH
Reply to this post directly if you need further help (bottom right button)

Hi,

Here’s a very quick reply, can help more tomorrow if you have follow-up questions:

  1. checkout the multi-scenes sample (e.g. via menu item Needle Engine/Explore Samples to install and open it). Online it’s available on Multi Scenes (dynamic loading) | Needle Engine
  2. Every scene can have a unique skybox, yes. The multi-scene sample shows that as well using the builtin Sceneswitcher component to switch between them
  3. They can be in different scenes and communicate, yes. Depends on what you want for your experience. You can also use networking to load the same scene for each user (e.g. with the @syncField decorator to annotate a index or string property, you can find some examples for this in the docs and samples as well)