Worked on restart button. Unsuccessful, left it disabled.

This commit is contained in:
mxssw 2025-09-26 12:21:08 +03:00
parent bad94ab628
commit 6479d850e9
4 changed files with 51 additions and 24 deletions

View File

@ -1,10 +1,13 @@
using _PROJECT.NewHandPresence;
using FishNet;
using FishNet.Discovery;
using FishNet.Managing.Scened;
using FishNet.Object;
using System.Collections;
using System.Collections.Generic;
using System.Net;
using TMPro;
using Unity.XR.CoreUtils;
using UnityEngine;
using UnityEngine.UI;
@ -61,13 +64,37 @@ public class NetworkMenuUI : MonoBehaviour
StartCoroutine(HostAndSearchRoutine());
}
private void OnReload()
{
/*if (!InstanceFinder.IsClient)
{
Debug.LogWarning("Reload can only be called from a client!");
return;
}
//UnityEngine.SceneManagement.Scene currentScene = UnityEngine.SceneManagement.SceneManager.GetActiveScene();
//UnityEngine.SceneManagement.SceneManager.LoadScene(currentScene.name);
// Use the ClientManager.Objects dictionary
foreach (NetworkObject obj in InstanceFinder.ClientManager.Objects.)
{
if (obj.IsOwner) // This ensures it's YOUR local player
{
var xr = obj.GetComponentInChildren<XROrigin>();
if (xr != null)
{
Debug.Log("Found my XR Origin player.");
TutorialController tutorial = xr.GetComponent<TutorialController>();
if (tutorial != null)
{
tutorial._state = TutorialController.TutorialState.Initializing;
}
}
else
{
Debug.Log("My local player is not an XR Origin.");
}
}
}*/
}
private void OnJoinMultiplayer()

View File

@ -8,7 +8,7 @@ namespace _PROJECT.NewHandPresence
{
public class TutorialController : MonoBehaviour
{
private enum State
public enum TutorialState
{
Initializing,
Turn,
@ -34,7 +34,7 @@ namespace _PROJECT.NewHandPresence
private SmartHandPresence _leftSmartHandPresence;
private SmartHandPresence _rightSmartHandPresence;
private State _state = State.Initializing;
public TutorialState _state = TutorialState.Initializing;
private Camera _camera;
@ -45,12 +45,12 @@ namespace _PROJECT.NewHandPresence
private void Update()
{
if (_state == State.Initializing)
if (_state == TutorialState.Initializing)
{
TryInitialize();
}
if (_state == State.WaitForGrip)
if (_state == TutorialState.WaitForGrip)
{
TryFindXRGrabInteractable();
}
@ -76,12 +76,12 @@ namespace _PROJECT.NewHandPresence
UpdateState(_state.Next());
}
private void UpdateState(State newState)
private void UpdateState(TutorialState newState)
{
_state = newState;
Debug.Log($"Tutorial state: {_state}");
if (_state == State.Initializing) return;
if (_state == TutorialState.Initializing) return;
SetHandsVisibility(true);
_rightHintController.HideHint();
@ -89,26 +89,26 @@ namespace _PROJECT.NewHandPresence
switch (_state)
{
case State.Initializing:
case TutorialState.Initializing:
break;
case State.Turn:
case TutorialState.Turn:
ShowTurnHint();
break;
case State.Move:
case TutorialState.Move:
ShowLocomotionHint();
break;
case State.Teleport:
case TutorialState.Teleport:
ShowTeleportHint();
break;
case State.WaitForGrip:
case TutorialState.WaitForGrip:
SetHandsVisibility(true);
break;
case State.Grip:
case TutorialState.Grip:
SetHandsVisibility(false);
CreateBillboard(_grabInteractable.gameObject, "Grab me!");
ShowGripHint();
break;
case State.Done:
case TutorialState.Done:
SetHandsVisibility(true);
DestroyBillboard();
break;
@ -215,28 +215,28 @@ namespace _PROJECT.NewHandPresence
private void OnGripPerformed(SelectEnterEventArgs arg0)
{
if (_state != State.Grip) return;
if (_state != TutorialState.Grip) return;
Debug.Log("Grip performed");
UpdateState(_state.Next());
}
private void OnTeleportPerformed(LocomotionSystem obj)
{
if (_state != State.Teleport) return;
if (_state != TutorialState.Teleport) return;
Debug.Log("Teleport performed");
UpdateState(_state.Next());
}
private void OnMovePerformed(InputAction.CallbackContext obj)
{
if (_state != State.Move) return;
if (_state != TutorialState.Move) return;
Debug.Log("Move performed");
UpdateState(_state.Next());
}
private void OnTurnPerformed(InputAction.CallbackContext obj)
{
if (_state != State.Turn) return;
if (_state != TutorialState.Turn) return;
Debug.Log("Turn performed");
UpdateState(_state.Next());
}

Binary file not shown.

BIN
ProjectSettings/ProjectSettings.asset (Stored with Git LFS)

Binary file not shown.