Finished with attributes
This commit is contained in:
8 files changed
+79
-18
No files matched your search
@@ -1,9 +1,9 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class BouncyPanel : MonoBehaviour {
|
||||
[SerializeField] private float frequency = 8f;
|
||||
[SerializeField] private float minSize = 1f;
|
||||
[SerializeField] private float maxSize = 1.1f;
|
||||
public float frequency = 8f;
|
||||
public float minSize = 1f;
|
||||
public float maxSize = 1.1f;
|
||||
|
||||
void Update() {
|
||||
float newsize = (Mathf.Sin(Time.time * frequency) + 1f) / 2f;
|
||||
|
||||
@@ -3,10 +3,10 @@ using UnityEngine;
|
||||
|
||||
[RequireComponent(typeof(TextMeshProUGUI))]
|
||||
public class BouncyText : MonoBehaviour {
|
||||
[SerializeField] private float frequency = 2f;
|
||||
[SerializeField] private float minSize = 10f;
|
||||
[SerializeField] private float maxSize = 12f;
|
||||
[SerializeField] private bool add;
|
||||
public float frequency = 2f;
|
||||
public float minSize = 10f;
|
||||
public float maxSize = 12f;
|
||||
public bool add;
|
||||
private TextMeshProUGUI text;
|
||||
private float startSize = 0;
|
||||
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
using System;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using TMPro;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class MenuScript : MonoBehaviour {
|
||||
public class MainMenu : MonoBehaviour {
|
||||
[SerializeField] private Button closeButton;
|
||||
[SerializeField] private TMP_Text updateText;
|
||||
[SerializeField] private Button updateButton;
|
||||
@@ -26,10 +29,8 @@ public class MenuScript : MonoBehaviour {
|
||||
updateText.text = "Latest: Loading...";
|
||||
}
|
||||
}
|
||||
if (PresistentData.randomSplashes != null && PresistentData.randomSplashes.Count != 0) {
|
||||
splashText.text = PresistentData.randomSplashes[Random.Range(0, PresistentData.randomSplashes.Count)]["content"].ToString();
|
||||
}
|
||||
copyrightText.text = $"\\u00A9 {System.DateTime.Now.Year} Lncvrt. All rights reserved.";
|
||||
if (PresistentData.randomSplashes != null && PresistentData.randomSplashes.Count != 0) DoSplashText(splashText, PresistentData.randomSplashes);
|
||||
copyrightText.text = $"\\u00A9 {DateTime.Now.Year} Lncvrt. All rights reserved.";
|
||||
|
||||
if (!Application.isMobilePlatform && !Application.isEditor) {
|
||||
closeButton.gameObject.SetActive(true);
|
||||
@@ -60,4 +61,28 @@ public class MenuScript : MonoBehaviour {
|
||||
void Update() {
|
||||
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>();
|
||||
text.text = splash.Content;
|
||||
|
||||
var scale = text.transform.localScale;
|
||||
scale.y = splash.Attributes.Flip ? -1 : 1;
|
||||
scale.x = (splash.Attributes.Flip == splash.Attributes.Reverse) ? 1 : -1;
|
||||
text.transform.localScale = scale;
|
||||
|
||||
if (splash.Attributes.BounceSpeed != -1) text.GetComponent<BouncyText>().frequency = splash.Attributes.BounceSpeed;
|
||||
|
||||
if (splash.Attributes.Color != null) {
|
||||
if (splash.Attributes.Color == "rainbow" && splash.Attributes.RainbowSpeed != -1) {
|
||||
text.color = Color.white;
|
||||
var rainbowText = text.AddComponent<RainbowText>();
|
||||
rainbowText.frequency = splash.Attributes.RainbowSpeed;
|
||||
} else if (splash.Attributes.Color.Length == 6) {
|
||||
UnityEngine.ColorUtility.TryParseHtmlString("#" + splash.Attributes.Color, out Color splashColor);
|
||||
text.color = splashColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -53,10 +53,8 @@ public class PresistentData : MonoBehaviour {
|
||||
if (
|
||||
SceneManager.GetActiveScene().name == "MainMenu" &&
|
||||
randomSplashes != null &&
|
||||
GameObject.Find("Canvas/SplashText").TryGetComponent<TextMeshProUGUI>(out var text) &&
|
||||
GameObject.Find("Canvas/SplashText").TryGetComponent<TextMeshProUGUI>(out var splashText) &&
|
||||
randomSplashes.Count != 0
|
||||
) {
|
||||
text.text = randomSplashes[Random.Range(0, randomSplashes.Count)]["content"].ToString();
|
||||
}
|
||||
) MainMenu.DoSplashText(splashText, randomSplashes);
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class RainbowImage : MonoBehaviour {
|
||||
[SerializeField] private float frequency = 1f;
|
||||
public float frequency = 1f;
|
||||
private Image targetImage;
|
||||
|
||||
void Awake() {
|
||||
|
||||
@@ -2,7 +2,7 @@ using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
public class RainbowText : MonoBehaviour {
|
||||
[SerializeField] private float frequency = 1f;
|
||||
public float frequency = 1f;
|
||||
private TMP_Text targetImage;
|
||||
|
||||
void Awake() {
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
using Newtonsoft.Json;
|
||||
using UnityEngine.Scripting;
|
||||
|
||||
[Preserve]
|
||||
public class SplashEntry {
|
||||
[Preserve]
|
||||
[JsonProperty("content")]
|
||||
public string Content { get; set; }
|
||||
|
||||
[Preserve]
|
||||
[JsonProperty("attributes")]
|
||||
public SplashAttributes Attributes { get; set; } = new SplashAttributes();
|
||||
}
|
||||
|
||||
[Preserve]
|
||||
public class SplashAttributes {
|
||||
[Preserve]
|
||||
[JsonProperty("flip")]
|
||||
public bool Flip { get; set; } = false;
|
||||
|
||||
[Preserve]
|
||||
[JsonProperty("reverse")]
|
||||
public bool Reverse { get; set; } = false;
|
||||
|
||||
[Preserve]
|
||||
[JsonProperty("bounceSpeed")]
|
||||
public int BounceSpeed { get; set; } = -1;
|
||||
|
||||
[Preserve]
|
||||
[JsonProperty("color")]
|
||||
public string Color { get; set; } = null;
|
||||
|
||||
[Preserve]
|
||||
[JsonProperty("rainbowSpeed")]
|
||||
public int RainbowSpeed { get; set; } = -1;
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 89f3f9d4ebca1409c9b51be881a1864b
|
||||
Reference in new issue
Block a user