Files
2024-10-29 17:16:17 +01:00

41 lines
1.3 KiB
C#

using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
//this script provides part of functionallity for the menu bar
public class MenuBar : MonoBehaviour
{
[SerializeField] private GameObject MenuCanvas;
[SerializeField] private GameObject OBJCanvas;
[SerializeField] private GameObject MainCamera;
private void Update()
{
// calc the position of the menubar (offset to the player itself)
Vector3 newPosition = MainCamera.transform.position + MainCamera.transform.forward * 0.7f;
newPosition.y = MainCamera.transform.position.y - 0.45f; // always keep up y-value
// apply the calculated position
MenuCanvas.transform.position = newPosition;
// rotate the menu canvas with the player
MenuCanvas.transform.rotation = Quaternion.Euler(15, MainCamera.transform.rotation.eulerAngles.y, 0);
}
// change menu bar to the object loader, scaler etc. menu (this menu bar part must deactivated)
public void changeToOBJMenu()
{
MenuCanvas.SetActive(false);
OBJCanvas.SetActive(true);
}
// button function binding to call the savescene function
public void SaveScene()
{
GameObject.Find("ObjectSpawner").GetComponent<RoomSaver>().SaveScene();
}
}