/// <summary> /// Creates a CapturyOrigin at world origin. /// </summary> /// <returns></returns> private CapturyOrigin CreateCapturyOrigin() { GameObject go = new GameObject(); go.name = "CapturyOrigin"; CapturyOrigin capturyOrigin = go.AddComponent <CapturyOrigin>(); return(capturyOrigin); }
/// <summary> /// Called when scene has changed/switched. /// </summary> /// <param name="previousScene"></param> /// <param name="currentScene"></param> private void OnActiveSceneChanged(Scene previousScene, Scene currentScene) { capturyOrigin = FindObjectOfType <CapturyOrigin>(); if (capturyOrigin == null) { // create origin at world origin of none exists capturyOrigin = CreateCapturyOrigin(); } CapturyOriginChanged(capturyOrigin); networkPlugin.offsetToWorld = capturyOrigin.OffsetToWorldOrigin; }
// Use this for initialization void Start() { networkPlugin = GetComponent <CapturyNetworkPlugin>(); // find CapturyOrigin to define spawn position of avatars capturyOrigin = FindObjectOfType <CapturyOrigin>(); if (capturyOrigin == null) { // create origin at world origin if none exists capturyOrigin = CreateCapturyOrigin(); } CapturyOriginChanged(capturyOrigin); // register for scene change events SceneManager.activeSceneChanged += OnActiveSceneChanged; }