Skip to main content

API Reference

Important Notes

  • In your scripts, use CustomBehaviour instead of MonoBehaviour.
  • Functions that may compromise security, such as file input/output operations, are not permitted.
  • Do not use the Awake() method. Use Start() instead.
  • Pressing Ctrl+Alt+D on the client opens the debugging window.

Synchronization Variables

Synchronization variables are automatically synchronized across all users in the same virtual environment. To utilize these variables, the AsyncObject.cs script must be attached to the corresponding object.

Supported Types

  • SyncString
  • SyncInt
  • SyncFloat
  • SyncBool
  • SyncVector2
  • SyncVector3
  • SyncQuaternion

Initialization

Variables are initialized as follows: new SyncType(this, "uniqueKey"), where SyncType is one of the supported synchronization variable types, and "uniqueKey" is a unique identifier for the variable.

Example

SyncInt syncExample;

void Start()
{
syncExample = new SyncInt(this, "syncExample");
syncExample.val = 50;
}

Additional Properties

Synchronization variables include additional properties that control and track their state:

  • val: The current value of the variable.
  • dirty: Indicates if the variable's value has changed since the last synchronization. You must manually reset it to 'false' after processing the change.
  • restored: A read-only boolean that indicates if the variable was modified before the user entered the virtual world. For example, in a chat system, if messages were sent before a user joined, restored would be true, meaning past messages are available.

Local Variables

Local variables are used to store data that is specific to a single user and is not synchronized across the network. These variables are initialized similarly to synchronization variables but are only available locally on the user's device.

Supported Types

  • LocalInt
  • LocalFloat
  • LocalString
  • LocalBool
  • LocalVector2
  • LocalVector3
  • LocalQuaternion

Initialization

Variables are initialized as follows: new LocalType(this, "uniqueKey"), where LocalType is one of the supported local variable types, and "uniqueKey" is a unique identifier for the variable.

Example

LocalInt localExample;

void Start()
{
localExample = new LocalInt(this, "localExample");
localExample.val = 100;
}

Interaction and Input

  • GetTouchHand(): HandType - Determines which hand (if any) is currently touching the controller.
  • IsViewTouch(): bool - Checks whether the view is currently being touched.
  • GetGrabHand(): HandType - Identifies which hand is currently grabbing.
  • IsViewGrab(): bool - Checks if the view is currently being grabbed.
  • IsSelected(): bool - Determines if the current object is selected.
  • GetPress(button, hand): bool - Checks if a specified button is pressed on a specified hand.
  • GetPressUp(button, hand): bool - Determines if a specified button has been released on a specified hand.
  • GetPressDown(button, hand): bool - Detects when a specified button is initially pressed on a specified hand.
  • GetInputValue(button, hand): float - Retrieves the current input value for a given button and hand.
  • GetMouseButton(button): bool - Checks if a mouse button is currently pressed.
  • GetMouseDown(button): bool - Determines if a mouse button was pressed down this frame.
  • GetMouseUp(button): bool - Identifies if a mouse button was released this frame.
  • Vibration(hand, durationSeconds, frequency, amplitude): bool - Initiates a vibration on the specified hand controller with given parameters.

Camera Functions

  • SetCustomCamera(camera, useTracking): void - Sets a custom camera for rendering, with optional tracking.
  • SetDesktopCamera(camera): void - Configures a specific camera for desktop mode.
  • ScreenCapture(camera, uicamera, size_x, size_y): void - Captures a screenshot using the specified cameras and resolution.
  • ResetCamera(): void - Resets the camera to its default state.

Media Functions

  • LoadModelAsync(itemId): Task<GameObject> - Asynchronously loads a 3D model.
  • LoadAudioAsync(itemId): Task<AudioClip> - Asynchronously loads an audio clip.
  • LoadMotionAsync(itemId, model): Task<RuntimeMediaController> - Asynchronously loads and assigns a motion to a given model.
  • LoadCameraAsync(itemId, cameraObject): Task<RuntimeMediaController> - Asynchronously loads camera animation.
  • SyncExternalMediaAsync(itemId): Task<RuntimeMediaController> - Synchronizes external media for playback.

