Inworld Editor
The editor files are located in Assets/Inworld.AI/Editor
. They are mainly used to implement the Inworld Studio Panel
which is displayed below.
UI Elements
The Inworld AI Unity SDK uses UI Elements to paint the panel. Each page contains a Content
panel for the contents and a Bot
panel for the buttons.
Let's take the Content
panel in the Character Choosing Page as an example.
- In
Project
tab, right-click and selectInworld Setting Panel
- Double click
UI Settings
in the setting panel. It will navigate to the Unity's UI Element building tool.
From that UI editor, you can see the components are listed in the
Hierarchy
(on the left). You can reference these components after naming them in theInspector
(on the right). In this example, we named itWorkspaceChooser
.In Unity C# scripts, you can get these components by calling
InworldEditor.Root.Q()
by the name. e.g.,InworldEditor.Root.Q<VisualElement>("WorkspaceChooser")
.
⚠️ Note: The file format is
uxml
, which is a similar version ofxml
. If you know how to code inxml
, then you can modify it directly.
Finite-State Machine
The Inworld Studio Panel
is implemented by a finite-state machine. Each page has its own state, and it is initialized and implemented as below.
1. Editor Default
This is the default page in editor mode for developers to use the default scenes and characters.
2. Editor Init
This is the page that developers can obtain their studio access tokens. This state is triggered if the user selects Login
in the EditorDefault.
3. Editor Workspace Chooser
This state is triggered when the user token is pasted and the login is clicked in EditorInit, or when you select different Workspaces
in other states. This state will fetch the user token from our server, and then list all the workspaces belonging to it.
4. Editor Scene Chooser
This state is triggered when one of the workspaces has been selected in the EditorWorkspaceChooser, or when different scenes are selected in EditorCharacterChooser. This state will fetch the API key and secret, and the scenes of that workspace. It will then provide a drop-down field for users to choose from.
5. Editor Character Chooser
This state is triggered when a workspace, API key and secret, and scene have been selected. In this state, it will start fetching thumbnails, avatars, and generating character buttons.
6. Editor Playing
This state is triggered under two conditions,
- It is the default state for runtime
- If the editor code has been changed when you modified code related to the InworldEditor
7. Editor Error
An error page is triggered when the default resource is incorrect or the token fails to be received. This triggers a back-off reconnecting system, and, if possible, it will switch to a previous state.
If you would like to create your own customized Inworld Studio Panel
, then it is recommended that you create your own state. To do this, implement OnEnter()
, OnExit()
, OnError()
, and PostUpdate()
as needed.
Please visit InworldEditor for more references.