Editor extensions

World editing and uploading in Creator Kit are performed using Unity Editor. By writing editor extensions in C#, you can augment this process.

Registering callbacks

You can register callbacks before and after uploading.

By referencing ClusterVR.CreatorKit.Editor.EditorEvents.asmdef from Unity C# code written for the Editor, you can access the WorldUploadEvents class to handle world upload events.

The WorldUploadEvents class provides the following functions:

FunctionDescription
RegisterOnWorldUploadStartRegisters a callback function that is called before the world upload starts. In the callback function, return true if the upload should continue, or false if the upload should be canceled.
RegisterOnWorldUploadEndRegisters a callback function that is called when the world upload succeeds or fails.

The sample code below registers callbacks to log output before and after the world upload.

using ClusterVR.CreatorKit.Editor.EditorEvents;
using UnityEditor;
using UnityEngine;

public static class MyWorldUploadEventHandler
{
    [InitializeOnLoadMethod]
    public static void Initialize()
    {
        WorldUploadEvents.RegisterOnWorldUploadStart(OnWorldUploadStarted);
        WorldUploadEvents.RegisterOnWorldUploadEnd(OnWorldUploadEnded);
    }

    static bool OnWorldUploadStarted(WorldUploadStartEventData data)
    {
        Debug.Log($"World upload started, root object count = {data.Scene.rootCount}");
        return true;
    }
  
    static void OnWorldUploadEnded(WorldUploadEndEventData data)
    {
        Debug.Log($"World upload ended, success={data.Success}");
    }
}