I noticed that the XR Interaction Toolkit may have an issue with the UI Document from the Unity UI Toolkit. It seems that there may be a bug causing this problem. I’ve found a workaround that might help you. I wrote a simple script that iterates through all the raycasters in the scene and disables any Panel Raycaster scripts attached to them. This is just a workaround, and futher investigation may be needed to determine if this is the actual problem. I hope this helps!
using UnityEngine;
using CesiumForUnity;
using UnityEngine.XR.Interaction.Toolkit;
using UnityEngine.EventSystems;
using UnityEngine.UIElements;
public class AttachTeleportArea : MonoBehaviour
{
void Start()
{
var modules = RaycasterManager.GetRaycasters();
for (int i = 0; i < modules.Count; ++i)
{
var module = modules[i];
var panelRaycaster = module.gameObject.GetComponent<PanelRaycaster>();
if(panelRaycaster != null)
{
panelRaycaster.enabled = false;
}
}
int teleportLayer = InteractionLayerMask.GetMask(new string[] { "Teleport" });
Cesium3DTileset tileset = GetComponent<Cesium3DTileset>();
if (tileset != null)
{
tileset.OnTileGameObjectCreated += go =>
{
var ta = go.AddComponent<TeleportationArea>();
ta.interactionLayers = teleportLayer;
};
}
}
}
Just noticed the problem is back. It appeared to work when I first tested it with this new script, but as I continued to build the app it is back again…
I’m sorry the error is back. I’m not sure how to reproduce the error. Is it still being triggered the same way, i.e. moving too far from the origin? i.e. does it only happen after interacting with UI elements?
When the error appears, could you check if the Panel Raycaster is indeed disabled? In Play Mode, look for the GameObject with the name “EventSystem”, and underneath that look for the GameObject named “CesiumCreditSystemUIPanelSettings” and check that the PanelRaycaster script is indeed disabled.
The script disables this object on Start but maybe there is some other script that reactivates it? Maybe going further by disabling the GameObject would finally fix the issue? i.e.
{
var module = modules[i];
var panelRaycaster = module.gameObject.GetComponent<PanelRaycaster>();
if (panelRaycaster != null)
{
panelRaycaster.enabled = false;
module.gameObject.SetActive(false);
}
}
Thank you, can you please confirm is this is how the new script should look like now?
using UnityEngine;
using CesiumForUnity;
using UnityEngine.XR.Interaction.Toolkit;
using UnityEngine.EventSystems;
using UnityEngine.UIElements;
public class AttachTeleportArea : MonoBehaviour
{
void Start()
{
// Disable all panel raycasters in the scene
PanelRaycaster panelRaycasters = Object.FindObjectsOfType();
foreach (var panelRaycaster in panelRaycasters)
{
panelRaycaster.enabled = false;
panelRaycaster.gameObject.SetActive(false);
}
int teleportLayer = InteractionLayerMask.GetMask(new string[] { "Teleport" });
Cesium3DTileset tileset = GetComponent<Cesium3DTileset>();
if (tileset != null)
{
tileset.OnTileGameObjectCreated += go =>
{
var ta = go.AddComponent<TeleportationArea>();
ta.interactionLayers = teleportLayer;
};
}
}
I was doing more tests, and the script above worked only once. However, I was able to modify it and found a more aggressive workaround using coroutine. I tested it across multiple scenes and it works so far.
using System.Collections;
using UnityEngine;
using CesiumForUnity;
using UnityEngine.XR.Interaction.Toolkit;
using UnityEngine.EventSystems;
using UnityEngine.UIElements;
public class AttachTeleportArea : MonoBehaviour
{
private bool keepChecking = true;
void Start()
{
// Start the coroutine to keep monitoring PanelRaycasters
StartCoroutine(ContinuouslyCheckAndDisableRaycasters());
int teleportLayer = InteractionLayerMask.GetMask(new string[] { "Teleport" });
Cesium3DTileset tileset = GetComponent<Cesium3DTileset>();
if (tileset != null)
{
tileset.OnTileGameObjectCreated += go =>
{
var ta = go.AddComponent<TeleportationArea>();
ta.interactionLayers = teleportLayer;
};
}
}
IEnumerator ContinuouslyCheckAndDisableRaycasters()
{
while (keepChecking)
{
PanelRaycaster[] panelRaycasters = Object.FindObjectsOfType<PanelRaycaster>();
foreach (var panelRaycaster in panelRaycasters)
{
if(panelRaycaster.enabled)
{
panelRaycaster.enabled = false;
}
}
yield return new WaitForSeconds(0.5f); // Check every half second
}
}
private void OnDestroy()
{
keepChecking = false;
}
Does this script work? I keep having the same problem. Seems to have no effect on the operation of the program has been ignored @joseph.kaile@janine
I also have this problem, you must have met there, how to solve it?