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;
using FishNet.Discovery; using FishNet.Discovery;
using FishNet.Managing.Scened; using FishNet.Managing.Scened;
using FishNet.Object;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Net; using System.Net;
using TMPro; using TMPro;
using Unity.XR.CoreUtils;
using UnityEngine; using UnityEngine;
using UnityEngine.UI; using UnityEngine.UI;
@ -61,13 +64,37 @@ public class NetworkMenuUI : MonoBehaviour
StartCoroutine(HostAndSearchRoutine()); StartCoroutine(HostAndSearchRoutine());
} }
private void OnReload() 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(); // Use the ClientManager.Objects dictionary
//UnityEngine.SceneManagement.SceneManager.LoadScene(currentScene.name); 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() private void OnJoinMultiplayer()

View File

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

Binary file not shown.

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

Binary file not shown.