crosshair wip
This commit is contained in:
1 parent
19f26c7ca9
commit
7c6c6902c5
35 files changed
+1331
-1688
No files matched your search
@@ -0,0 +1,49 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
using System.IO;
|
||||
|
||||
public class MenuUI : MonoBehaviour {
|
||||
UIDocument uiDocument;
|
||||
VisualElement tracks;
|
||||
|
||||
Button exit;
|
||||
|
||||
void OnEnable() {
|
||||
uiDocument = GetComponent<UIDocument>();
|
||||
}
|
||||
|
||||
public void AddTracks() {
|
||||
SetupExit();
|
||||
|
||||
tracks = uiDocument.rootVisualElement.Q<VisualElement>("tracks");
|
||||
tracks.Clear();
|
||||
|
||||
for (int i = 0; i < SceneManager.sceneCountInBuildSettings; ++i) {
|
||||
int j = i; // top kek
|
||||
Scene scene = SceneManager.GetSceneByBuildIndex(i);
|
||||
string scenePath = SceneUtility.GetScenePathByBuildIndex(i);
|
||||
string sceneName = Path.GetFileNameWithoutExtension(scenePath);
|
||||
Button button = new Button { text = sceneName };
|
||||
button.clicked += () => LoadScene(j);
|
||||
tracks.Add(button);
|
||||
}
|
||||
}
|
||||
|
||||
void LoadScene(int i) {
|
||||
Debug.Log($"Loading scene {i}");
|
||||
SceneManager.LoadScene(i);
|
||||
}
|
||||
|
||||
void SetupExit() {
|
||||
exit = uiDocument.rootVisualElement.Q<Button>("exit");
|
||||
exit.clicked += Exit;
|
||||
}
|
||||
|
||||
void Exit() {
|
||||
Debug.Log("Quitting");
|
||||
Application.Quit();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user