add logs to level3
Some checks failed
Build project / Build for (StandaloneWindows64, 6000.0.37f1) (push) Has been cancelled
Build project / Publish to itch.io (StandaloneLinux64) (push) Has been cancelled
Build project / Publish to itch.io (StandaloneWindows64) (push) Has been cancelled
Build project / Build for (StandaloneLinux64, 6000.0.37f1) (push) Has been cancelled
Build project / Build for (StandaloneWindows64, 6000.0.37f1) (pull_request) Has been cancelled
Build project / Publish to itch.io (StandaloneLinux64) (pull_request) Has been cancelled
Build project / Publish to itch.io (StandaloneWindows64) (pull_request) Has been cancelled
Build project / Build for (StandaloneLinux64, 6000.0.37f1) (pull_request) Has been cancelled
Some checks failed
Build project / Build for (StandaloneWindows64, 6000.0.37f1) (push) Has been cancelled
Build project / Publish to itch.io (StandaloneLinux64) (push) Has been cancelled
Build project / Publish to itch.io (StandaloneWindows64) (push) Has been cancelled
Build project / Build for (StandaloneLinux64, 6000.0.37f1) (push) Has been cancelled
Build project / Build for (StandaloneWindows64, 6000.0.37f1) (pull_request) Has been cancelled
Build project / Publish to itch.io (StandaloneLinux64) (pull_request) Has been cancelled
Build project / Publish to itch.io (StandaloneWindows64) (pull_request) Has been cancelled
Build project / Build for (StandaloneLinux64, 6000.0.37f1) (pull_request) Has been cancelled
This commit is contained in:
parent
c7e6fad050
commit
c5d2c3cf8c
File diff suppressed because it is too large
Load Diff
92
Assets/Scripts/OpenLogHandler.cs
Normal file
92
Assets/Scripts/OpenLogHandler.cs
Normal file
@ -0,0 +1,92 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using TMPro;
|
||||
|
||||
public class OpenLogHandler : MonoBehaviour
|
||||
{
|
||||
public GameObject scrollableTextPanel; // Assign your "ScrollableTextPanel" in the Inspector
|
||||
[SerializeField] private TextMeshProUGUI scrollableText; // Assign your TextMeshProUGUI component in the Inspector
|
||||
[SerializeField] private string logText = "This is the log text that will be displayed in the scrollable panel."; // The text to display
|
||||
|
||||
[SerializeField] private GameObject contentPanel; // Assign your content panel in the Inspector
|
||||
|
||||
[Header("Player Control Locking")]
|
||||
public GameObject[] crosshairs;
|
||||
public MonoBehaviour playerMovementScript;
|
||||
|
||||
private bool isPanelOpen = false;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Input.GetMouseButtonDown(0)) // Left mouse button click
|
||||
{
|
||||
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
||||
RaycastHit hit;
|
||||
if (Physics.Raycast(ray, out hit))
|
||||
{
|
||||
if (hit.transform == transform) // Check if the clicked object is the one this script is attached to
|
||||
{
|
||||
Debug.Log("Clicked on the Log!");
|
||||
ShowPanel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isPanelOpen && Input.GetKeyDown(KeyCode.Escape))
|
||||
{
|
||||
ClosePanel();
|
||||
}
|
||||
}
|
||||
|
||||
void ShowPanel()
|
||||
{
|
||||
if (!scrollableTextPanel.activeSelf)
|
||||
{
|
||||
|
||||
scrollableText.text = logText; // Set the text in the TextMeshProUGUI component
|
||||
// set content to posY 0
|
||||
RectTransform contentRect = contentPanel.GetComponent<RectTransform>();
|
||||
contentRect.position = new Vector3(contentRect.position.x, 0, contentRect.position.z);
|
||||
scrollableTextPanel.SetActive(true);
|
||||
LockPlayerControl();
|
||||
isPanelOpen = true;
|
||||
}
|
||||
}
|
||||
|
||||
void ClosePanel()
|
||||
{
|
||||
scrollableTextPanel.SetActive(false);
|
||||
UnlockPlayerControl();
|
||||
isPanelOpen = false;
|
||||
}
|
||||
|
||||
void LockPlayerControl()
|
||||
{
|
||||
foreach (GameObject crosshair in crosshairs)
|
||||
{
|
||||
if (crosshair != null)
|
||||
crosshair.SetActive(false);
|
||||
}
|
||||
if (playerMovementScript != null)
|
||||
playerMovementScript.enabled = false;
|
||||
|
||||
Time.timeScale = 0f;
|
||||
Cursor.lockState = CursorLockMode.None;
|
||||
Cursor.visible = true;
|
||||
}
|
||||
|
||||
public void UnlockPlayerControl()
|
||||
{
|
||||
foreach (GameObject crosshair in crosshairs)
|
||||
{
|
||||
if (crosshair != null)
|
||||
crosshair.SetActive(true);
|
||||
}
|
||||
if (playerMovementScript != null)
|
||||
playerMovementScript.enabled = true;
|
||||
|
||||
Time.timeScale = 1f;
|
||||
Cursor.lockState = CursorLockMode.Locked;
|
||||
Cursor.visible = false;
|
||||
}
|
||||
}
|
2
Assets/Scripts/OpenLogHandler.cs.meta
Normal file
2
Assets/Scripts/OpenLogHandler.cs.meta
Normal file
@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0951d6b44dbbf8779bd1a0e0ed1b75f8
|
Loading…
Reference in New Issue
Block a user