Make this more proper
This commit is contained in:
2 files changed
+8
-9
No files matched your search
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using TMPro;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
@@ -29,7 +28,8 @@ public class MainMenu : MonoBehaviour {
|
||||
updateText.text = "Latest: Loading...";
|
||||
}
|
||||
}
|
||||
if (PresistentData.randomSplashes != null && PresistentData.randomSplashes.Count != 0) DoSplashText(splashText, PresistentData.randomSplashes);
|
||||
if (PresistentData.randomSplashes != null && PresistentData.randomSplashes.Count != 0)
|
||||
DoSplashText(splashText, PresistentData.randomSplashes[UnityEngine.Random.Range(0, PresistentData.randomSplashes.Count)]);
|
||||
copyrightText.text = $"\\u00A9 {DateTime.Now.Year} Lncvrt. All rights reserved.";
|
||||
|
||||
if (!Application.isMobilePlatform && !Application.isEditor) {
|
||||
@@ -62,9 +62,7 @@ public class MainMenu : MonoBehaviour {
|
||||
if (Keyboard.current.escapeKey.wasPressedThisFrame && !GameObject.Find("ProfilePrefab(Clone)")) closePopup.SetActive(!closePopup.activeSelf);
|
||||
}
|
||||
|
||||
public static void DoSplashText(TMP_Text text, JArray randomSplashes) {
|
||||
var random = randomSplashes[UnityEngine.Random.Range(0, randomSplashes.Count)];
|
||||
var splash = random.ToObject<SplashEntry>();
|
||||
public static void DoSplashText(TMP_Text text, SplashEntry splash) {
|
||||
text.text = splash.Content;
|
||||
|
||||
var scale = text.transform.localScale;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
@@ -9,7 +10,7 @@ public class PresistentData : MonoBehaviour {
|
||||
public static PresistentData Instance;
|
||||
private bool loadingDone = false;
|
||||
public static string latestVersion = null;
|
||||
public static JArray randomSplashes = new();
|
||||
public static List<SplashEntry> randomSplashes = new();
|
||||
|
||||
private async void Awake() {
|
||||
if (Instance != null && Instance != this) {
|
||||
@@ -49,12 +50,12 @@ public class PresistentData : MonoBehaviour {
|
||||
request.SetRequestHeader("ClientVersion", Application.version);
|
||||
request.SetRequestHeader("ClientPlatform", Application.platform.ToString());
|
||||
await request.SendWebRequest();
|
||||
randomSplashes = JArray.Parse(request.downloadHandler.text);
|
||||
randomSplashes = JsonConvert.DeserializeObject<List<SplashEntry>>(request.downloadHandler.text);
|
||||
if (
|
||||
SceneManager.GetActiveScene().name == "MainMenu" &&
|
||||
randomSplashes != null &&
|
||||
GameObject.Find("Canvas/SplashText").TryGetComponent<TextMeshProUGUI>(out var splashText) &&
|
||||
randomSplashes.Count != 0
|
||||
) MainMenu.DoSplashText(splashText, randomSplashes);
|
||||
) MainMenu.DoSplashText(splashText, randomSplashes[Random.Range(0, randomSplashes.Count)]);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user