Advanced Usage Guides
Instructions for using Unity source project and SDK
The following steps assume that you have a basic understanding of Unity Editor
If you want to add your own custom resources or functions to RFUniverse, you can do so by adding them to the RFUniverse open source project.
If you want to add RFUniverse functionality to your own project, you can import the RFUniverse Core SDK
If you encounter missing plugin errors in your project, you can restart the project and use the menu RFUniverse/CheckPlugins to fix them.
Supplementing missing plugins and resources
After opening the RFUniverse project or importing the RFUniverse Core SDK, you need to supplement third-party plugins and resources yourself to enable their functionality:
Please put the plugins in the Plugins directory, import the plugins, and use the menu RFUniverse/CheckPlugins to fix dependencies
Assets directory structure
AddressableAssetsData:The Unity Addressable Assets System fixed directory, which manages resource addresses and resource packaging configurations
Assets:Resource directory, which contains all dynamically loaded resources. If you don’t need to use built-in model and robot resources, you can delete them
Model:Model/texture/material resources
PhysicalMaterials:Physical materials
Prefab:Prefabs, assigned Addressable addresses for resource loading.
Extend: Various expanded Attr modules
Plugins:Expanded plugin directory. Please put OBI, BioIK, and other plugins in this directory
RFUniverse:RFUniverse core functionality resources and scripts.
StreamingAssets:Configuration file save directory
SceneData:Save directory for scene JSON files
TextMesh Pro:UI resources
Scene
RFUniverse/First.unity:The first scene that the published program runs, which receives command-line parameters and then jumps to other scenes
RFUniverse/Empty.unity:Player mode scene
EditMode/Edit.unity:Edit mode scebe
Running sample scenes in the project
The functional examples in the pyrfuniverse/Test directory can be run in both the Release and UnityEditor.
First, run the Empty scene once and then exit, then run a Python script and run the Empty scene in UnityEditor.
Building a Scene
In RFUniverse, objects can be configured into Prefabs according to rules and dynamically loaded through Python interfaces at runtime. Alternatively, a fixed scene can be built in advance to communicate with Python. The choice between the two methods depends on whether you need to run different environments in a published version. In most cases, it is simpler and more efficient to build a scene in advance in the UnityEditor.
Basic Process:
Copy an Empty scene and add your objects.
Alternatively, import RFUniverse/Assets/Prefab/RFUniverse into an existing scene and remove the original MainCamera and Directional Light.
Add the BaseAttr script to the objects that need to communicate, manually assigning a unique ID to each object to ensure no duplicates.
Refer to pyrfuniverse/Test to write Python scripts that read information from objects using their IDs and call object interfaces.
More specific process in Tutorials
For more details and more specific process in building your custom scene, please refer to the following tutorials.
Dynamic Message
In addition to fixed parameter interfaces, AssetManager also supports sending dynamic messages to enable two-way data communication, which is more flexible and convenient.
Python->Unity
C#:
AssetManger.Instance.AddListener(string message, Action<IncomingMessage> action);
Open the listener by passing the message name and the message receiver function. The parameter type passed to the receiver function is
IncomingMessage
Python:
env.SendMessage(self, message: str, *args)
Pass the message name and any number of data to send.
Unity->Python
Python:
env.AddListener(self, message: str, fun)
Open the listener by passing the message name and the message receiver function. The parameter type passed to the receiver function is
IncomingMessage
C#:
AssetManger.Instance.SendMessage(string message, params object[] objects);
Pass the message name and any number of data to send.
Please note that dynamic messages must ensure that the types and order of data read from IncomingMessage in the receiver function are the same as those passed in when sending the message. Otherwise, the program will throw an error.
Please refer to pyrfuniverse/Test/test_custom_message.py for a specific usage example of the dynamic message interface.
Core Classes
Attributes
Attr
is the basic unit of objects in RFUniverse. All objects are derived from BaseAttr
, such as GameObjectAttr
, RigidbodyAttr
, ControllerAttr
, CameraAttr
, etc.
BaseAttr
provides basic object loading, creation, deletion, movement, and other attributes.GameObjectAttr
extends simple visual effect modification for objects.ColliderAttr
extends modification functions for an object’s collider.RigidbodyAttr
extends the rigid body properties of objects.ControllerAttr
extends the operation of robotic arm joints.CameraAttr
extends image capture capabilities for cameras.LightAttr
extends light control functionality.PointCloudAttr
extends point cloud import and rendering functionality.