Voice Functions

  • SetVoiceEnabled(enable): void - Enables or disables voice functionality.
  • GetVoiceEnabled(): bool - Checks if voice functionality is enabled.
  • PlayVoiceAudio(userId, audioString): void - Plays an audio clip from a voice string.
  • SetVoiceSendingStatus(isSending): void - Sets the sending status of voice communication.
  • SetVoiceCallback(userId, callback): void - Sets a callback function for processing voice data.
  • Base64StringToAudioClip(audioString): AudioClip - Converts a base64 string to an AudioClip.
  • AudioClipToBase64String(audioClip): string - Converts an AudioClip to a base64 string.
  • TextToNpcSpeech(npcObject, text): void - Converts text to speech for an NPC.

AI Functions

  • AINpcChatAsync(npc, prompt, description, instruction): Task<AIChatResult> - Initiates an AI-based chat with an NPC.
  • AIStreamAsync(prompt): Task<string> - Processes a prompt through the AI stream.
  • AIStreamLocalAsync(apiKey, prompt): Task<string> - Processes a prompt through the local AI stream using a specific API key.
  • AIVoiceToTextAsync(apiKey, audioString, lang): Task<string> - Converts voice to text using AI and a specific API key.

Google API Functions

  • SpeechToText(audioString, sourceLang, apiKey, callback): void - Converts speech to text using Google's API.
  • TextTranslation(source, sourceLang, targetLang, apiKey, callback): void - Translates text from one language to another using Google's API.
  • TextToSpeech(source, sourceLang, targetLang, voiceName, gender, apiKey, callback): void - Converts text to speech using Google's API.

User Event Functions

  • EventUserJoin(user): void - Function called when a user joins.
  • EventUserLeave(user): void - Function called when a user leaves.

Image Tracking Functions

  • StartImageBasedTracking(avatar): void - Begins tracking based on images for a specified avatar.
  • StopImageBasedTracking(): void - Stops the image-based tracking.

User Functions

  • GetUsers(): User[] - Retrieves all users in the current session.
  • GetUserById(id): User - Finds a user by their ID.
  • GetUserByObject(go): User - Retrieves a user associated with a GameObject.
  • GetOwner(go): User - Identifies the owner of a GameObject.
  • GetPlayer(): User - Retrieves the player's user data.

Object Permission Functions

  • IsOwned(go): bool - Checks if a GameObject is owned.
  • TakeOwnership(go): void - Takes ownership of a GameObject.

ETC Functions

  • GoToWorld(worldId, passwd): void - Transports the player to another world.
  • RetrieveBodyData(go): BodyData - Retrieves body data from a GameObject.
  • EnableOutline(enable, color, lineWidth): void - Enables or disables outline effect on a GameObject.
  • ManualSync(): void - Forces a manual synchronization.
  • PurchaseProduct(productId): void - Initiates the purchase process for a product.
  • GetItemsByExtensions(extensions): List<ItemData> - Retrieves items that match specified file extensions.
  • IsVRModeEnabled(): bool - Checks if VR mode is enabled.
  • GetGlobalBehaviour(): CustomBehaviour - Retrieves the global behaviour script instance.
  • ShowExpandMenu(show): void - Shows or hides the expand menu.
  • LoadBytesAsync(itemId):Task<byte[]> - Asynchronously loads binary data associated with the specified itemId.

User Class

The User class provides a framework for managing and interacting with users within the virtual environment.

Properties

  • Id: string - The unique identifier for the user.
  • BaseObject: GameObject - The base GameObject associated with the user.

Methods

  • GetBodyPartObject(BodyPart bodyPart): GameObject - Returns the GameObject associated with the specified body part.
  • GetBodyPartVelocity(BodyPart bodyPart): Vector3 - Retrieves the velocity of the specified body part.
  • PlayAnimation(AnimationSet animations, int index): void - Plays the specified animation from the animation set.
  • StopAnimation(): void - Stops the currently playing animation.
  • GetAnimationTimeNormalized(): float - Returns the normalized time of the currently playing animation.
  • SetPosition(Vector3 pos): void - Sets the position of the user.
  • SetRotation(Quaternion rot): void - Sets the rotation of the user.
  • BindToGameObject(GameObject go): void - Binds the user to a specific GameObject.
  • IsSpeaking(): bool - Checks if the user is currently speaking.