game(scripts): move & stdise. ResetPosition -> MemoriseInitalPosition

This commit is contained in:
Mark Joshwel 2025-02-15 00:10:00 +08:00
parent 8bc9aa4686
commit 3a2aae335c
4 changed files with 27 additions and 50 deletions

View file

@ -1,24 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class ResetPosition : MonoBehaviour
{
private Vector3 initialPosition;
private Quaternion initialRotation;
void Start()
{
// Store initial position and rotation at the start
initialPosition = transform.position;
initialRotation = transform.rotation;
}
public void ResetingPosition()
{
// Reset the XR Rig to the stored position and rotation
transform.position = initialPosition;
transform.rotation = initialRotation;
}
}

View file

@ -0,0 +1,27 @@
/*
* Author: Wai Lam
* Date: 13/2/25
* Description: Memorise the initial position of a game object and reset it when needed
*/
using UnityEngine;
public class MemoriseInitialPosition : MonoBehaviour
{
private Vector3 _initialPosition;
private Quaternion _initialRotation;
private void Start()
{
// Store initial position and rotation at the start
_initialPosition = transform.position;
_initialRotation = transform.rotation;
}
public void ResetPosition()
{
// Reset the XR Rig to the stored position and rotation
transform.position = _initialPosition;
transform.rotation = _initialRotation;
}
}

View file

@ -1,26 +0,0 @@
/*
Author: Wai Lam
Date: 7/2/25
Description: Loading scene from start to game
*/
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class Sceneloader : MonoBehaviour
{
public string sceneName; // Name of the scene to load
public void LoadScene()
{
if (!string.IsNullOrEmpty(sceneName))
{
SceneManager.LoadScene(sceneName);
}
else
{
Debug.LogWarning("Scene name is not assigned!");
}
}
}