Skip to main content

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.

OpenPanel

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.

  1. In Project tab, right-click and select Inworld Setting Panel

UIE01

  1. Double click UI Settings in the setting panel. It will navigate to the Unity's UI Element building tool.

UIElement

  1. 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 the Inspector (on the right). In this example, we named it WorkspaceChooser.

  2. 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 of xml. If you know how to code in xml, then you can modify it directly.

UIE02

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.

EditorStates

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,

  1. It is the default state for runtime
  2. 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.

FSM

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.