Samples
Vikja Module package includes samples that demonstrate the basic features of the Vikja module.
Requirements
- Aukiverse app key and secret.
- Unity project with ConjureKit and Vikja packages.
Import
Import the Demo sample from the package manager.
Open the
Main
scene of the Demo sample.Insert your Aukiverse console app key and secret in
Main.cs
scene of the Demo sample.
_conjureKit = new ConjureKit(ConjureKitConfiguration.Get(), cameraTransform, "insert_app_key_here", "insert_app_secret_here");
Overview
This example demonstrates connecting to a shared session with a specific session id, creating an entity, and sending and receiving Vikja actions on that entity. Run two instances of the Main scene from the sample. This can be two Unity editor instances, two smartphones, or a combination of both. Now you should be able to join the same session on both devices and send custom messages between the two.
The sample will connect to a new session on Start
. You should see the session id and the state printed on the screen. Join the same session on another device using that session id.
Entity actions
When the Spawn button is pressed, the Spawn
method is invoked, which creates an entity and requests a Vikja action on that entity with the name "VIKJA_TEST_ACTION"
_conjureKit.AddEntity(pose, false, entity =>
{
_vikja.RequestAction(entity.Id, "VIKJA_TEST_ACTION", Encoding.ASCII.GetBytes("VIKJA_TEST_ACTION"),
action => { AukiDebug.Log($"Received request action success with {action.Name}"); },
s => AukiDebug.Log($"Received request action error: {s}"));
}, s => AukiDebug.LogDebug($"Received entity add error error: {s}"));
Other participants will get the EntityAction if they are subscribed to the OnEntityAction event on the Vikja object, and the message will be logged to the console;
_vikja = new Vikja(_conjureKit);
// Subscribe to Vikja entity actions.
_vikja.OnEntityAction += action => Debug.Log($"Received action {action.Name} for entity {action.EntityId}");