Users can make an Object Addressable
to load them into the scene at runtime. Addressable is an asset system Unity uses, which allows the developer to ask for an asset via its address. Once an asset (e.g. a prefab) is marked "addressable", it generates an address that can be called from anywhere. Wherever the asset resides (local or remote), the system will locate it and its dependencies, then return it.
Press Ctrl+G
after clicking on the object in Project
window.
Click on the object, and press Ctrl + G
.
The box for Addressable should be checked if the asset is added into Addressable Assets.
<aside>
⚠️ If the box is not checked after pressing Ctrl + G
, click on something else and then click the object again.
</aside>
The text in the box is its name, which is used to identify which object to load. Each object should have a unique name. By default, the object name for loading is the same as its name in the scene. You can modify the name in the textbox to make sure it is unique.
In general, there are two steps to load an object from Addressable. Here are the steps.
Notice: These are sample code snippets that give you an idea about how to do this. They do not run since there are no actual objects with the corresponding names in the simulation environment.
Want more details?
Create the environment with the names of the object you want to load in assets
env = RCareWorld(assets = ["example_object"])
Initialize the object with its id, name, and set is_in_scene to False
id = 2333
name = "example_object"
is_in_scene = False
example_object = env.create_object(id, name, is_in_scene)
Load the object and specify its position and rotation. It will be loaded to [0,0,0] if no parameters are given. Rotation should be given in euler angle format.
# load without parameter
example_object.load()
# load with parameter
example_object.load(position=[1,1,1], rotation=[30,0,0])