suta-togamennwakarann
This commit is contained in:
74
Assets/_Scripts/NewMonoBehaviourScript.cs
Normal file
74
Assets/_Scripts/NewMonoBehaviourScript.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
/// <summary>
|
||||
/// XR UIが反応しない原因を自動判定する超安全な診断スクリプト
|
||||
/// </summary>
|
||||
public class XRUIDiagnoser : MonoBehaviour
|
||||
{
|
||||
private void Start()
|
||||
{
|
||||
Debug.Log("============== 🔍 XR UI 自動診断スタート ==============");
|
||||
|
||||
// 1. EventSystem の重複・存在チェック
|
||||
var eventSystems = FindObjectsByType<EventSystem>(FindObjectsInactive.Include, FindObjectsSortMode.None);
|
||||
if (eventSystems.Length == 0)
|
||||
{
|
||||
Debug.LogError("🚨【原因】シーンに EventSystem が存在しません!");
|
||||
}
|
||||
else if (eventSystems.Length > 1)
|
||||
{
|
||||
Debug.LogError($"🚨【原因】EventSystem がシーンに {eventSystems.Length} 個あります!これが最大の原因になりやすいです。不要な方を削除してください。");
|
||||
foreach (var es in eventSystems) Debug.Log($" ・配置場所: {es.gameObject.name}", es.gameObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
var module = eventSystems[0].GetComponent<BaseInputModule>();
|
||||
Debug.Log($"⭕ EventSystem: OK [{eventSystems[0].name}] | Module: {(module != null ? module.GetType().Name : "なし")}");
|
||||
}
|
||||
|
||||
// 2. Ray Interactor (ビーム発射体) の存在チェック (名前で動的探索するためバージョンエラーになりません)
|
||||
var allComponents = FindObjectsByType<Component>(FindObjectsInactive.Include, FindObjectsSortMode.None);
|
||||
int rayCount = 0;
|
||||
foreach (var c in allComponents)
|
||||
{
|
||||
if (c != null && c.GetType().Name.Contains("RayInteractor"))
|
||||
{
|
||||
rayCount++;
|
||||
bool active = c.gameObject.activeInHierarchy;
|
||||
if (!active)
|
||||
Debug.LogError($"🚨【原因】[{c.gameObject.name}] の RayInteractor オブジェクトが非アクティブ(OFF)になっています!", c.gameObject);
|
||||
else
|
||||
Debug.Log($"⭕ Ray Interactor 発見: [{c.gameObject.name}] ({c.GetType().Name}) | Active: OK");
|
||||
}
|
||||
}
|
||||
|
||||
if (rayCount == 0)
|
||||
{
|
||||
Debug.LogError("🚨【原因】コントローラーの手のオブジェクトに RayInteractor コンポーネントが見つかりません!");
|
||||
}
|
||||
|
||||
// 3. Canvas の設定チェック
|
||||
var canvases = FindObjectsByType<Canvas>(FindObjectsInactive.Exclude, FindObjectsSortMode.None);
|
||||
if (canvases.Length == 0)
|
||||
{
|
||||
Debug.LogError("🚨【原因】アクティブな Canvas がシーン内に存在しません!");
|
||||
}
|
||||
|
||||
foreach (var canvas in canvases)
|
||||
{
|
||||
var raycaster = canvas.GetComponent<GraphicRaycaster>();
|
||||
if (raycaster == null)
|
||||
{
|
||||
Debug.LogError($"🚨【原因】Canvas [{canvas.name}] に Raycaster コンポーネントが付いていません!", canvas.gameObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log($"⭕ Canvas: OK [{canvas.name}] | RenderMode: {canvas.renderMode} | Raycaster: {raycaster.GetType().Name}");
|
||||
}
|
||||
}
|
||||
|
||||
Debug.Log("========================================================");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user