suta-togamennwakarann
This commit is contained in:
55
Assets/_Scripts/FadeOut.cs
Normal file
55
Assets/_Scripts/FadeOut.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
// アタッチしたSprite Rendererの色を操作してフェードアウトさせるスクリプト
|
||||
[RequireComponent(typeof(SpriteRenderer))]
|
||||
public class FadeOutSprite : MonoBehaviour
|
||||
{
|
||||
private SpriteRenderer spriteRenderer;
|
||||
public float fadeDuration = 1.0f; // 消えるまでの時間(秒)
|
||||
public float startDelay = 0.5f; // 表示してからフェードを開始するまでの待ち時間(秒)
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
spriteRenderer = GetComponent<SpriteRenderer>();
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
// オブジェクトが有効になったときにフェードアニメーションを開始
|
||||
StartCoroutine(FadeOutCoroutine());
|
||||
}
|
||||
|
||||
private IEnumerator FadeOutCoroutine()
|
||||
{
|
||||
// 1. 最初は完全に表示
|
||||
SetAlpha(1f);
|
||||
|
||||
// 2. 指定時間待機(画像がはっきり見える時間)
|
||||
yield return new WaitForSeconds(startDelay);
|
||||
|
||||
// 3. アルファ値を徐々に減らすフェードアウト
|
||||
float timer = 0f;
|
||||
Color initialColor = spriteRenderer.color;
|
||||
|
||||
while (timer < fadeDuration)
|
||||
{
|
||||
timer += Time.deltaTime;
|
||||
// 経過時間に基づいてアルファ値を計算(1 -> 0)
|
||||
float alpha = Mathf.Lerp(1f, 0f, timer / fadeDuration);
|
||||
SetAlpha(alpha);
|
||||
yield return null; // 次のフレームまで待機
|
||||
}
|
||||
|
||||
// 4. 完全に消えたら自身を破棄(再利用しない場合)
|
||||
SetAlpha(0f);
|
||||
Destroy(gameObject);
|
||||
}
|
||||
|
||||
private void SetAlpha(float alpha)
|
||||
{
|
||||
Color current = spriteRenderer.color;
|
||||
current.a = alpha; // Alpha値を更新
|
||||
spriteRenderer.color = current;
|
||||
}
|
||||
}
|
||||
2
Assets/_Scripts/FadeOut.cs.meta
Normal file
2
Assets/_Scripts/FadeOut.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d1dad518e6deb304387fd1c1435a67b2
|
||||
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("========================================================");
|
||||
}
|
||||
}
|
||||
2
Assets/_Scripts/NewMonoBehaviourScript.cs.meta
Normal file
2
Assets/_Scripts/NewMonoBehaviourScript.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bca5237dce7df3543ba5a9c686d545d6
|
||||
@@ -43,6 +43,10 @@ public class PlayerStatusManager : MonoBehaviour
|
||||
private float defenseBuffTimer = 0f;
|
||||
private bool isCodingMode = false;
|
||||
|
||||
public GameObject successEffectPrefab;
|
||||
// エフェクトを出す位置(合体したブロックの少し上など)
|
||||
public Transform effectSpawnPoint;
|
||||
|
||||
private List<Animator> pausedAnimators = new List<Animator>();
|
||||
private List<NavMeshAgent> pausedAgents = new List<NavMeshAgent>();
|
||||
|
||||
@@ -178,6 +182,7 @@ public class PlayerStatusManager : MonoBehaviour
|
||||
|
||||
public void ApplyBuffsAndResume(string buff1, string buff2)
|
||||
{
|
||||
Instantiate(successEffectPrefab, effectSpawnPoint.position, effectSpawnPoint.rotation);
|
||||
ActivateBuffByName(buff1);
|
||||
ActivateBuffByName(buff2);
|
||||
ResumeWorldState(consumeGauge: true);
|
||||
|
||||
45
Assets/_Scripts/TitleManager.cs
Normal file
45
Assets/_Scripts/TitleManager.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class SimpleTitleManager : MonoBehaviour
|
||||
{
|
||||
[Header("UI Buttons")]
|
||||
[SerializeField] private Button startButton;
|
||||
[SerializeField] private Button exitButton;
|
||||
|
||||
[Header("Scene Settings")]
|
||||
[SerializeField] private string mainGameSceneName = "MainGameScene";
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
// テンプレートの手でボタンを押した時に実行される処理
|
||||
startButton.onClick.AddListener(OnStartButtonClicked);
|
||||
exitButton.onClick.AddListener(OnExitButtonClicked);
|
||||
}
|
||||
|
||||
private void OnStartButtonClicked()
|
||||
{
|
||||
startButton.interactable = false; // 二重押し防止
|
||||
StartCoroutine(LoadSceneRoutine());
|
||||
}
|
||||
|
||||
private void OnExitButtonClicked()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
UnityEditor.EditorApplication.isPlaying = false;
|
||||
#else
|
||||
Application.Quit();
|
||||
#endif
|
||||
}
|
||||
|
||||
private IEnumerator LoadSceneRoutine()
|
||||
{
|
||||
AsyncOperation asyncLoad = SceneManager.LoadSceneAsync(mainGameSceneName);
|
||||
while (!asyncLoad.isDone)
|
||||
{
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/_Scripts/TitleManager.cs.meta
Normal file
2
Assets/_Scripts/TitleManager.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 63f333cd2936fbf439d4433a50178080
|
||||
92
Assets/_Scripts/VRLaserPointer.cs
Normal file
92
Assets/_Scripts/VRLaserPointer.cs
Normal file
@@ -0,0 +1,92 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace VRTitle.Input
|
||||
{
|
||||
/// <summary>
|
||||
/// VRコントローラーからのポインター入力とUI操作を仲介するコンポーネント
|
||||
/// </summary>
|
||||
[RequireComponent(typeof(LineRenderer))]
|
||||
public class VRLaserPointer : MonoBehaviour
|
||||
{
|
||||
[Header("Ray Settings")]
|
||||
[SerializeField] private float maxDistance = 10f;
|
||||
[SerializeField] private LayerMask uiLayerMask = ~0;
|
||||
|
||||
[Header("Visual")]
|
||||
[SerializeField] private LineRenderer lineRenderer;
|
||||
|
||||
private GameObject currentHoveredObject;
|
||||
|
||||
private void Reset()
|
||||
{
|
||||
lineRenderer = GetComponent<LineRenderer>();
|
||||
lineRenderer.positionCount = 2;
|
||||
lineRenderer.startWidth = 0.005f;
|
||||
lineRenderer.endWidth = 0.001f;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
ProcessPointer();
|
||||
}
|
||||
|
||||
private void ProcessPointer()
|
||||
{
|
||||
Ray ray = new Ray(transform.position, transform.forward);
|
||||
PointerEventData pointerData = new PointerEventData(EventSystem.current)
|
||||
{
|
||||
position = new Vector2(Screen.width / 2f, Screen.height / 2f)
|
||||
};
|
||||
|
||||
List<RaycastResult> results = new List<RaycastResult>();
|
||||
EventSystem.current?.RaycastAll(pointerData, results);
|
||||
|
||||
Vector3 targetPosition = transform.position + transform.forward * maxDistance;
|
||||
|
||||
if (results.Count > 0)
|
||||
{
|
||||
RaycastResult hit = results[0];
|
||||
targetPosition = hit.worldPosition;
|
||||
UpdateHoverState(hit.gameObject, pointerData);
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateHoverState(null, pointerData);
|
||||
}
|
||||
|
||||
// ポインター描画の更新
|
||||
lineRenderer.SetPosition(0, transform.position);
|
||||
lineRenderer.SetPosition(1, targetPosition);
|
||||
}
|
||||
|
||||
private void UpdateHoverState(GameObject newHover, PointerEventData pointerData)
|
||||
{
|
||||
if (currentHoveredObject == newHover) return;
|
||||
|
||||
if (currentHoveredObject != null)
|
||||
{
|
||||
ExecuteEvents.Execute(currentHoveredObject, pointerData, ExecuteEvents.pointerExitHandler);
|
||||
}
|
||||
|
||||
currentHoveredObject = newHover;
|
||||
|
||||
if (currentHoveredObject != null)
|
||||
{
|
||||
ExecuteEvents.Execute(currentHoveredObject, pointerData, ExecuteEvents.pointerEnterHandler);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// トリガーボタンが押された時に呼び出す(Input System側から呼び出し可能)
|
||||
/// </summary>
|
||||
public void OnPrimaryTriggerDown()
|
||||
{
|
||||
if (currentHoveredObject == null) return;
|
||||
|
||||
PointerEventData pointerData = new PointerEventData(EventSystem.current);
|
||||
ExecuteEvents.Execute(currentHoveredObject, pointerData, ExecuteEvents.pointerClickHandler);
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/_Scripts/VRLaserPointer.cs.meta
Normal file
2
Assets/_Scripts/VRLaserPointer.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6159a60476d605c4494622c0790e9b02
|
||||
Reference in New Issue
Block a user