Add game downloads
This commit is contained in:
14035 files changed
No files matched your search
@@ -0,0 +1,521 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Text.RegularExpressions;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class Account : MonoBehaviour
|
||||
{
|
||||
public GameObject registerPanel;
|
||||
|
||||
public Button registerPanelLoginBtn;
|
||||
|
||||
public GameObject loginPanel;
|
||||
|
||||
public Button loginPanelRegisterBtn;
|
||||
|
||||
public GameObject accountPanel;
|
||||
|
||||
public Button backButton;
|
||||
|
||||
public Button accountPanelSyncButton;
|
||||
|
||||
public Button accountPanelLogoutButton;
|
||||
|
||||
public TMP_InputField registerPanelUsernameForm;
|
||||
|
||||
public TMP_InputField registerPanelEmailForm;
|
||||
|
||||
public TMP_InputField registerPanelEmailConfirmForm;
|
||||
|
||||
public TMP_InputField registerPanelPasswordForm;
|
||||
|
||||
public TMP_InputField registerPanelPasswordConfirmForm;
|
||||
|
||||
public TMP_InputField loginPanelUsernameForm;
|
||||
|
||||
public TMP_InputField loginPanelPasswordForm;
|
||||
|
||||
public TMP_Text registerPanelStatusText;
|
||||
|
||||
public TMP_Text loginPanelStatusText;
|
||||
|
||||
public TMP_Text accountPanelStatusText;
|
||||
|
||||
public GameObject changeUsernamePanel;
|
||||
|
||||
public TMP_Text changeUsernamePanelStatusText;
|
||||
|
||||
public Button submitButton;
|
||||
|
||||
public Button changeUsernameButton;
|
||||
|
||||
public Button changePasswordButton;
|
||||
|
||||
public GameObject changePasswordPanel;
|
||||
|
||||
public TMP_Text changePasswordStatusText;
|
||||
|
||||
public TMP_Text changeUsernameStatusText;
|
||||
|
||||
public TMP_InputField changeUsernameCurrentForm;
|
||||
|
||||
public TMP_InputField changeUsernameNewForm;
|
||||
|
||||
public TMP_InputField changeUsernamePasswordForm;
|
||||
|
||||
public TMP_InputField changePasswordCurrentUsernameForm;
|
||||
|
||||
public TMP_InputField changePasswordCurrentForm;
|
||||
|
||||
public TMP_InputField changePasswordNewForm;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (PlayerPrefs.HasKey("gameSession") && PlayerPrefs.HasKey("userID"))
|
||||
{
|
||||
SwitchScene(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
SwitchScene(1);
|
||||
}
|
||||
backButton.onClick.AddListener(BackToMenu);
|
||||
registerPanelLoginBtn.onClick.AddListener(delegate
|
||||
{
|
||||
SwitchScene(2);
|
||||
});
|
||||
submitButton.onClick.AddListener(ButtonSubmit);
|
||||
loginPanelRegisterBtn.onClick.AddListener(delegate
|
||||
{
|
||||
SwitchScene(1);
|
||||
});
|
||||
accountPanelSyncButton.onClick.AddListener(StartSyncAccount);
|
||||
accountPanelLogoutButton.onClick.AddListener(LogoutAccount);
|
||||
changeUsernameButton.onClick.AddListener(delegate
|
||||
{
|
||||
SwitchScene(3);
|
||||
});
|
||||
changePasswordButton.onClick.AddListener(delegate
|
||||
{
|
||||
SwitchScene(4);
|
||||
});
|
||||
}
|
||||
|
||||
private void BackToMenu()
|
||||
{
|
||||
if (GetCurrentScene() == 3 || GetCurrentScene() == 4)
|
||||
{
|
||||
SwitchScene(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
SceneManager.LoadScene("Menu");
|
||||
}
|
||||
}
|
||||
|
||||
private int GetCurrentScene()
|
||||
{
|
||||
if (accountPanel.activeSelf)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (registerPanel.activeSelf)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (loginPanel.activeSelf)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
if (changeUsernamePanel.activeSelf)
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
if (changePasswordPanel.activeSelf)
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
private void ButtonSubmit()
|
||||
{
|
||||
if (GetCurrentScene() == 1)
|
||||
{
|
||||
StartCoroutine(SubmitRegister());
|
||||
}
|
||||
else if (GetCurrentScene() == 2)
|
||||
{
|
||||
StartCoroutine(SubmitLogin());
|
||||
}
|
||||
else if (GetCurrentScene() == 3)
|
||||
{
|
||||
StartCoroutine(ChangeUsername());
|
||||
}
|
||||
else if (GetCurrentScene() == 4)
|
||||
{
|
||||
StartCoroutine(ChangePassword());
|
||||
}
|
||||
}
|
||||
|
||||
private void SwitchScene(int scene)
|
||||
{
|
||||
ClearForms();
|
||||
backButton.transform.localPosition = new Vector3(0f, -165f, 0f);
|
||||
backButton.GetComponent<RectTransform>().sizeDelta = new Vector2(90f, 30f);
|
||||
submitButton.transform.localPosition = new Vector3(110f, -165f, 0f);
|
||||
submitButton.gameObject.SetActive(value: true);
|
||||
accountPanel.SetActive(value: false);
|
||||
registerPanel.SetActive(value: false);
|
||||
loginPanel.SetActive(value: false);
|
||||
changeUsernamePanel.SetActive(value: false);
|
||||
changePasswordPanel.SetActive(value: false);
|
||||
registerPanelStatusText.text = "";
|
||||
loginPanelStatusText.text = "";
|
||||
accountPanelStatusText.text = "";
|
||||
changeUsernamePanelStatusText.text = "";
|
||||
changePasswordStatusText.text = "";
|
||||
changeUsernameStatusText.text = "";
|
||||
registerPanelStatusText.color = Color.white;
|
||||
loginPanelStatusText.color = Color.white;
|
||||
accountPanelStatusText.color = Color.white;
|
||||
changeUsernamePanelStatusText.color = Color.white;
|
||||
changePasswordStatusText.color = Color.white;
|
||||
changeUsernameStatusText.color = Color.white;
|
||||
accountPanelSyncButton.interactable = true;
|
||||
switch (scene)
|
||||
{
|
||||
case 0:
|
||||
accountPanel.SetActive(value: true);
|
||||
submitButton.gameObject.SetActive(value: false);
|
||||
backButton.transform.localPosition = new Vector3(-60f, -165f, 0f);
|
||||
backButton.GetComponent<RectTransform>().sizeDelta = new Vector2(110f, 30f);
|
||||
break;
|
||||
case 1:
|
||||
registerPanel.SetActive(value: true);
|
||||
break;
|
||||
case 2:
|
||||
loginPanel.SetActive(value: true);
|
||||
break;
|
||||
case 3:
|
||||
changeUsernamePanel.SetActive(value: true);
|
||||
backButton.transform.localPosition = new Vector3(-60f, -165f, 0f);
|
||||
backButton.GetComponent<RectTransform>().sizeDelta = new Vector2(110f, 30f);
|
||||
submitButton.transform.localPosition = new Vector3(60f, -165f, 0f);
|
||||
break;
|
||||
case 4:
|
||||
changePasswordPanel.SetActive(value: true);
|
||||
backButton.transform.localPosition = new Vector3(-60f, -165f, 0f);
|
||||
backButton.GetComponent<RectTransform>().sizeDelta = new Vector2(110f, 30f);
|
||||
submitButton.transform.localPosition = new Vector3(60f, -165f, 0f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator SubmitRegister()
|
||||
{
|
||||
if (!registerPanelEmailForm.text.Trim().Equals(registerPanelEmailConfirmForm.text.Trim(), StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
UpdateStatusText(registerPanelStatusText, "Email doesn't match", Color.red);
|
||||
yield break;
|
||||
}
|
||||
if (!registerPanelPasswordForm.text.Trim().Equals(registerPanelPasswordConfirmForm.text.Trim(), StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
UpdateStatusText(registerPanelStatusText, "Password doesn't match", Color.red);
|
||||
yield break;
|
||||
}
|
||||
if (!Regex.IsMatch(registerPanelUsernameForm.text, "^[a-zA-Z0-9]{3,16}$"))
|
||||
{
|
||||
UpdateStatusText(registerPanelStatusText, "Username must be 3-16 characters, letters and numbers only", Color.red);
|
||||
yield break;
|
||||
}
|
||||
WWWForm wWWForm = new WWWForm();
|
||||
wWWForm.AddField("username", registerPanelUsernameForm.text);
|
||||
wWWForm.AddField("email", registerPanelEmailForm.text);
|
||||
wWWForm.AddField("password", registerPanelPasswordForm.text);
|
||||
using UnityWebRequest request = UnityWebRequest.Post("https://berrydash.xytriza.com/database/registerAccount.php", wWWForm);
|
||||
request.SetRequestHeader("User-Agent", "BerryDashClient");
|
||||
request.SetRequestHeader("ClientVersion", PlayerPrefs.GetFloat("clientVersion").ToString());
|
||||
yield return request.SendWebRequest();
|
||||
if (request.result != UnityWebRequest.Result.Success)
|
||||
{
|
||||
Debug.LogError("HTTP Error: " + request.error);
|
||||
UpdateStatusText(registerPanelStatusText, "Failed to make HTTP request", Color.red);
|
||||
yield break;
|
||||
}
|
||||
string text = request.downloadHandler.text;
|
||||
Debug.Log(text);
|
||||
switch (text)
|
||||
{
|
||||
case "1":
|
||||
SwitchScene(2);
|
||||
break;
|
||||
case "-1":
|
||||
UpdateStatusText(registerPanelStatusText, "Internal login server error", Color.red);
|
||||
break;
|
||||
case "-2":
|
||||
UpdateStatusText(registerPanelStatusText, "Incomplete form data", Color.red);
|
||||
break;
|
||||
case "-3":
|
||||
UpdateStatusText(registerPanelStatusText, "Username not valid", Color.red);
|
||||
break;
|
||||
case "-4":
|
||||
UpdateStatusText(registerPanelStatusText, "Email not valid", Color.red);
|
||||
break;
|
||||
case "-5":
|
||||
UpdateStatusText(registerPanelStatusText, "Password must have 8 characters, one number and one letter", Color.red);
|
||||
break;
|
||||
case "-6":
|
||||
UpdateStatusText(registerPanelStatusText, "Username too long or short", Color.red);
|
||||
break;
|
||||
case "-7":
|
||||
UpdateStatusText(registerPanelStatusText, "Username must be 3-16 characters, letters and numbers only", Color.red);
|
||||
break;
|
||||
case "-8":
|
||||
UpdateStatusText(registerPanelStatusText, "Username or email already exists", Color.red);
|
||||
break;
|
||||
default:
|
||||
UpdateStatusText(registerPanelStatusText, "Unknown server response \"" + text + "\"", Color.red);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator SubmitLogin()
|
||||
{
|
||||
WWWForm wWWForm = new WWWForm();
|
||||
wWWForm.AddField("username", loginPanelUsernameForm.text);
|
||||
wWWForm.AddField("password", loginPanelPasswordForm.text);
|
||||
wWWForm.AddField("currentHighScore", PlayerPrefs.GetInt("HighScore", 0).ToString());
|
||||
using UnityWebRequest request = UnityWebRequest.Post("https://berrydash.xytriza.com/database/loginAccount.php", wWWForm);
|
||||
request.SetRequestHeader("User-Agent", "BerryDashClient");
|
||||
request.SetRequestHeader("ClientVersion", PlayerPrefs.GetFloat("clientVersion").ToString());
|
||||
yield return request.SendWebRequest();
|
||||
if (request.result != UnityWebRequest.Result.Success)
|
||||
{
|
||||
Debug.LogError("HTTP Error: " + request.error);
|
||||
UpdateStatusText(loginPanelStatusText, "Failed to make HTTP request", Color.red);
|
||||
yield break;
|
||||
}
|
||||
string text = request.downloadHandler.text;
|
||||
Debug.Log(text);
|
||||
if (!(text == "-1"))
|
||||
{
|
||||
if (text == "-2")
|
||||
{
|
||||
UpdateStatusText(loginPanelStatusText, "Incorrect username or password", Color.red);
|
||||
}
|
||||
else if (Regex.IsMatch(text, "^[a-zA-Z0-9]{512}:\\d+:\\d+:\\d+:\\d+$"))
|
||||
{
|
||||
string[] array = text.Split(':');
|
||||
string value = array[0];
|
||||
int value2 = int.Parse(array[1]);
|
||||
int value3 = int.Parse(array[2]);
|
||||
int value4 = int.Parse(array[3]);
|
||||
int value5 = int.Parse(array[4]);
|
||||
PlayerPrefs.SetString("gameSession", value);
|
||||
PlayerPrefs.SetInt("userID", value2);
|
||||
PlayerPrefs.SetInt("HighScore", value3);
|
||||
PlayerPrefs.SetInt("icon", value4);
|
||||
PlayerPrefs.SetInt("overlay", value5);
|
||||
SwitchScene(0);
|
||||
UpdateStatusText(loginPanelStatusText, "", Color.red);
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateStatusText(loginPanelStatusText, "Unknown server response", Color.red);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateStatusText(loginPanelStatusText, "Internal login server error", Color.red);
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator ChangeUsername()
|
||||
{
|
||||
WWWForm wWWForm = new WWWForm();
|
||||
wWWForm.AddField("username", changeUsernameCurrentForm.text);
|
||||
wWWForm.AddField("currentPassword", changeUsernamePasswordForm.text);
|
||||
wWWForm.AddField("newUsername", changeUsernameNewForm.text);
|
||||
using UnityWebRequest request = UnityWebRequest.Post("https://berrydash.xytriza.com/database/changeAccountUsername.php", wWWForm);
|
||||
request.SetRequestHeader("User-Agent", "BerryDashClient");
|
||||
request.SetRequestHeader("ClientVersion", PlayerPrefs.GetFloat("clientVersion").ToString());
|
||||
yield return request.SendWebRequest();
|
||||
if (request.result != UnityWebRequest.Result.Success)
|
||||
{
|
||||
Debug.LogError("HTTP Error: " + request.error);
|
||||
UpdateStatusText(changeUsernameStatusText, "Failed to make HTTP request", Color.red);
|
||||
yield break;
|
||||
}
|
||||
string text = request.downloadHandler.text;
|
||||
Debug.Log(text);
|
||||
switch (text)
|
||||
{
|
||||
case "1":
|
||||
SwitchScene(0);
|
||||
UpdateStatusText(accountPanelStatusText, "Username changed successfully", Color.green);
|
||||
break;
|
||||
case "-1":
|
||||
UpdateStatusText(changeUsernameStatusText, "Internal login server error", Color.red);
|
||||
break;
|
||||
case "-2":
|
||||
UpdateStatusText(changeUsernameStatusText, "New Username, Password, or old username is empty", Color.red);
|
||||
break;
|
||||
case "-3":
|
||||
UpdateStatusText(changeUsernameStatusText, "New Username contains invalid characters", Color.red);
|
||||
break;
|
||||
case "-4":
|
||||
UpdateStatusText(changeUsernameStatusText, "New Username is too short or too long", Color.red);
|
||||
break;
|
||||
case "-5":
|
||||
UpdateStatusText(changeUsernameStatusText, "New Username does not match the required format", Color.red);
|
||||
break;
|
||||
case "-6":
|
||||
UpdateStatusText(changeUsernameStatusText, "Incorrect current password", Color.red);
|
||||
break;
|
||||
case "-7":
|
||||
UpdateStatusText(changeUsernameStatusText, "Current username is incorrect", Color.red);
|
||||
break;
|
||||
case "-8":
|
||||
UpdateStatusText(changeUsernameStatusText, "New username already exists", Color.red);
|
||||
break;
|
||||
default:
|
||||
UpdateStatusText(changeUsernameStatusText, "Unknown server response", Color.red);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator ChangePassword()
|
||||
{
|
||||
WWWForm wWWForm = new WWWForm();
|
||||
wWWForm.AddField("username", changePasswordCurrentUsernameForm.text);
|
||||
wWWForm.AddField("currentPassword", changePasswordCurrentForm.text);
|
||||
wWWForm.AddField("newPassword", changePasswordNewForm.text);
|
||||
using UnityWebRequest request = UnityWebRequest.Post("https://berrydash.xytriza.com/database/changeAccountPassword.php", wWWForm);
|
||||
request.SetRequestHeader("User-Agent", "BerryDashClient");
|
||||
request.SetRequestHeader("ClientVersion", PlayerPrefs.GetFloat("clientVersion").ToString());
|
||||
yield return request.SendWebRequest();
|
||||
if (request.result != UnityWebRequest.Result.Success)
|
||||
{
|
||||
Debug.LogError("HTTP Error: " + request.error);
|
||||
UpdateStatusText(changePasswordStatusText, "Failed to make HTTP request", Color.red);
|
||||
yield break;
|
||||
}
|
||||
string text = request.downloadHandler.text;
|
||||
Debug.Log(text);
|
||||
switch (text)
|
||||
{
|
||||
case "-1":
|
||||
UpdateStatusText(changePasswordStatusText, "Internal login server error", Color.red);
|
||||
yield break;
|
||||
case "-2":
|
||||
UpdateStatusText(changePasswordStatusText, "New Password, Password, or username is empty", Color.red);
|
||||
yield break;
|
||||
case "-3":
|
||||
UpdateStatusText(changePasswordStatusText, "New Password is too short or too long", Color.red);
|
||||
yield break;
|
||||
case "-4":
|
||||
UpdateStatusText(changePasswordStatusText, "Username must be 3-16 characters, letters and numbers only", Color.red);
|
||||
yield break;
|
||||
case "-5":
|
||||
UpdateStatusText(changePasswordStatusText, "Incorrect current password", Color.red);
|
||||
yield break;
|
||||
case "-6":
|
||||
UpdateStatusText(changePasswordStatusText, "Current username is incorrect", Color.red);
|
||||
yield break;
|
||||
case "-7":
|
||||
UpdateStatusText(changePasswordStatusText, "New password cannot be the same as your old password", Color.red);
|
||||
yield break;
|
||||
}
|
||||
if (Regex.IsMatch(text, "^[a-zA-Z0-9]{512}$"))
|
||||
{
|
||||
PlayerPrefs.SetString("gameSession", text);
|
||||
SwitchScene(0);
|
||||
UpdateStatusText(accountPanelStatusText, "Password changed successfully", Color.green);
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateStatusText(accountPanelStatusText, "Unknown server response", Color.red);
|
||||
}
|
||||
}
|
||||
|
||||
private void ClearForms()
|
||||
{
|
||||
registerPanelUsernameForm.text = "";
|
||||
registerPanelEmailForm.text = "";
|
||||
registerPanelEmailConfirmForm.text = "";
|
||||
registerPanelPasswordForm.text = "";
|
||||
registerPanelPasswordConfirmForm.text = "";
|
||||
loginPanelUsernameForm.text = "";
|
||||
loginPanelPasswordForm.text = "";
|
||||
changeUsernameNewForm.text = "";
|
||||
changeUsernamePasswordForm.text = "";
|
||||
changePasswordCurrentForm.text = "";
|
||||
changePasswordNewForm.text = "";
|
||||
changePasswordCurrentUsernameForm.text = "";
|
||||
changeUsernameCurrentForm.text = "";
|
||||
}
|
||||
|
||||
private IEnumerator SyncAccount()
|
||||
{
|
||||
WWWForm wWWForm = new WWWForm();
|
||||
wWWForm.AddField("userID", PlayerPrefs.GetInt("userID", 0).ToString());
|
||||
wWWForm.AddField("gameSession", PlayerPrefs.GetString("gameSession", ""));
|
||||
wWWForm.AddField("highScore", PlayerPrefs.GetInt("HighScore", 0).ToString());
|
||||
wWWForm.AddField("icon", PlayerPrefs.GetInt("icon", 1).ToString());
|
||||
wWWForm.AddField("overlay", PlayerPrefs.GetInt("overlay", 0).ToString());
|
||||
using UnityWebRequest request = UnityWebRequest.Post("https://berrydash.xytriza.com/database/syncAccount.php", wWWForm);
|
||||
request.SetRequestHeader("User-Agent", "BerryDashClient");
|
||||
request.SetRequestHeader("ClientVersion", PlayerPrefs.GetFloat("clientVersion").ToString());
|
||||
yield return request.SendWebRequest();
|
||||
if (request.result != UnityWebRequest.Result.Success)
|
||||
{
|
||||
Debug.LogError("HTTP Error: " + request.error);
|
||||
UpdateStatusText(accountPanelStatusText, "Failed to make HTTP request", Color.red);
|
||||
yield break;
|
||||
}
|
||||
string text = request.downloadHandler.text;
|
||||
Debug.Log(text);
|
||||
switch (text)
|
||||
{
|
||||
case "1":
|
||||
accountPanelSyncButton.interactable = false;
|
||||
UpdateStatusText(accountPanelStatusText, "Synced account", Color.green);
|
||||
break;
|
||||
case "-1":
|
||||
UpdateStatusText(accountPanelStatusText, "Internal login server error", Color.red);
|
||||
break;
|
||||
case "-2":
|
||||
LogoutAccount();
|
||||
break;
|
||||
default:
|
||||
UpdateStatusText(accountPanelStatusText, "Unknown server response \"" + text + "\"", Color.red);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void StartSyncAccount()
|
||||
{
|
||||
StartCoroutine(SyncAccount());
|
||||
}
|
||||
|
||||
private void LogoutAccount()
|
||||
{
|
||||
PlayerPrefs.DeleteKey("userID");
|
||||
PlayerPrefs.DeleteKey("gameSession");
|
||||
PlayerPrefs.SetInt("HighScore", 0);
|
||||
PlayerPrefs.SetInt("icon", 1);
|
||||
PlayerPrefs.SetInt("overlay", 0);
|
||||
SwitchScene(1);
|
||||
}
|
||||
|
||||
private void UpdateStatusText(TMP_Text text, string message, Color color)
|
||||
{
|
||||
text.text = message;
|
||||
text.color = color;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 047a8a59c57418c87b9e45f2c0318297
|
||||
timeCreated: 1754266431
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
externalObjects: {}
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class ChatController : MonoBehaviour
|
||||
{
|
||||
public TMP_InputField ChatInputField;
|
||||
|
||||
public TMP_Text ChatDisplayOutput;
|
||||
|
||||
public Scrollbar ChatScrollbar;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
ChatInputField.onSubmit.AddListener(AddToChatOutput);
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
ChatInputField.onSubmit.RemoveListener(AddToChatOutput);
|
||||
}
|
||||
|
||||
private void AddToChatOutput(string newText)
|
||||
{
|
||||
ChatInputField.text = string.Empty;
|
||||
DateTime now = DateTime.Now;
|
||||
string text = "[<#FFFF80>" + now.Hour.ToString("d2") + ":" + now.Minute.ToString("d2") + ":" + now.Second.ToString("d2") + "</color>] " + newText;
|
||||
if (ChatDisplayOutput != null)
|
||||
{
|
||||
if (ChatDisplayOutput.text == string.Empty)
|
||||
{
|
||||
ChatDisplayOutput.text = text;
|
||||
}
|
||||
else
|
||||
{
|
||||
TMP_Text chatDisplayOutput = ChatDisplayOutput;
|
||||
chatDisplayOutput.text = chatDisplayOutput.text + "\n" + text;
|
||||
}
|
||||
}
|
||||
ChatInputField.ActivateInputField();
|
||||
ChatScrollbar.value = 0f;
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 040093e64515ea51b16860f9ccf9cd0c
|
||||
timeCreated: 1754266431
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
externalObjects: {}
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,19 @@
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
public class DropdownSample : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private TextMeshProUGUI text;
|
||||
|
||||
[SerializeField]
|
||||
private TMP_Dropdown dropdownWithoutPlaceholder;
|
||||
|
||||
[SerializeField]
|
||||
private TMP_Dropdown dropdownWithPlaceholder;
|
||||
|
||||
public void OnButtonClick()
|
||||
{
|
||||
text.text = ((dropdownWithPlaceholder.value > -1) ? ("Selected values:\n" + dropdownWithoutPlaceholder.value + " - " + dropdownWithPlaceholder.value) : "Error: Please make a selection");
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a3643d9c5c884669961d45fbdd017158
|
||||
timeCreated: 1754266431
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
externalObjects: {}
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,29 @@
|
||||
using System.Collections;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
public class EnvMapAnimator : MonoBehaviour
|
||||
{
|
||||
public Vector3 RotationSpeeds;
|
||||
|
||||
private TMP_Text m_textMeshPro;
|
||||
|
||||
private Material m_material;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
m_textMeshPro = GetComponent<TMP_Text>();
|
||||
m_material = m_textMeshPro.fontSharedMaterial;
|
||||
}
|
||||
|
||||
private IEnumerator Start()
|
||||
{
|
||||
Matrix4x4 matrix = default(Matrix4x4);
|
||||
while (true)
|
||||
{
|
||||
matrix.SetTRS(Vector3.zero, Quaternion.Euler(Time.time * RotationSpeeds.x, Time.time * RotationSpeeds.y, Time.time * RotationSpeeds.z), Vector3.one);
|
||||
m_material.SetMatrix("_EnvMatrix", matrix);
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 195fda47a9c061efffeb5015bfe4ed10
|
||||
timeCreated: 1754266431
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
externalObjects: {}
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,629 @@
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
public class Game : MonoBehaviour
|
||||
{
|
||||
public float spawnRate = 1f;
|
||||
|
||||
private float nextSpawnTime;
|
||||
|
||||
private int score;
|
||||
|
||||
private int highscore;
|
||||
|
||||
private float boostLeft;
|
||||
|
||||
private float slownessLeft;
|
||||
|
||||
private float screenWidth;
|
||||
|
||||
private bool isGrounded;
|
||||
|
||||
public TMP_Text scoreText;
|
||||
|
||||
public TMP_Text highScoreText;
|
||||
|
||||
public TMP_Text boostText;
|
||||
|
||||
public GameObject bird;
|
||||
|
||||
public GameObject pausePanel;
|
||||
|
||||
public Rigidbody2D rb;
|
||||
|
||||
public AudioSource backgroundMusic;
|
||||
|
||||
public TMP_Text fpsCounter;
|
||||
|
||||
private float nextUpdate;
|
||||
|
||||
private float fps;
|
||||
|
||||
public SpriteRenderer overlayRender;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
highscore = PlayerPrefs.GetInt("HighScore", 0);
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
SpriteRenderer component = bird.GetComponent<SpriteRenderer>();
|
||||
int num = PlayerPrefs.GetInt("icon", 1);
|
||||
int num2 = PlayerPrefs.GetInt("overlay", 1);
|
||||
switch (num)
|
||||
{
|
||||
case 1:
|
||||
if (PlayerPrefs.GetInt("userID", 0) == 1)
|
||||
{
|
||||
component.sprite = Resources.Load<Sprite>("icons/icons/bird_-1");
|
||||
}
|
||||
else if (PlayerPrefs.GetInt("userID", 0) == 2)
|
||||
{
|
||||
component.sprite = Resources.Load<Sprite>("icons/icons/bird_-2");
|
||||
}
|
||||
else if (PlayerPrefs.GetInt("userID", 0) == 4)
|
||||
{
|
||||
component.sprite = Resources.Load<Sprite>("icons/icons/bird_-3");
|
||||
}
|
||||
else
|
||||
{
|
||||
component.sprite = Resources.Load<Sprite>("icons/icons/bird_1");
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
component.sprite = Resources.Load<Sprite>("icons/icons/bird_2");
|
||||
break;
|
||||
case 3:
|
||||
component.sprite = Resources.Load<Sprite>("icons/icons/bird_3");
|
||||
break;
|
||||
case 4:
|
||||
component.sprite = Resources.Load<Sprite>("icons/icons/bird_4");
|
||||
break;
|
||||
default:
|
||||
component.sprite = Resources.Load<Sprite>("icons/icons/bird_1");
|
||||
PlayerPrefs.SetInt("icon", 1);
|
||||
PlayerPrefs.Save();
|
||||
break;
|
||||
}
|
||||
switch (num2)
|
||||
{
|
||||
case 1:
|
||||
overlayRender.sprite = Resources.Load<Sprite>("icons/overlays/overlay_1");
|
||||
break;
|
||||
case 2:
|
||||
overlayRender.sprite = Resources.Load<Sprite>("icons/overlays/overlay_2");
|
||||
break;
|
||||
case 3:
|
||||
overlayRender.sprite = Resources.Load<Sprite>("icons/overlays/overlay_3");
|
||||
break;
|
||||
case 4:
|
||||
overlayRender.sprite = Resources.Load<Sprite>("icons/overlays/overlay_4");
|
||||
break;
|
||||
case 5:
|
||||
overlayRender.sprite = Resources.Load<Sprite>("icons/overlays/overlay_5");
|
||||
break;
|
||||
case 6:
|
||||
overlayRender.sprite = Resources.Load<Sprite>("icons/overlays/overlay_6");
|
||||
break;
|
||||
case 7:
|
||||
overlayRender.sprite = Resources.Load<Sprite>("icons/overlays/overlay_7");
|
||||
break;
|
||||
case 8:
|
||||
overlayRender.sprite = Resources.Load<Sprite>("icons/overlays/overlay_8");
|
||||
overlayRender.transform.localPosition = new Vector3(-0.35f, 0.3f, 0f);
|
||||
break;
|
||||
case 9:
|
||||
overlayRender.sprite = Resources.Load<Sprite>("icons/overlays/overlay_9");
|
||||
break;
|
||||
default:
|
||||
overlayRender.sprite = null;
|
||||
break;
|
||||
}
|
||||
if (component.sprite == null)
|
||||
{
|
||||
component.sprite = Resources.Load<Sprite>("icons/icons/bird_1");
|
||||
PlayerPrefs.SetInt("icon", 1);
|
||||
}
|
||||
if (overlayRender.sprite == null && num2 != 0)
|
||||
{
|
||||
overlayRender.sprite = Resources.Load<Sprite>("icons/overlays/overlay_1");
|
||||
PlayerPrefs.SetInt("overlay", 1);
|
||||
}
|
||||
PlayerPrefs.Save();
|
||||
backgroundMusic.volume = PlayerPrefs.GetFloat("musicVolume", 1f);
|
||||
screenWidth = Camera.main.orthographicSize * 2f * Camera.main.aspect;
|
||||
GameObject.Find("HighScoreText").GetComponent<TMP_Text>().text = $"High Score: {highscore}";
|
||||
if (PlayerPrefs.GetInt("Setting2", 0) == 1)
|
||||
{
|
||||
GameObject gameObject = new GameObject("LeftArrow");
|
||||
GameObject gameObject2 = new GameObject("RightArrow");
|
||||
GameObject gameObject3 = new GameObject("JumpArrow");
|
||||
GameObject gameObject4 = new GameObject("RestartButton");
|
||||
GameObject gameObject5 = new GameObject("BackButton");
|
||||
gameObject.AddComponent<SpriteRenderer>();
|
||||
gameObject2.AddComponent<SpriteRenderer>();
|
||||
gameObject3.AddComponent<SpriteRenderer>();
|
||||
gameObject4.AddComponent<SpriteRenderer>();
|
||||
gameObject5.AddComponent<SpriteRenderer>();
|
||||
gameObject.GetComponent<SpriteRenderer>().sprite = Resources.Load<Sprite>("textures/Arrow");
|
||||
gameObject2.GetComponent<SpriteRenderer>().sprite = Resources.Load<Sprite>("textures/Arrow");
|
||||
gameObject3.GetComponent<SpriteRenderer>().sprite = Resources.Load<Sprite>("textures/Arrow");
|
||||
gameObject4.GetComponent<SpriteRenderer>().sprite = Resources.Load<Sprite>("textures/Restart");
|
||||
gameObject5.GetComponent<SpriteRenderer>().sprite = Resources.Load<Sprite>("textures/Arrow");
|
||||
gameObject.transform.rotation = Quaternion.Euler(0f, 0f, 90f);
|
||||
gameObject2.transform.rotation = Quaternion.Euler(0f, 0f, -90f);
|
||||
gameObject5.transform.rotation = Quaternion.Euler(0f, 0f, 90f);
|
||||
gameObject.transform.position = new Vector3((0f - screenWidth) / 2.5f, -4f, 0f);
|
||||
gameObject2.transform.position = new Vector3(screenWidth / 2.5f, -4f, 0f);
|
||||
gameObject4.transform.position = new Vector3(screenWidth / 2.3f, Camera.main.orthographicSize - 1.2f, 0f);
|
||||
gameObject5.transform.position = new Vector3((0f - screenWidth) / 2.3f, Camera.main.orthographicSize - 1.2f, 0f);
|
||||
if (PlayerPrefs.GetInt("Setting3", 0) == 1)
|
||||
{
|
||||
gameObject.transform.localScale = new Vector3(screenWidth / 14f, screenWidth / 14f, 1f);
|
||||
gameObject2.transform.localScale = new Vector3(screenWidth / 14f, screenWidth / 14f, 1f);
|
||||
gameObject3.transform.localScale = new Vector3(screenWidth / 14f, screenWidth / 14f, 1f);
|
||||
gameObject4.transform.localScale = new Vector3(screenWidth / 14f, screenWidth / 14f, 1f);
|
||||
gameObject5.transform.localScale = new Vector3(screenWidth / 14f, screenWidth / 14f, 1f);
|
||||
gameObject3.transform.position = new Vector3(screenWidth / 2.5f, -1f, 0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
gameObject.transform.localScale = new Vector3(screenWidth / 20f, screenWidth / 20f, 1f);
|
||||
gameObject2.transform.localScale = new Vector3(screenWidth / 20f, screenWidth / 20f, 1f);
|
||||
gameObject3.transform.localScale = new Vector3(screenWidth / 20f, screenWidth / 20f, 1f);
|
||||
gameObject4.transform.localScale = new Vector3(screenWidth / 20f, screenWidth / 20f, 1f);
|
||||
gameObject5.transform.localScale = new Vector3(screenWidth / 20f, screenWidth / 20f, 1f);
|
||||
gameObject3.transform.position = new Vector3(screenWidth / 2.5f, -2f, 0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void MoveBird()
|
||||
{
|
||||
float num = Camera.main.orthographicSize * 2f * Camera.main.aspect;
|
||||
float num2 = 0.18f * (num / 20.19257f);
|
||||
bool flag = false;
|
||||
bool flag2 = false;
|
||||
bool flag3 = false;
|
||||
bool flag4 = false;
|
||||
bool flag5 = false;
|
||||
float num3 = num2;
|
||||
if (boostLeft > 0f)
|
||||
{
|
||||
num3 = num2 * 1.39f;
|
||||
}
|
||||
else if (slownessLeft > 0f)
|
||||
{
|
||||
num3 = num2 * 0.56f;
|
||||
}
|
||||
CheckIfGrounded();
|
||||
float axisRaw = Input.GetAxisRaw("Horizontal");
|
||||
if (axisRaw < 0f || Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.A))
|
||||
{
|
||||
flag2 = true;
|
||||
}
|
||||
if (axisRaw > 0f || Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.D))
|
||||
{
|
||||
flag = true;
|
||||
}
|
||||
if (Input.GetKey(KeyCode.Space) || Input.GetKey(KeyCode.UpArrow) || Input.GetKey(KeyCode.W) || (Input.GetMouseButton(0) && PlayerPrefs.GetInt("Setting2", 0) == 0) || Input.GetKey(KeyCode.JoystickButton0))
|
||||
{
|
||||
flag3 = true;
|
||||
}
|
||||
if (Input.GetKey(KeyCode.R))
|
||||
{
|
||||
flag5 = true;
|
||||
}
|
||||
if (PlayerPrefs.GetInt("Setting2", 0) == 1)
|
||||
{
|
||||
GameObject gameObject = GameObject.Find("LeftArrow");
|
||||
GameObject gameObject2 = GameObject.Find("RightArrow");
|
||||
GameObject gameObject3 = GameObject.Find("JumpArrow");
|
||||
GameObject gameObject4 = GameObject.Find("RestartButton");
|
||||
GameObject gameObject5 = GameObject.Find("BackButton");
|
||||
if (Input.GetMouseButton(0))
|
||||
{
|
||||
Vector3 point = Camera.main.ScreenToWorldPoint(Input.mousePosition);
|
||||
point.z = 0f;
|
||||
if (gameObject.GetComponent<SpriteRenderer>().bounds.Contains(point))
|
||||
{
|
||||
flag2 = true;
|
||||
}
|
||||
if (gameObject2.GetComponent<SpriteRenderer>().bounds.Contains(point))
|
||||
{
|
||||
flag = true;
|
||||
}
|
||||
if (gameObject3.GetComponent<SpriteRenderer>().bounds.Contains(point))
|
||||
{
|
||||
flag3 = true;
|
||||
}
|
||||
}
|
||||
if (Input.GetMouseButtonDown(0))
|
||||
{
|
||||
Vector3 point2 = Camera.main.ScreenToWorldPoint(Input.mousePosition);
|
||||
point2.z = 0f;
|
||||
if (gameObject4.GetComponent<SpriteRenderer>().bounds.Contains(point2))
|
||||
{
|
||||
flag5 = true;
|
||||
}
|
||||
if (gameObject5.GetComponent<SpriteRenderer>().bounds.Contains(point2))
|
||||
{
|
||||
flag4 = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (flag2 && !flag)
|
||||
{
|
||||
bird.transform.position += new Vector3(0f - num3, 0f, 0f);
|
||||
ClampPosition(num, bird);
|
||||
bird.transform.localScale = new Vector3(1.35f, 1.35f, 1.35f);
|
||||
}
|
||||
if (flag && !flag2)
|
||||
{
|
||||
bird.transform.position += new Vector3(num3, 0f, 0f);
|
||||
ClampPosition(num, bird);
|
||||
bird.transform.localScale = new Vector3(-1.35f, 1.35f, 1.35f);
|
||||
}
|
||||
if (flag3 && isGrounded)
|
||||
{
|
||||
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("sounds/Jump"), Camera.main.transform.position, 0.75f * PlayerPrefs.GetFloat("sfxVolume", 1f));
|
||||
if (boostLeft > 0f)
|
||||
{
|
||||
rb.velocity = Vector2.up * 12f;
|
||||
}
|
||||
else if (slownessLeft > 0f)
|
||||
{
|
||||
rb.velocity = Vector2.up * 6f;
|
||||
}
|
||||
else
|
||||
{
|
||||
rb.velocity = Vector2.up * 9f;
|
||||
}
|
||||
}
|
||||
if (flag4)
|
||||
{
|
||||
TogglePause();
|
||||
}
|
||||
if (flag5)
|
||||
{
|
||||
Respawn();
|
||||
}
|
||||
}
|
||||
|
||||
private void ClampPosition(float screenWidth, GameObject bird)
|
||||
{
|
||||
float num = screenWidth / 2.17f;
|
||||
float x = Mathf.Clamp(bird.transform.position.x, 0f - num, num);
|
||||
bird.transform.position = new Vector3(x, bird.transform.position.y, bird.transform.position.z);
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
SpawnBerries();
|
||||
if (!pausePanel.activeSelf)
|
||||
{
|
||||
MoveBird();
|
||||
if (boostLeft > 0f)
|
||||
{
|
||||
boostLeft -= Time.deltaTime;
|
||||
boostText.GetComponent<TMP_Text>().text = "Boost expires in " + $"{boostLeft:0.0}" + "s";
|
||||
}
|
||||
else if (slownessLeft > 0f)
|
||||
{
|
||||
slownessLeft -= Time.deltaTime;
|
||||
boostText.GetComponent<TMP_Text>().text = "Slowness expires in " + $"{slownessLeft:0.0}" + "s";
|
||||
}
|
||||
else
|
||||
{
|
||||
boostText.GetComponent<TMP_Text>().text = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SpawnBerries()
|
||||
{
|
||||
if (!(Time.time >= nextSpawnTime))
|
||||
{
|
||||
return;
|
||||
}
|
||||
nextSpawnTime = Time.time + 1f / spawnRate;
|
||||
float value = Random.value;
|
||||
if (!pausePanel.activeSelf)
|
||||
{
|
||||
GameObject gameObject;
|
||||
SpriteRenderer spriteRenderer;
|
||||
if (value <= 0.6f)
|
||||
{
|
||||
gameObject = new GameObject("Berry");
|
||||
spriteRenderer = gameObject.AddComponent<SpriteRenderer>();
|
||||
spriteRenderer.sprite = Resources.Load<Sprite>("textures/Berry");
|
||||
gameObject.tag = "Berry";
|
||||
}
|
||||
else if (value <= 0.8f)
|
||||
{
|
||||
gameObject = new GameObject("PoisonBerry");
|
||||
spriteRenderer = gameObject.AddComponent<SpriteRenderer>();
|
||||
spriteRenderer.sprite = Resources.Load<Sprite>("textures/PoisonBerry");
|
||||
gameObject.tag = "PoisonBerry";
|
||||
}
|
||||
else if (value <= 0.9f)
|
||||
{
|
||||
gameObject = new GameObject("SlowBerry");
|
||||
spriteRenderer = gameObject.AddComponent<SpriteRenderer>();
|
||||
spriteRenderer.sprite = Resources.Load<Sprite>("textures/SlowBerry");
|
||||
gameObject.tag = "SlowBerry";
|
||||
}
|
||||
else
|
||||
{
|
||||
gameObject = new GameObject("UltraBerry");
|
||||
spriteRenderer = gameObject.AddComponent<SpriteRenderer>();
|
||||
spriteRenderer.sprite = Resources.Load<Sprite>("textures/UltraBerry");
|
||||
gameObject.tag = "UltraBerry";
|
||||
}
|
||||
spriteRenderer.sortingOrder = -5;
|
||||
float num = Camera.main.orthographicSize * 2f * Camera.main.aspect;
|
||||
float x = Random.Range((0f - num) / 2.17f, num / 2.17f);
|
||||
gameObject.transform.position = new Vector3(x, Camera.main.orthographicSize + 1f, 0f);
|
||||
Rigidbody2D rigidbody2D = gameObject.AddComponent<Rigidbody2D>();
|
||||
rigidbody2D.gravityScale = 0f;
|
||||
rigidbody2D.velocity = new Vector2(0f, -3f);
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (PlayerPrefs.GetInt("Setting4", 0) == 1 && Time.time > nextUpdate)
|
||||
{
|
||||
fps = 1f / Time.deltaTime;
|
||||
fpsCounter.text = "FPS: " + Mathf.Round(fps);
|
||||
nextUpdate = Time.time + 0.25f;
|
||||
}
|
||||
if (screenWidth != Camera.main.orthographicSize * 2f * Camera.main.aspect)
|
||||
{
|
||||
screenWidth = Camera.main.orthographicSize * 2f * Camera.main.aspect;
|
||||
ClampPosition(screenWidth, bird);
|
||||
if (PlayerPrefs.GetInt("Setting2", 0) == 1)
|
||||
{
|
||||
GameObject gameObject = GameObject.Find("LeftArrow");
|
||||
GameObject gameObject2 = GameObject.Find("RightArrow");
|
||||
GameObject gameObject3 = GameObject.Find("JumpArrow");
|
||||
GameObject gameObject4 = GameObject.Find("RestartButton");
|
||||
GameObject gameObject5 = GameObject.Find("BackButton");
|
||||
gameObject.transform.position = new Vector3((0f - screenWidth) / 2.5f, -4f, 0f);
|
||||
gameObject2.transform.position = new Vector3(screenWidth / 2.5f, -4f, 0f);
|
||||
gameObject4.transform.position = new Vector3(screenWidth / 2.3f, Camera.main.orthographicSize - 1.2f, 0f);
|
||||
gameObject5.transform.position = new Vector3((0f - screenWidth) / 2.3f, Camera.main.orthographicSize - 1.2f, 0f);
|
||||
if (PlayerPrefs.GetInt("Setting3", 0) == 1)
|
||||
{
|
||||
gameObject.transform.localScale = new Vector3(screenWidth / 14f, screenWidth / 14f, 1f);
|
||||
gameObject2.transform.localScale = new Vector3(screenWidth / 14f, screenWidth / 14f, 1f);
|
||||
gameObject3.transform.localScale = new Vector3(screenWidth / 14f, screenWidth / 14f, 1f);
|
||||
gameObject4.transform.localScale = new Vector3(screenWidth / 14f, screenWidth / 14f, 1f);
|
||||
gameObject5.transform.localScale = new Vector3(screenWidth / 14f, screenWidth / 14f, 1f);
|
||||
gameObject3.transform.position = new Vector3(screenWidth / 2.5f, -1f, 0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
gameObject.transform.localScale = new Vector3(screenWidth / 20f, screenWidth / 20f, 1f);
|
||||
gameObject2.transform.localScale = new Vector3(screenWidth / 20f, screenWidth / 20f, 1f);
|
||||
gameObject3.transform.localScale = new Vector3(screenWidth / 20f, screenWidth / 20f, 1f);
|
||||
gameObject4.transform.localScale = new Vector3(screenWidth / 20f, screenWidth / 20f, 1f);
|
||||
gameObject5.transform.localScale = new Vector3(screenWidth / 20f, screenWidth / 20f, 1f);
|
||||
gameObject3.transform.position = new Vector3(screenWidth / 2.5f, -2f, 0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
GameObject[] array = GameObject.FindGameObjectsWithTag("Berry");
|
||||
GameObject[] array2 = GameObject.FindGameObjectsWithTag("PoisonBerry");
|
||||
GameObject[] array3 = GameObject.FindGameObjectsWithTag("UltraBerry");
|
||||
GameObject[] array4 = GameObject.FindGameObjectsWithTag("SlowBerry");
|
||||
if (!pausePanel.activeSelf)
|
||||
{
|
||||
CheckIfGrounded();
|
||||
GameObject[] array5 = array;
|
||||
foreach (GameObject gameObject6 in array5)
|
||||
{
|
||||
if (gameObject6.transform.position.y < 0f - Camera.main.orthographicSize - 1f)
|
||||
{
|
||||
Object.Destroy(gameObject6);
|
||||
}
|
||||
else if (Vector3.Distance(bird.transform.position, gameObject6.transform.position) < 1.5f)
|
||||
{
|
||||
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("sounds/Eat"), Camera.main.transform.position, PlayerPrefs.GetFloat("sfxVolume", 1f));
|
||||
Object.Destroy(gameObject6);
|
||||
score++;
|
||||
UpdateScore(score);
|
||||
}
|
||||
gameObject6.GetComponent<Rigidbody2D>().velocity = new Vector2(0f, -3f);
|
||||
}
|
||||
array5 = array2;
|
||||
foreach (GameObject gameObject7 in array5)
|
||||
{
|
||||
if (gameObject7.transform.position.y < 0f - Camera.main.orthographicSize - 1f)
|
||||
{
|
||||
Object.Destroy(gameObject7);
|
||||
}
|
||||
else if (Vector3.Distance(bird.transform.position, gameObject7.transform.position) < 1.5f)
|
||||
{
|
||||
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("sounds/Death"), Camera.main.transform.position, PlayerPrefs.GetFloat("sfxVolume", 1f));
|
||||
Respawn();
|
||||
}
|
||||
gameObject7.GetComponent<Rigidbody2D>().velocity = new Vector2(0f, -3f);
|
||||
}
|
||||
array5 = array3;
|
||||
foreach (GameObject gameObject8 in array5)
|
||||
{
|
||||
if (gameObject8.transform.position.y < 0f - Camera.main.orthographicSize - 1f)
|
||||
{
|
||||
Object.Destroy(gameObject8);
|
||||
}
|
||||
else if (Vector3.Distance(bird.transform.position, gameObject8.transform.position) < 1.5f)
|
||||
{
|
||||
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("sounds/Powerup"), Camera.main.transform.position, 0.5f * PlayerPrefs.GetFloat("sfxVolume", 1f));
|
||||
Object.Destroy(gameObject8);
|
||||
if (slownessLeft > 0f)
|
||||
{
|
||||
slownessLeft = 0f;
|
||||
score++;
|
||||
UpdateScore(score);
|
||||
}
|
||||
else
|
||||
{
|
||||
boostLeft += 10f;
|
||||
score += 5;
|
||||
UpdateScore(score);
|
||||
}
|
||||
}
|
||||
gameObject8.GetComponent<Rigidbody2D>().velocity = new Vector2(0f, -3f);
|
||||
}
|
||||
array5 = array4;
|
||||
foreach (GameObject gameObject9 in array5)
|
||||
{
|
||||
if (gameObject9.transform.position.y < 0f - Camera.main.orthographicSize - 1f)
|
||||
{
|
||||
Object.Destroy(gameObject9);
|
||||
}
|
||||
else if (Vector3.Distance(bird.transform.position, gameObject9.transform.position) < 1.5f)
|
||||
{
|
||||
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("sounds/Slowness"), Camera.main.transform.position, 0.5f * PlayerPrefs.GetFloat("sfxVolume", 1f));
|
||||
Object.Destroy(gameObject9);
|
||||
boostLeft = 0f;
|
||||
slownessLeft = 10f;
|
||||
if (score > 0)
|
||||
{
|
||||
score--;
|
||||
UpdateScore(score);
|
||||
}
|
||||
}
|
||||
gameObject9.GetComponent<Rigidbody2D>().velocity = new Vector2(0f, -3f);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rb.gravityScale = 0f;
|
||||
rb.velocity = Vector2.zero;
|
||||
GameObject[] array5 = array;
|
||||
for (int i = 0; i < array5.Length; i++)
|
||||
{
|
||||
array5[i].GetComponent<Rigidbody2D>().velocity = Vector2.zero;
|
||||
}
|
||||
array5 = array2;
|
||||
for (int i = 0; i < array5.Length; i++)
|
||||
{
|
||||
array5[i].GetComponent<Rigidbody2D>().velocity = Vector2.zero;
|
||||
}
|
||||
array5 = array3;
|
||||
for (int i = 0; i < array5.Length; i++)
|
||||
{
|
||||
array5[i].GetComponent<Rigidbody2D>().velocity = Vector2.zero;
|
||||
}
|
||||
array5 = array4;
|
||||
for (int i = 0; i < array5.Length; i++)
|
||||
{
|
||||
array5[i].GetComponent<Rigidbody2D>().velocity = Vector2.zero;
|
||||
}
|
||||
}
|
||||
if (Input.GetKeyDown(KeyCode.Escape) || Input.GetKeyDown(KeyCode.JoystickButton7) || Input.GetKeyDown(KeyCode.Joystick2Button7))
|
||||
{
|
||||
TogglePause();
|
||||
}
|
||||
}
|
||||
|
||||
private void Respawn()
|
||||
{
|
||||
bird.transform.position = new Vector3(0f, -4.3f, 0f);
|
||||
bird.transform.localScale = new Vector3(1.35f, 1.35f, 1.35f);
|
||||
rb.gravityScale = 0f;
|
||||
rb.velocity = Vector2.zero;
|
||||
score = 0;
|
||||
boostLeft = 0f;
|
||||
slownessLeft = 0f;
|
||||
UpdateScore(score);
|
||||
GameObject[] array = GameObject.FindGameObjectsWithTag("Berry");
|
||||
GameObject[] array2 = GameObject.FindGameObjectsWithTag("PoisonBerry");
|
||||
GameObject[] array3 = GameObject.FindGameObjectsWithTag("UltraBerry");
|
||||
GameObject[] array4 = GameObject.FindGameObjectsWithTag("SlowBerry");
|
||||
GameObject[] array5 = array;
|
||||
for (int i = 0; i < array5.Length; i++)
|
||||
{
|
||||
Object.Destroy(array5[i]);
|
||||
}
|
||||
array5 = array2;
|
||||
for (int i = 0; i < array5.Length; i++)
|
||||
{
|
||||
Object.Destroy(array5[i]);
|
||||
}
|
||||
array5 = array3;
|
||||
for (int i = 0; i < array5.Length; i++)
|
||||
{
|
||||
Object.Destroy(array5[i]);
|
||||
}
|
||||
array5 = array4;
|
||||
for (int i = 0; i < array5.Length; i++)
|
||||
{
|
||||
Object.Destroy(array5[i]);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateScore(int score)
|
||||
{
|
||||
if (score > highscore)
|
||||
{
|
||||
highscore = score;
|
||||
}
|
||||
PlayerPrefs.SetInt("HighScore", highscore);
|
||||
PlayerPrefs.Save();
|
||||
scoreText.GetComponent<TMP_Text>().text = "Score: " + score;
|
||||
highScoreText.GetComponent<TMP_Text>().text = "High Score: " + highscore;
|
||||
}
|
||||
|
||||
private void CheckIfGrounded()
|
||||
{
|
||||
GameObject gameObject = GameObject.Find("JumpArrow");
|
||||
isGrounded = bird.transform.position.y <= -4.1299996f;
|
||||
rb.gravityScale = (isGrounded ? 0f : 1.5f);
|
||||
if (bird.transform.position.y < -4.18f)
|
||||
{
|
||||
bird.transform.position = new Vector2(bird.transform.position.x, -4.18f);
|
||||
rb.velocity = new Vector2(rb.velocity.x, 0f);
|
||||
}
|
||||
if (gameObject != null)
|
||||
{
|
||||
Renderer component = gameObject.GetComponent<Renderer>();
|
||||
if (component != null)
|
||||
{
|
||||
component.material.color = (isGrounded ? Color.white : Color.red);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void TogglePause()
|
||||
{
|
||||
if (pausePanel.activeSelf)
|
||||
{
|
||||
DisablePause();
|
||||
}
|
||||
else
|
||||
{
|
||||
EnablePause();
|
||||
}
|
||||
}
|
||||
|
||||
private void EnablePause()
|
||||
{
|
||||
backgroundMusic.Pause();
|
||||
pausePanel.SetActive(value: true);
|
||||
}
|
||||
|
||||
private void DisablePause()
|
||||
{
|
||||
backgroundMusic.Play();
|
||||
pausePanel.SetActive(value: false);
|
||||
}
|
||||
|
||||
private void OnApplicationPause()
|
||||
{
|
||||
EnablePause();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 351b0d6adaecf72e6fc7c33c0eece600
|
||||
timeCreated: 1754266431
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
externalObjects: {}
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,210 @@
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class Iconkit : MonoBehaviour
|
||||
{
|
||||
public GameObject panel;
|
||||
|
||||
public GameObject iconSelectionPanel;
|
||||
|
||||
public GameObject overlaySelectionPanel;
|
||||
|
||||
public Button backButton;
|
||||
|
||||
public Image defaultIcon;
|
||||
|
||||
public Button placeholderButton;
|
||||
|
||||
public TMP_Text selectionText;
|
||||
|
||||
public Image previewBird;
|
||||
|
||||
public Image previewOverlay;
|
||||
|
||||
public Image overlay0;
|
||||
|
||||
public Image overlay1;
|
||||
|
||||
public Image overlay2;
|
||||
|
||||
public Image overlay3;
|
||||
|
||||
public Image overlay4;
|
||||
|
||||
public Image overlay5;
|
||||
|
||||
public Image overlay6;
|
||||
|
||||
public Image overlay7;
|
||||
|
||||
public Image overlay8;
|
||||
|
||||
public Image overlay9;
|
||||
|
||||
public Image icon1;
|
||||
|
||||
public Image icon2;
|
||||
|
||||
public Image icon3;
|
||||
|
||||
public Image icon4;
|
||||
|
||||
public GameObject previewBirdObject;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
SwitchToIcon();
|
||||
SelectOverlay(PlayerPrefs.GetInt("overlay", Mathf.Clamp(PlayerPrefs.GetInt("overlay", 0), 0, 9)));
|
||||
SelectIcon(PlayerPrefs.GetInt("icon", Mathf.Clamp(PlayerPrefs.GetInt("icon", 0), 1, 4)));
|
||||
if (PlayerPrefs.GetInt("userID", 0) == 1)
|
||||
{
|
||||
defaultIcon.sprite = Resources.Load<Sprite>("icons/icons/bird_-1");
|
||||
}
|
||||
else if (PlayerPrefs.GetInt("userID", 0) == 2)
|
||||
{
|
||||
defaultIcon.sprite = Resources.Load<Sprite>("icons/icons/bird_-2");
|
||||
}
|
||||
else if (PlayerPrefs.GetInt("userID", 0) == 4)
|
||||
{
|
||||
defaultIcon.sprite = Resources.Load<Sprite>("icons/icons/bird_-3");
|
||||
}
|
||||
placeholderButton.onClick.AddListener(ToggleKit);
|
||||
backButton.onClick.AddListener(delegate
|
||||
{
|
||||
PlayerPrefs.SetInt("icon", Mathf.Clamp(PlayerPrefs.GetInt("icon", 0), 1, 4));
|
||||
PlayerPrefs.SetInt("overlay", Mathf.Clamp(PlayerPrefs.GetInt("overlay", 0), 0, 9));
|
||||
PlayerPrefs.Save();
|
||||
SceneManager.LoadScene("Menu");
|
||||
});
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (!Input.GetMouseButtonDown(0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
Vector2 screenPoint = Input.mousePosition;
|
||||
Image[] array = new Image[10] { overlay0, overlay1, overlay2, overlay3, overlay4, overlay5, overlay6, overlay7, overlay8, overlay9 };
|
||||
Image[] array2 = new Image[4] { icon1, icon2, icon3, icon4 };
|
||||
for (int i = 0; i < array.Length; i++)
|
||||
{
|
||||
if (RectTransformUtility.RectangleContainsScreenPoint(array[i].rectTransform, screenPoint) && array[i].IsActive())
|
||||
{
|
||||
SelectOverlay(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < array2.Length; j++)
|
||||
{
|
||||
if (RectTransformUtility.RectangleContainsScreenPoint(array2[j].rectTransform, screenPoint) && array2[j].IsActive())
|
||||
{
|
||||
SelectIcon(j + 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (RectTransformUtility.RectangleContainsScreenPoint(previewBirdObject.GetComponent<RectTransform>(), screenPoint))
|
||||
{
|
||||
float x = previewBirdObject.transform.localScale.x;
|
||||
previewBirdObject.transform.localScale = new Vector3((x != 1f) ? 1 : (-1), 1f, 1f);
|
||||
}
|
||||
}
|
||||
|
||||
private void SwitchToIcon()
|
||||
{
|
||||
iconSelectionPanel.SetActive(value: true);
|
||||
overlaySelectionPanel.SetActive(value: false);
|
||||
selectionText.text = "Icon selection";
|
||||
placeholderButton.GetComponentInChildren<TMP_Text>().text = "Overlays";
|
||||
}
|
||||
|
||||
private void SwitchToOverlay()
|
||||
{
|
||||
iconSelectionPanel.SetActive(value: false);
|
||||
overlaySelectionPanel.SetActive(value: true);
|
||||
selectionText.text = "Overlay selection";
|
||||
placeholderButton.GetComponentInChildren<TMP_Text>().text = "Icons";
|
||||
}
|
||||
|
||||
private void ToggleKit()
|
||||
{
|
||||
if (GetCurrentKit() == 1)
|
||||
{
|
||||
SwitchToOverlay();
|
||||
}
|
||||
else if (GetCurrentKit() == 2)
|
||||
{
|
||||
SwitchToIcon();
|
||||
}
|
||||
}
|
||||
|
||||
private int GetCurrentKit()
|
||||
{
|
||||
if (iconSelectionPanel.activeSelf)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (overlaySelectionPanel.activeSelf)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private void SelectIcon(int iconID)
|
||||
{
|
||||
PlayerPrefs.SetInt("icon", iconID);
|
||||
Image[] array = new Image[4] { icon1, icon2, icon3, icon4 };
|
||||
Color32 color = new Color32(70, 70, 70, byte.MaxValue);
|
||||
Color32 color2 = new Color32(100, 100, 100, byte.MaxValue);
|
||||
for (int i = 0; i < array.Length; i++)
|
||||
{
|
||||
array[i].color = ((iconID == i + 1) ? color : color2);
|
||||
}
|
||||
previewBird.sprite = Resources.Load<Sprite>("icons/icons/bird_" + iconID);
|
||||
if (iconID == 1)
|
||||
{
|
||||
if (PlayerPrefs.GetInt("userID", 0) == 1)
|
||||
{
|
||||
previewBird.sprite = Resources.Load<Sprite>("icons/icons/bird_-1");
|
||||
}
|
||||
else if (PlayerPrefs.GetInt("userID", 0) == 2)
|
||||
{
|
||||
previewBird.sprite = Resources.Load<Sprite>("icons/icons/bird_-2");
|
||||
}
|
||||
else if (PlayerPrefs.GetInt("userID", 0) == 4)
|
||||
{
|
||||
previewBird.sprite = Resources.Load<Sprite>("icons/icons/bird_-3");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SelectOverlay(int overlayID)
|
||||
{
|
||||
PlayerPrefs.SetInt("overlay", overlayID);
|
||||
Image[] array = new Image[10] { overlay0, overlay1, overlay2, overlay3, overlay4, overlay5, overlay6, overlay7, overlay8, overlay9 };
|
||||
Color32 color = new Color32(70, 70, 70, byte.MaxValue);
|
||||
Color32 color2 = new Color32(100, 100, 100, byte.MaxValue);
|
||||
for (int i = 0; i < array.Length; i++)
|
||||
{
|
||||
array[i].color = ((overlayID == i) ? color : color2);
|
||||
}
|
||||
previewOverlay.rectTransform.localPosition = new Vector3(-19f, 28f, 0f);
|
||||
previewOverlay.gameObject.SetActive(value: true);
|
||||
if (overlayID == 8)
|
||||
{
|
||||
previewOverlay.rectTransform.localPosition = new Vector3(-22f, 20f, 0f);
|
||||
}
|
||||
if (overlayID == 0)
|
||||
{
|
||||
previewOverlay.gameObject.SetActive(value: false);
|
||||
previewOverlay.sprite = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
previewOverlay.sprite = Resources.Load<Sprite>("icons/overlays/overlay_" + overlayID);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1c0f908331fd22e15052178d53af19d8
|
||||
timeCreated: 1754266431
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
externalObjects: {}
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,164 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class Leaderboard : MonoBehaviour
|
||||
{
|
||||
public Canvas canvas;
|
||||
|
||||
public ScrollRect scrollRect;
|
||||
|
||||
public GameObject content;
|
||||
|
||||
public TMP_Dropdown showAmount;
|
||||
|
||||
public TMP_Text statusText;
|
||||
|
||||
public TMP_FontAsset font;
|
||||
|
||||
public Button backButton;
|
||||
|
||||
public Button refreshButton;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
scrollRect.normalizedPosition = new Vector2(0f, 1f);
|
||||
UpdateStatus(enabled: true, "Loading...");
|
||||
StartCoroutine(GetTopPlayers(0));
|
||||
showAmount.onValueChanged.AddListener(delegate(int value)
|
||||
{
|
||||
StartCoroutine(RefreshLeaderboard(value));
|
||||
});
|
||||
backButton.onClick.AddListener(delegate
|
||||
{
|
||||
SceneManager.LoadScene("Menu");
|
||||
});
|
||||
refreshButton.onClick.AddListener(delegate
|
||||
{
|
||||
StartCoroutine(RefreshLeaderboard(showAmount.value));
|
||||
});
|
||||
}
|
||||
|
||||
private IEnumerator RefreshLeaderboard(int value)
|
||||
{
|
||||
int childCount = content.transform.childCount;
|
||||
GameObject[] entries = new GameObject[childCount];
|
||||
for (int i = 0; i < childCount; i++)
|
||||
{
|
||||
entries[i] = content.transform.GetChild(i).gameObject;
|
||||
}
|
||||
yield return StartCoroutine(GetTopPlayers(value));
|
||||
for (int j = 0; j < entries.Length; j++)
|
||||
{
|
||||
UnityEngine.Object.Destroy(entries[j]);
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator GetTopPlayers(int showAmount)
|
||||
{
|
||||
Debug.Log(showAmount);
|
||||
WWWForm wWWForm = new WWWForm();
|
||||
wWWForm.AddField("showAmount", showAmount);
|
||||
using UnityWebRequest request = UnityWebRequest.Post("https://berrydash.xytriza.com/database/getTopPlayers.php", wWWForm);
|
||||
request.SetRequestHeader("User-Agent", "BerryDashClient");
|
||||
request.SetRequestHeader("ClientVersion", PlayerPrefs.GetFloat("clientVersion").ToString());
|
||||
yield return request.SendWebRequest();
|
||||
if (request.result == UnityWebRequest.Result.Success)
|
||||
{
|
||||
UpdateStatus();
|
||||
string text = request.downloadHandler.text;
|
||||
Debug.Log(text);
|
||||
string[] array = text.Split(new char[1] { ':' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
int num = array.Length / 5;
|
||||
float num2 = 40f;
|
||||
float num3 = 10f;
|
||||
float num4 = content.GetComponent<RectTransform>().rect.height / 2f;
|
||||
for (int i = 0; i < num; i++)
|
||||
{
|
||||
GameObject gameObject = new GameObject("Entry_" + i, typeof(RectTransform), typeof(CanvasRenderer));
|
||||
RectTransform component = gameObject.GetComponent<RectTransform>();
|
||||
component.sizeDelta = new Vector2(600f, num2);
|
||||
component.anchoredPosition = new Vector2(0f, num4 - (float)i * (num2 + num3));
|
||||
component.anchorMin = new Vector2(0.5f, 1f);
|
||||
component.anchorMax = new Vector2(0.5f, 1f);
|
||||
component.pivot = new Vector2(0.5f, 1f);
|
||||
GameObject gameObject2 = new GameObject("PlayerName", typeof(RectTransform), typeof(TextMeshProUGUI));
|
||||
GameObject gameObject3 = new GameObject("PlayerIcon", typeof(RectTransform), typeof(Image));
|
||||
GameObject gameObject4 = new GameObject("PlayerIconOverlay", typeof(RectTransform), typeof(Image));
|
||||
GameObject obj = new GameObject("Score", typeof(RectTransform), typeof(TextMeshProUGUI));
|
||||
gameObject2.transform.SetParent(gameObject.transform, worldPositionStays: false);
|
||||
gameObject3.transform.SetParent(gameObject2.transform, worldPositionStays: false);
|
||||
gameObject4.transform.SetParent(gameObject3.transform, worldPositionStays: false);
|
||||
obj.transform.SetParent(gameObject.transform, worldPositionStays: false);
|
||||
Image component2 = gameObject3.GetComponent<Image>();
|
||||
component2.sprite = Resources.Load<Sprite>("icons/icons/bird_" + array[i * 5 + 2]);
|
||||
if (array[i * 5 + 2] == "1")
|
||||
{
|
||||
if (array[i * 5 + 4] == "1")
|
||||
{
|
||||
component2.sprite = Resources.Load<Sprite>("icons/icons/bird_-1");
|
||||
}
|
||||
else if (array[i * 5 + 4] == "2")
|
||||
{
|
||||
component2.sprite = Resources.Load<Sprite>("icons/icons/bird_-2");
|
||||
}
|
||||
else if (array[i * 5 + 4] == "4")
|
||||
{
|
||||
component2.sprite = Resources.Load<Sprite>("icons/icons/bird_-3");
|
||||
}
|
||||
}
|
||||
component2.rectTransform.sizeDelta = new Vector2(30f, 30f);
|
||||
component2.rectTransform.localScale = new Vector3(-1f, 1f, 1f);
|
||||
component2.rectTransform.anchoredPosition = new Vector2(-125f, 0f);
|
||||
Image component3 = gameObject4.GetComponent<Image>();
|
||||
if (array[i * 5 + 3] == "0")
|
||||
{
|
||||
gameObject4.SetActive(value: false);
|
||||
}
|
||||
if (array[i * 5 + 3] == "8")
|
||||
{
|
||||
component3.rectTransform.anchoredPosition = new Vector2(-8.25f, 7.5f);
|
||||
}
|
||||
else
|
||||
{
|
||||
component3.rectTransform.anchoredPosition = new Vector2(-7.125f, 10.5f);
|
||||
}
|
||||
component3.rectTransform.sizeDelta = new Vector2(13.125f, 5.625f);
|
||||
component3.sprite = Resources.Load<Sprite>("icons/overlays/overlay_" + array[i * 5 + 3]);
|
||||
TextMeshProUGUI component4 = gameObject2.GetComponent<TextMeshProUGUI>();
|
||||
component4.text = array[i * 5] + " (#" + (i + 1) + ")";
|
||||
component4.font = font;
|
||||
component4.fontSize = 14f;
|
||||
component4.alignment = TextAlignmentOptions.Left;
|
||||
component4.rectTransform.sizeDelta = new Vector2(200f, 75f);
|
||||
component4.rectTransform.anchoredPosition = new Vector2(-35f, 0f);
|
||||
TextMeshProUGUI component5 = obj.GetComponent<TextMeshProUGUI>();
|
||||
component5.text = "Score: " + array[i * 5 + 1];
|
||||
component5.font = font;
|
||||
component5.fontSize = 14f;
|
||||
component5.alignment = TextAlignmentOptions.Right;
|
||||
component5.rectTransform.sizeDelta = new Vector2(200f, 75f);
|
||||
component5.rectTransform.anchoredPosition = new Vector2(65f, 0f);
|
||||
gameObject.transform.SetParent(content.transform, worldPositionStays: false);
|
||||
}
|
||||
RectTransform component6 = content.GetComponent<RectTransform>();
|
||||
component6.sizeDelta = new Vector2(component6.sizeDelta.x, (float)num * (num2 + num3));
|
||||
yield break;
|
||||
}
|
||||
UpdateStatus(enabled: true, "Failed to fetch leaderboard stats");
|
||||
foreach (Transform item in content.transform)
|
||||
{
|
||||
UnityEngine.Object.Destroy(item.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateStatus(bool enabled = false, string message = "")
|
||||
{
|
||||
statusText.gameObject.SetActive(enabled);
|
||||
statusText.text = message;
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7bf0fa7c1e2acf8488b66523003fe2c0
|
||||
timeCreated: 1754266431
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
externalObjects: {}
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,28 @@
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class Loading : MonoBehaviour
|
||||
{
|
||||
public float clientVersion;
|
||||
|
||||
public TMP_Text statusText;
|
||||
|
||||
public Button updateButton;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
QualitySettings.vSyncCount = PlayerPrefs.GetInt("Setting5", 1);
|
||||
Screen.fullScreen = PlayerPrefs.GetInt("Setting1", 1) == 1;
|
||||
PlayerPrefs.SetFloat("latestVersion", clientVersion);
|
||||
if (!PlayerPrefs.HasKey("iconSelected"))
|
||||
{
|
||||
PlayerPrefs.SetInt("iconSelected", 1);
|
||||
}
|
||||
PlayerPrefs.SetInt("icon", Mathf.Clamp(PlayerPrefs.GetInt("icon", 0), 1, 4));
|
||||
PlayerPrefs.SetInt("overlay", Mathf.Clamp(PlayerPrefs.GetInt("overlay", 0), 0, 9));
|
||||
PlayerPrefs.Save();
|
||||
SceneManager.LoadScene("Menu");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 69c533b9fc572da6997da3d48e0008ca
|
||||
timeCreated: 1754266431
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
externalObjects: {}
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,49 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class Menu : MonoBehaviour
|
||||
{
|
||||
public Button exitBtn;
|
||||
|
||||
public Button playBtn;
|
||||
|
||||
public Button settingsBtn;
|
||||
|
||||
public Button accountBtn;
|
||||
|
||||
public Button leaderboardBtn;
|
||||
|
||||
public Button iconkitButton;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
exitBtn.onClick.AddListener(delegate
|
||||
{
|
||||
Application.Quit();
|
||||
});
|
||||
playBtn.onClick.AddListener(delegate
|
||||
{
|
||||
SceneManager.LoadScene("Game");
|
||||
});
|
||||
settingsBtn.onClick.AddListener(delegate
|
||||
{
|
||||
SceneManager.LoadScene("Settings");
|
||||
});
|
||||
accountBtn.onClick.AddListener(delegate
|
||||
{
|
||||
SceneManager.LoadScene("Account");
|
||||
});
|
||||
leaderboardBtn.onClick.AddListener(delegate
|
||||
{
|
||||
SceneManager.LoadScene("Leaderboard");
|
||||
});
|
||||
iconkitButton.onClick.AddListener(delegate
|
||||
{
|
||||
SceneManager.LoadScene("Iconkit");
|
||||
});
|
||||
PlayerPrefs.SetInt("icon", Mathf.Clamp(PlayerPrefs.GetInt("icon", 0), 1, 4));
|
||||
PlayerPrefs.SetInt("overlay", Mathf.Clamp(PlayerPrefs.GetInt("overlay", 0), 0, 9));
|
||||
PlayerPrefs.Save();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dc09b79a67df8fcda7f0874a698db3c2
|
||||
timeCreated: 1754266431
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
externalObjects: {}
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,52 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class PauseMenu : MonoBehaviour
|
||||
{
|
||||
public GameObject pausePanel;
|
||||
|
||||
public Button menuButton;
|
||||
|
||||
public Button playButton;
|
||||
|
||||
public AudioSource backgroundMusic;
|
||||
|
||||
public Slider musicSlider;
|
||||
|
||||
public Slider sfxSlider;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
menuButton.onClick.AddListener(MenuClick);
|
||||
playButton.onClick.AddListener(TogglePause);
|
||||
musicSlider.onValueChanged.AddListener(UpdateMusicVolume);
|
||||
sfxSlider.onValueChanged.AddListener(UpdateSFXVolume);
|
||||
musicSlider.value = PlayerPrefs.GetFloat("musicVolume", 1f);
|
||||
sfxSlider.value = PlayerPrefs.GetFloat("sfxVolume", 1f);
|
||||
}
|
||||
|
||||
private void TogglePause()
|
||||
{
|
||||
backgroundMusic.Play();
|
||||
pausePanel.SetActive(value: false);
|
||||
}
|
||||
|
||||
private void MenuClick()
|
||||
{
|
||||
SceneManager.LoadScene("Menu");
|
||||
}
|
||||
|
||||
private void UpdateMusicVolume(float volume)
|
||||
{
|
||||
PlayerPrefs.SetFloat("musicVolume", volume);
|
||||
PlayerPrefs.Save();
|
||||
backgroundMusic.volume = volume;
|
||||
}
|
||||
|
||||
private void UpdateSFXVolume(float volume)
|
||||
{
|
||||
PlayerPrefs.SetFloat("sfxVolume", volume);
|
||||
PlayerPrefs.Save();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5dd82d7b197576eb74676050f1d1f2ea
|
||||
timeCreated: 1754266431
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
externalObjects: {}
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
[assembly: AssemblyVersion("0.0.0.0")]
|
||||
@@ -0,0 +1,100 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class Settings : MonoBehaviour
|
||||
{
|
||||
public Toggle setting1toggle;
|
||||
|
||||
public Toggle setting2toggle;
|
||||
|
||||
public Toggle setting3toggle;
|
||||
|
||||
public Toggle setting4toggle;
|
||||
|
||||
public Toggle setting5toggle;
|
||||
|
||||
public Button backbutton;
|
||||
|
||||
public Slider musicSlider;
|
||||
|
||||
public Slider sfxSlider;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
musicSlider.value = PlayerPrefs.GetFloat("musicVolume", 1f);
|
||||
sfxSlider.value = PlayerPrefs.GetFloat("sfxVolume", 1f);
|
||||
setting1toggle.isOn = PlayerPrefs.GetInt("Setting1", 1) == 1;
|
||||
setting2toggle.isOn = PlayerPrefs.GetInt("Setting2", 0) == 1;
|
||||
setting3toggle.isOn = PlayerPrefs.GetInt("Setting3", 0) == 1;
|
||||
setting4toggle.isOn = PlayerPrefs.GetInt("Setting4", 0) == 1;
|
||||
setting5toggle.isOn = PlayerPrefs.GetInt("Setting5", 1) == 1;
|
||||
backbutton.onClick.AddListener(BackButton);
|
||||
setting1toggle.onValueChanged.AddListener(delegate
|
||||
{
|
||||
Setting1ToggleValueChanged(setting1toggle);
|
||||
});
|
||||
setting2toggle.onValueChanged.AddListener(delegate
|
||||
{
|
||||
Setting2ToggleValueChanged(setting2toggle);
|
||||
});
|
||||
setting3toggle.onValueChanged.AddListener(delegate
|
||||
{
|
||||
Setting3ToggleValueChanged(setting3toggle);
|
||||
});
|
||||
setting4toggle.onValueChanged.AddListener(delegate
|
||||
{
|
||||
Setting4ToggleValueChanged(setting4toggle);
|
||||
});
|
||||
setting5toggle.onValueChanged.AddListener(delegate
|
||||
{
|
||||
Setting5ToggleValueChanged(setting5toggle);
|
||||
});
|
||||
musicSlider.onValueChanged.AddListener(UpdateMusicVolume);
|
||||
sfxSlider.onValueChanged.AddListener(UpdateSFXVolume);
|
||||
}
|
||||
|
||||
private void Setting1ToggleValueChanged(Toggle change)
|
||||
{
|
||||
Screen.fullScreen = change.isOn;
|
||||
PlayerPrefs.SetInt("Setting1", change.isOn ? 1 : 0);
|
||||
}
|
||||
|
||||
private void Setting2ToggleValueChanged(Toggle change)
|
||||
{
|
||||
PlayerPrefs.SetInt("Setting2", change.isOn ? 1 : 0);
|
||||
}
|
||||
|
||||
private void Setting3ToggleValueChanged(Toggle change)
|
||||
{
|
||||
PlayerPrefs.SetInt("Setting3", change.isOn ? 1 : 0);
|
||||
}
|
||||
|
||||
private void Setting4ToggleValueChanged(Toggle change)
|
||||
{
|
||||
PlayerPrefs.SetInt("Setting4", change.isOn ? 1 : 0);
|
||||
}
|
||||
|
||||
private void Setting5ToggleValueChanged(Toggle change)
|
||||
{
|
||||
PlayerPrefs.SetInt("Setting5", change.isOn ? 1 : 0);
|
||||
QualitySettings.vSyncCount = (change.isOn ? 1 : 0);
|
||||
}
|
||||
|
||||
private void BackButton()
|
||||
{
|
||||
SceneManager.LoadScene("Menu");
|
||||
}
|
||||
|
||||
private void UpdateMusicVolume(float volume)
|
||||
{
|
||||
PlayerPrefs.SetFloat("musicVolume", volume);
|
||||
PlayerPrefs.Save();
|
||||
}
|
||||
|
||||
private void UpdateSFXVolume(float volume)
|
||||
{
|
||||
PlayerPrefs.SetFloat("sfxVolume", volume);
|
||||
PlayerPrefs.Save();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6c1ac99385ca7ec3a72b980df5396ae9
|
||||
timeCreated: 1754266431
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
externalObjects: {}
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TMPro.Examples
|
||||
{
|
||||
public class Benchmark01 : MonoBehaviour
|
||||
{
|
||||
public int BenchmarkType;
|
||||
|
||||
public TMP_FontAsset TMProFont;
|
||||
|
||||
public Font TextMeshFont;
|
||||
|
||||
private TextMeshPro m_textMeshPro;
|
||||
|
||||
private TextContainer m_textContainer;
|
||||
|
||||
private TextMesh m_textMesh;
|
||||
|
||||
private const string label01 = "The <#0050FF>count is: </color>{0}";
|
||||
|
||||
private const string label02 = "The <color=#0050FF>count is: </color>";
|
||||
|
||||
private Material m_material01;
|
||||
|
||||
private Material m_material02;
|
||||
|
||||
private IEnumerator Start()
|
||||
{
|
||||
if (BenchmarkType == 0)
|
||||
{
|
||||
m_textMeshPro = base.gameObject.AddComponent<TextMeshPro>();
|
||||
m_textMeshPro.autoSizeTextContainer = true;
|
||||
if (TMProFont != null)
|
||||
{
|
||||
m_textMeshPro.font = TMProFont;
|
||||
}
|
||||
m_textMeshPro.fontSize = 48f;
|
||||
m_textMeshPro.alignment = TextAlignmentOptions.Center;
|
||||
m_textMeshPro.extraPadding = true;
|
||||
m_textMeshPro.enableWordWrapping = false;
|
||||
m_material01 = m_textMeshPro.font.material;
|
||||
m_material02 = Resources.Load<Material>("Fonts & Materials/LiberationSans SDF - Drop Shadow");
|
||||
}
|
||||
else if (BenchmarkType == 1)
|
||||
{
|
||||
m_textMesh = base.gameObject.AddComponent<TextMesh>();
|
||||
if (TextMeshFont != null)
|
||||
{
|
||||
m_textMesh.font = TextMeshFont;
|
||||
m_textMesh.GetComponent<Renderer>().sharedMaterial = m_textMesh.font.material;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_textMesh.font = Resources.Load("Fonts/ARIAL", typeof(Font)) as Font;
|
||||
m_textMesh.GetComponent<Renderer>().sharedMaterial = m_textMesh.font.material;
|
||||
}
|
||||
m_textMesh.fontSize = 48;
|
||||
m_textMesh.anchor = TextAnchor.MiddleCenter;
|
||||
}
|
||||
for (int i = 0; i <= 1000000; i++)
|
||||
{
|
||||
if (BenchmarkType == 0)
|
||||
{
|
||||
m_textMeshPro.SetText("The <#0050FF>count is: </color>{0}", i % 1000);
|
||||
if (i % 1000 == 999)
|
||||
{
|
||||
TextMeshPro textMeshPro = m_textMeshPro;
|
||||
Material fontSharedMaterial;
|
||||
if (!(m_textMeshPro.fontSharedMaterial == m_material01))
|
||||
{
|
||||
Material material = (m_textMeshPro.fontSharedMaterial = m_material01);
|
||||
fontSharedMaterial = material;
|
||||
}
|
||||
else
|
||||
{
|
||||
Material material = (m_textMeshPro.fontSharedMaterial = m_material02);
|
||||
fontSharedMaterial = material;
|
||||
}
|
||||
textMeshPro.fontSharedMaterial = fontSharedMaterial;
|
||||
}
|
||||
}
|
||||
else if (BenchmarkType == 1)
|
||||
{
|
||||
m_textMesh.text = "The <color=#0050FF>count is: </color>" + i % 1000;
|
||||
}
|
||||
yield return null;
|
||||
}
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2dce2f3a66b559d26c4169ce420c9935
|
||||
timeCreated: 1754266431
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
externalObjects: {}
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace TMPro.Examples
|
||||
{
|
||||
public class Benchmark01_UGUI : MonoBehaviour
|
||||
{
|
||||
public int BenchmarkType;
|
||||
|
||||
public Canvas canvas;
|
||||
|
||||
public TMP_FontAsset TMProFont;
|
||||
|
||||
public Font TextMeshFont;
|
||||
|
||||
private TextMeshProUGUI m_textMeshPro;
|
||||
|
||||
private Text m_textMesh;
|
||||
|
||||
private const string label01 = "The <#0050FF>count is: </color>";
|
||||
|
||||
private const string label02 = "The <color=#0050FF>count is: </color>";
|
||||
|
||||
private Material m_material01;
|
||||
|
||||
private Material m_material02;
|
||||
|
||||
private IEnumerator Start()
|
||||
{
|
||||
if (BenchmarkType == 0)
|
||||
{
|
||||
m_textMeshPro = base.gameObject.AddComponent<TextMeshProUGUI>();
|
||||
if (TMProFont != null)
|
||||
{
|
||||
m_textMeshPro.font = TMProFont;
|
||||
}
|
||||
m_textMeshPro.fontSize = 48f;
|
||||
m_textMeshPro.alignment = TextAlignmentOptions.Center;
|
||||
m_textMeshPro.extraPadding = true;
|
||||
m_material01 = m_textMeshPro.font.material;
|
||||
m_material02 = Resources.Load<Material>("Fonts & Materials/LiberationSans SDF - BEVEL");
|
||||
}
|
||||
else if (BenchmarkType == 1)
|
||||
{
|
||||
m_textMesh = base.gameObject.AddComponent<Text>();
|
||||
if (TextMeshFont != null)
|
||||
{
|
||||
m_textMesh.font = TextMeshFont;
|
||||
}
|
||||
m_textMesh.fontSize = 48;
|
||||
m_textMesh.alignment = TextAnchor.MiddleCenter;
|
||||
}
|
||||
for (int i = 0; i <= 1000000; i++)
|
||||
{
|
||||
if (BenchmarkType == 0)
|
||||
{
|
||||
m_textMeshPro.text = "The <#0050FF>count is: </color>" + i % 1000;
|
||||
if (i % 1000 == 999)
|
||||
{
|
||||
TextMeshProUGUI textMeshPro = m_textMeshPro;
|
||||
Material fontSharedMaterial;
|
||||
if (!(m_textMeshPro.fontSharedMaterial == m_material01))
|
||||
{
|
||||
Material material = (m_textMeshPro.fontSharedMaterial = m_material01);
|
||||
fontSharedMaterial = material;
|
||||
}
|
||||
else
|
||||
{
|
||||
Material material = (m_textMeshPro.fontSharedMaterial = m_material02);
|
||||
fontSharedMaterial = material;
|
||||
}
|
||||
textMeshPro.fontSharedMaterial = fontSharedMaterial;
|
||||
}
|
||||
}
|
||||
else if (BenchmarkType == 1)
|
||||
{
|
||||
m_textMesh.text = "The <color=#0050FF>count is: </color>" + i % 1000;
|
||||
}
|
||||
yield return null;
|
||||
}
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d3e6497e5acfd415838b7f55dfda96f0
|
||||
timeCreated: 1754266431
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
externalObjects: {}
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace TMPro.Examples
|
||||
{
|
||||
public class Benchmark02 : MonoBehaviour
|
||||
{
|
||||
public int SpawnType;
|
||||
|
||||
public int NumberOfNPC = 12;
|
||||
|
||||
public bool IsTextObjectScaleStatic;
|
||||
|
||||
private TextMeshProFloatingText floatingText_Script;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
for (int i = 0; i < NumberOfNPC; i++)
|
||||
{
|
||||
if (SpawnType == 0)
|
||||
{
|
||||
GameObject gameObject = new GameObject();
|
||||
gameObject.transform.position = new Vector3(Random.Range(-95f, 95f), 0.25f, Random.Range(-95f, 95f));
|
||||
TextMeshPro textMeshPro = gameObject.AddComponent<TextMeshPro>();
|
||||
textMeshPro.autoSizeTextContainer = true;
|
||||
textMeshPro.rectTransform.pivot = new Vector2(0.5f, 0f);
|
||||
textMeshPro.alignment = TextAlignmentOptions.Bottom;
|
||||
textMeshPro.fontSize = 96f;
|
||||
textMeshPro.enableKerning = false;
|
||||
textMeshPro.color = new Color32(byte.MaxValue, byte.MaxValue, 0, byte.MaxValue);
|
||||
textMeshPro.text = "!";
|
||||
textMeshPro.isTextObjectScaleStatic = IsTextObjectScaleStatic;
|
||||
floatingText_Script = gameObject.AddComponent<TextMeshProFloatingText>();
|
||||
floatingText_Script.SpawnType = 0;
|
||||
floatingText_Script.IsTextObjectScaleStatic = IsTextObjectScaleStatic;
|
||||
}
|
||||
else if (SpawnType == 1)
|
||||
{
|
||||
GameObject gameObject2 = new GameObject();
|
||||
gameObject2.transform.position = new Vector3(Random.Range(-95f, 95f), 0.25f, Random.Range(-95f, 95f));
|
||||
TextMesh textMesh = gameObject2.AddComponent<TextMesh>();
|
||||
textMesh.font = Resources.Load<Font>("Fonts/ARIAL");
|
||||
textMesh.GetComponent<Renderer>().sharedMaterial = textMesh.font.material;
|
||||
textMesh.anchor = TextAnchor.LowerCenter;
|
||||
textMesh.fontSize = 96;
|
||||
textMesh.color = new Color32(byte.MaxValue, byte.MaxValue, 0, byte.MaxValue);
|
||||
textMesh.text = "!";
|
||||
floatingText_Script = gameObject2.AddComponent<TextMeshProFloatingText>();
|
||||
floatingText_Script.SpawnType = 1;
|
||||
}
|
||||
else if (SpawnType == 2)
|
||||
{
|
||||
GameObject gameObject3 = new GameObject();
|
||||
gameObject3.AddComponent<Canvas>().worldCamera = Camera.main;
|
||||
gameObject3.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);
|
||||
gameObject3.transform.position = new Vector3(Random.Range(-95f, 95f), 5f, Random.Range(-95f, 95f));
|
||||
TextMeshProUGUI textMeshProUGUI = new GameObject().AddComponent<TextMeshProUGUI>();
|
||||
textMeshProUGUI.rectTransform.SetParent(gameObject3.transform, worldPositionStays: false);
|
||||
textMeshProUGUI.color = new Color32(byte.MaxValue, byte.MaxValue, 0, byte.MaxValue);
|
||||
textMeshProUGUI.alignment = TextAlignmentOptions.Bottom;
|
||||
textMeshProUGUI.fontSize = 96f;
|
||||
textMeshProUGUI.text = "!";
|
||||
floatingText_Script = gameObject3.AddComponent<TextMeshProFloatingText>();
|
||||
floatingText_Script.SpawnType = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ff0fb97368bda127693108d5e4753dc4
|
||||
timeCreated: 1754266431
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
externalObjects: {}
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.TextCore.LowLevel;
|
||||
|
||||
namespace TMPro.Examples
|
||||
{
|
||||
public class Benchmark03 : MonoBehaviour
|
||||
{
|
||||
public enum BenchmarkType
|
||||
{
|
||||
TMP_SDF_MOBILE = 0,
|
||||
TMP_SDF__MOBILE_SSD = 1,
|
||||
TMP_SDF = 2,
|
||||
TMP_BITMAP_MOBILE = 3,
|
||||
TEXTMESH_BITMAP = 4
|
||||
}
|
||||
|
||||
public int NumberOfSamples = 100;
|
||||
|
||||
public BenchmarkType Benchmark;
|
||||
|
||||
public Font SourceFont;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
TMP_FontAsset tMP_FontAsset = null;
|
||||
switch (Benchmark)
|
||||
{
|
||||
case BenchmarkType.TMP_SDF_MOBILE:
|
||||
tMP_FontAsset = TMP_FontAsset.CreateFontAsset(SourceFont, 90, 9, GlyphRenderMode.SDFAA, 256, 256);
|
||||
break;
|
||||
case BenchmarkType.TMP_SDF__MOBILE_SSD:
|
||||
tMP_FontAsset = TMP_FontAsset.CreateFontAsset(SourceFont, 90, 9, GlyphRenderMode.SDFAA, 256, 256);
|
||||
tMP_FontAsset.material.shader = Shader.Find("TextMeshPro/Mobile/Distance Field SSD");
|
||||
break;
|
||||
case BenchmarkType.TMP_SDF:
|
||||
tMP_FontAsset = TMP_FontAsset.CreateFontAsset(SourceFont, 90, 9, GlyphRenderMode.SDFAA, 256, 256);
|
||||
tMP_FontAsset.material.shader = Shader.Find("TextMeshPro/Distance Field");
|
||||
break;
|
||||
case BenchmarkType.TMP_BITMAP_MOBILE:
|
||||
tMP_FontAsset = TMP_FontAsset.CreateFontAsset(SourceFont, 90, 9, GlyphRenderMode.SMOOTH, 256, 256);
|
||||
break;
|
||||
}
|
||||
for (int i = 0; i < NumberOfSamples; i++)
|
||||
{
|
||||
switch (Benchmark)
|
||||
{
|
||||
case BenchmarkType.TMP_SDF_MOBILE:
|
||||
case BenchmarkType.TMP_SDF__MOBILE_SSD:
|
||||
case BenchmarkType.TMP_SDF:
|
||||
case BenchmarkType.TMP_BITMAP_MOBILE:
|
||||
{
|
||||
GameObject obj2 = new GameObject();
|
||||
obj2.transform.position = new Vector3(0f, 1.2f, 0f);
|
||||
TextMeshPro textMeshPro = obj2.AddComponent<TextMeshPro>();
|
||||
textMeshPro.font = tMP_FontAsset;
|
||||
textMeshPro.fontSize = 128f;
|
||||
textMeshPro.text = "@";
|
||||
textMeshPro.alignment = TextAlignmentOptions.Center;
|
||||
textMeshPro.color = new Color32(byte.MaxValue, byte.MaxValue, 0, byte.MaxValue);
|
||||
if (Benchmark == BenchmarkType.TMP_BITMAP_MOBILE)
|
||||
{
|
||||
textMeshPro.fontSize = 132f;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BenchmarkType.TEXTMESH_BITMAP:
|
||||
{
|
||||
GameObject obj = new GameObject();
|
||||
obj.transform.position = new Vector3(0f, 1.2f, 0f);
|
||||
TextMesh textMesh = obj.AddComponent<TextMesh>();
|
||||
textMesh.GetComponent<Renderer>().sharedMaterial = SourceFont.material;
|
||||
textMesh.font = SourceFont;
|
||||
textMesh.anchor = TextAnchor.MiddleCenter;
|
||||
textMesh.fontSize = 130;
|
||||
textMesh.color = new Color32(byte.MaxValue, byte.MaxValue, 0, byte.MaxValue);
|
||||
textMesh.text = "@";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 25b8c11b3f2b345300d242fc9b0545f1
|
||||
timeCreated: 1754266431
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
externalObjects: {}
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace TMPro.Examples
|
||||
{
|
||||
public class Benchmark04 : MonoBehaviour
|
||||
{
|
||||
public int SpawnType;
|
||||
|
||||
public int MinPointSize = 12;
|
||||
|
||||
public int MaxPointSize = 64;
|
||||
|
||||
public int Steps = 4;
|
||||
|
||||
private Transform m_Transform;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
m_Transform = base.transform;
|
||||
float num = 0f;
|
||||
float num2 = (Camera.main.orthographicSize = Screen.height / 2);
|
||||
float num4 = num2;
|
||||
float num5 = (float)Screen.width / (float)Screen.height;
|
||||
for (int i = MinPointSize; i <= MaxPointSize; i += Steps)
|
||||
{
|
||||
if (SpawnType == 0)
|
||||
{
|
||||
GameObject gameObject = new GameObject("Text - " + i + " Pts");
|
||||
if (num > num4 * 2f)
|
||||
{
|
||||
break;
|
||||
}
|
||||
gameObject.transform.position = m_Transform.position + new Vector3(num5 * (0f - num4) * 0.975f, num4 * 0.975f - num, 0f);
|
||||
TextMeshPro textMeshPro = gameObject.AddComponent<TextMeshPro>();
|
||||
textMeshPro.rectTransform.pivot = new Vector2(0f, 0.5f);
|
||||
textMeshPro.enableWordWrapping = false;
|
||||
textMeshPro.extraPadding = true;
|
||||
textMeshPro.isOrthographic = true;
|
||||
textMeshPro.fontSize = i;
|
||||
textMeshPro.text = i + " pts - Lorem ipsum dolor sit...";
|
||||
textMeshPro.color = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue);
|
||||
num += (float)i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6d7b6d2813f1e8bd2fab94941f6982c1
|
||||
timeCreated: 1754266431
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
externalObjects: {}
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+246
@@ -0,0 +1,246 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace TMPro.Examples
|
||||
{
|
||||
public class CameraController : MonoBehaviour
|
||||
{
|
||||
public enum CameraModes
|
||||
{
|
||||
Follow = 0,
|
||||
Isometric = 1,
|
||||
Free = 2
|
||||
}
|
||||
|
||||
private Transform cameraTransform;
|
||||
|
||||
private Transform dummyTarget;
|
||||
|
||||
public Transform CameraTarget;
|
||||
|
||||
public float FollowDistance = 30f;
|
||||
|
||||
public float MaxFollowDistance = 100f;
|
||||
|
||||
public float MinFollowDistance = 2f;
|
||||
|
||||
public float ElevationAngle = 30f;
|
||||
|
||||
public float MaxElevationAngle = 85f;
|
||||
|
||||
public float MinElevationAngle;
|
||||
|
||||
public float OrbitalAngle;
|
||||
|
||||
public CameraModes CameraMode;
|
||||
|
||||
public bool MovementSmoothing = true;
|
||||
|
||||
public bool RotationSmoothing;
|
||||
|
||||
private bool previousSmoothing;
|
||||
|
||||
public float MovementSmoothingValue = 25f;
|
||||
|
||||
public float RotationSmoothingValue = 5f;
|
||||
|
||||
public float MoveSensitivity = 2f;
|
||||
|
||||
private Vector3 currentVelocity = Vector3.zero;
|
||||
|
||||
private Vector3 desiredPosition;
|
||||
|
||||
private float mouseX;
|
||||
|
||||
private float mouseY;
|
||||
|
||||
private Vector3 moveVector;
|
||||
|
||||
private float mouseWheel;
|
||||
|
||||
private const string event_SmoothingValue = "Slider - Smoothing Value";
|
||||
|
||||
private const string event_FollowDistance = "Slider - Camera Zoom";
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (QualitySettings.vSyncCount > 0)
|
||||
{
|
||||
Application.targetFrameRate = 60;
|
||||
}
|
||||
else
|
||||
{
|
||||
Application.targetFrameRate = -1;
|
||||
}
|
||||
if (Application.platform == RuntimePlatform.IPhonePlayer || Application.platform == RuntimePlatform.Android)
|
||||
{
|
||||
Input.simulateMouseWithTouches = false;
|
||||
}
|
||||
cameraTransform = base.transform;
|
||||
previousSmoothing = MovementSmoothing;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
if (CameraTarget == null)
|
||||
{
|
||||
dummyTarget = new GameObject("Camera Target").transform;
|
||||
CameraTarget = dummyTarget;
|
||||
}
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
GetPlayerInput();
|
||||
if (CameraTarget != null)
|
||||
{
|
||||
if (CameraMode == CameraModes.Isometric)
|
||||
{
|
||||
desiredPosition = CameraTarget.position + Quaternion.Euler(ElevationAngle, OrbitalAngle, 0f) * new Vector3(0f, 0f, 0f - FollowDistance);
|
||||
}
|
||||
else if (CameraMode == CameraModes.Follow)
|
||||
{
|
||||
desiredPosition = CameraTarget.position + CameraTarget.TransformDirection(Quaternion.Euler(ElevationAngle, OrbitalAngle, 0f) * new Vector3(0f, 0f, 0f - FollowDistance));
|
||||
}
|
||||
if (MovementSmoothing)
|
||||
{
|
||||
cameraTransform.position = Vector3.SmoothDamp(cameraTransform.position, desiredPosition, ref currentVelocity, MovementSmoothingValue * Time.fixedDeltaTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
cameraTransform.position = desiredPosition;
|
||||
}
|
||||
if (RotationSmoothing)
|
||||
{
|
||||
cameraTransform.rotation = Quaternion.Lerp(cameraTransform.rotation, Quaternion.LookRotation(CameraTarget.position - cameraTransform.position), RotationSmoothingValue * Time.deltaTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
cameraTransform.LookAt(CameraTarget);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void GetPlayerInput()
|
||||
{
|
||||
moveVector = Vector3.zero;
|
||||
mouseWheel = Input.GetAxis("Mouse ScrollWheel");
|
||||
float num = Input.touchCount;
|
||||
if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift) || num > 0f)
|
||||
{
|
||||
mouseWheel *= 10f;
|
||||
if (Input.GetKeyDown(KeyCode.I))
|
||||
{
|
||||
CameraMode = CameraModes.Isometric;
|
||||
}
|
||||
if (Input.GetKeyDown(KeyCode.F))
|
||||
{
|
||||
CameraMode = CameraModes.Follow;
|
||||
}
|
||||
if (Input.GetKeyDown(KeyCode.S))
|
||||
{
|
||||
MovementSmoothing = !MovementSmoothing;
|
||||
}
|
||||
if (Input.GetMouseButton(1))
|
||||
{
|
||||
mouseY = Input.GetAxis("Mouse Y");
|
||||
mouseX = Input.GetAxis("Mouse X");
|
||||
if (mouseY > 0.01f || mouseY < -0.01f)
|
||||
{
|
||||
ElevationAngle -= mouseY * MoveSensitivity;
|
||||
ElevationAngle = Mathf.Clamp(ElevationAngle, MinElevationAngle, MaxElevationAngle);
|
||||
}
|
||||
if (mouseX > 0.01f || mouseX < -0.01f)
|
||||
{
|
||||
OrbitalAngle += mouseX * MoveSensitivity;
|
||||
if (OrbitalAngle > 360f)
|
||||
{
|
||||
OrbitalAngle -= 360f;
|
||||
}
|
||||
if (OrbitalAngle < 0f)
|
||||
{
|
||||
OrbitalAngle += 360f;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (num == 1f && Input.GetTouch(0).phase == TouchPhase.Moved)
|
||||
{
|
||||
Vector2 deltaPosition = Input.GetTouch(0).deltaPosition;
|
||||
if (deltaPosition.y > 0.01f || deltaPosition.y < -0.01f)
|
||||
{
|
||||
ElevationAngle -= deltaPosition.y * 0.1f;
|
||||
ElevationAngle = Mathf.Clamp(ElevationAngle, MinElevationAngle, MaxElevationAngle);
|
||||
}
|
||||
if (deltaPosition.x > 0.01f || deltaPosition.x < -0.01f)
|
||||
{
|
||||
OrbitalAngle += deltaPosition.x * 0.1f;
|
||||
if (OrbitalAngle > 360f)
|
||||
{
|
||||
OrbitalAngle -= 360f;
|
||||
}
|
||||
if (OrbitalAngle < 0f)
|
||||
{
|
||||
OrbitalAngle += 360f;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Input.GetMouseButton(0) && Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out var hitInfo, 300f, 23552))
|
||||
{
|
||||
if (hitInfo.transform == CameraTarget)
|
||||
{
|
||||
OrbitalAngle = 0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
CameraTarget = hitInfo.transform;
|
||||
OrbitalAngle = 0f;
|
||||
MovementSmoothing = previousSmoothing;
|
||||
}
|
||||
}
|
||||
if (Input.GetMouseButton(2))
|
||||
{
|
||||
if (dummyTarget == null)
|
||||
{
|
||||
dummyTarget = new GameObject("Camera Target").transform;
|
||||
dummyTarget.position = CameraTarget.position;
|
||||
dummyTarget.rotation = CameraTarget.rotation;
|
||||
CameraTarget = dummyTarget;
|
||||
previousSmoothing = MovementSmoothing;
|
||||
MovementSmoothing = false;
|
||||
}
|
||||
else if (dummyTarget != CameraTarget)
|
||||
{
|
||||
dummyTarget.position = CameraTarget.position;
|
||||
dummyTarget.rotation = CameraTarget.rotation;
|
||||
CameraTarget = dummyTarget;
|
||||
previousSmoothing = MovementSmoothing;
|
||||
MovementSmoothing = false;
|
||||
}
|
||||
mouseY = Input.GetAxis("Mouse Y");
|
||||
mouseX = Input.GetAxis("Mouse X");
|
||||
moveVector = cameraTransform.TransformDirection(mouseX, mouseY, 0f);
|
||||
dummyTarget.Translate(-moveVector, Space.World);
|
||||
}
|
||||
}
|
||||
if (num == 2f)
|
||||
{
|
||||
Touch touch = Input.GetTouch(0);
|
||||
Touch touch2 = Input.GetTouch(1);
|
||||
Vector2 vector = touch.position - touch.deltaPosition;
|
||||
Vector2 vector2 = touch2.position - touch2.deltaPosition;
|
||||
float magnitude = (vector - vector2).magnitude;
|
||||
float magnitude2 = (touch.position - touch2.position).magnitude;
|
||||
float num2 = magnitude - magnitude2;
|
||||
if (num2 > 0.01f || num2 < -0.01f)
|
||||
{
|
||||
FollowDistance += num2 * 0.25f;
|
||||
FollowDistance = Mathf.Clamp(FollowDistance, MinFollowDistance, MaxFollowDistance);
|
||||
}
|
||||
}
|
||||
if (mouseWheel < -0.01f || mouseWheel > 0.01f)
|
||||
{
|
||||
FollowDistance -= mouseWheel * 5f;
|
||||
FollowDistance = Mathf.Clamp(FollowDistance, MinFollowDistance, MaxFollowDistance);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bbe7700f9732df029498b31ad05eb0f1
|
||||
timeCreated: 1754266431
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
externalObjects: {}
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace TMPro.Examples
|
||||
{
|
||||
public class ObjectSpin : MonoBehaviour
|
||||
{
|
||||
public enum MotionType
|
||||
{
|
||||
Rotation = 0,
|
||||
BackAndForth = 1,
|
||||
Translation = 2
|
||||
}
|
||||
|
||||
public float SpinSpeed = 5f;
|
||||
|
||||
public int RotationRange = 15;
|
||||
|
||||
private Transform m_transform;
|
||||
|
||||
private float m_time;
|
||||
|
||||
private Vector3 m_prevPOS;
|
||||
|
||||
private Vector3 m_initial_Rotation;
|
||||
|
||||
private Vector3 m_initial_Position;
|
||||
|
||||
private Color32 m_lightColor;
|
||||
|
||||
private int frames;
|
||||
|
||||
public MotionType Motion;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
m_transform = base.transform;
|
||||
m_initial_Rotation = m_transform.rotation.eulerAngles;
|
||||
m_initial_Position = m_transform.position;
|
||||
Light component = GetComponent<Light>();
|
||||
m_lightColor = ((component != null) ? component.color : Color.black);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Motion == MotionType.Rotation)
|
||||
{
|
||||
m_transform.Rotate(0f, SpinSpeed * Time.deltaTime, 0f);
|
||||
return;
|
||||
}
|
||||
if (Motion == MotionType.BackAndForth)
|
||||
{
|
||||
m_time += SpinSpeed * Time.deltaTime;
|
||||
m_transform.rotation = Quaternion.Euler(m_initial_Rotation.x, Mathf.Sin(m_time) * (float)RotationRange + m_initial_Rotation.y, m_initial_Rotation.z);
|
||||
return;
|
||||
}
|
||||
m_time += SpinSpeed * Time.deltaTime;
|
||||
float x = 15f * Mathf.Cos(m_time * 0.95f);
|
||||
float z = 10f;
|
||||
float y = 0f;
|
||||
m_transform.position = m_initial_Position + new Vector3(x, y, z);
|
||||
m_prevPOS = m_transform.position;
|
||||
frames++;
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d61f3dbe903e9fadcfb368280226c814
|
||||
timeCreated: 1754266431
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
externalObjects: {}
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TMPro.Examples
|
||||
{
|
||||
public class ShaderPropAnimator : MonoBehaviour
|
||||
{
|
||||
private Renderer m_Renderer;
|
||||
|
||||
private Material m_Material;
|
||||
|
||||
public AnimationCurve GlowCurve;
|
||||
|
||||
public float m_frame;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
m_Renderer = GetComponent<Renderer>();
|
||||
m_Material = m_Renderer.material;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
StartCoroutine(AnimateProperties());
|
||||
}
|
||||
|
||||
private IEnumerator AnimateProperties()
|
||||
{
|
||||
m_frame = Random.Range(0f, 1f);
|
||||
while (true)
|
||||
{
|
||||
float value = GlowCurve.Evaluate(m_frame);
|
||||
m_Material.SetFloat(ShaderUtilities.ID_GlowPower, value);
|
||||
m_frame += Time.deltaTime * Random.Range(0.2f, 0.3f);
|
||||
yield return new WaitForEndOfFrame();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0b7b7b79e67a79cfd7d8014563f62eee
|
||||
timeCreated: 1754266431
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
externalObjects: {}
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace TMPro.Examples
|
||||
{
|
||||
public class SimpleScript : MonoBehaviour
|
||||
{
|
||||
private TextMeshPro m_textMeshPro;
|
||||
|
||||
private const string label = "The <#0050FF>count is: </color>{0:2}";
|
||||
|
||||
private float m_frame;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
m_textMeshPro = base.gameObject.AddComponent<TextMeshPro>();
|
||||
m_textMeshPro.autoSizeTextContainer = true;
|
||||
m_textMeshPro.fontSize = 48f;
|
||||
m_textMeshPro.alignment = TextAlignmentOptions.Center;
|
||||
m_textMeshPro.enableWordWrapping = false;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
m_textMeshPro.SetText("The <#0050FF>count is: </color>{0:2}", m_frame % 1000f);
|
||||
m_frame += 1f * Time.deltaTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fb7abe824271dea330088875fb7e3850
|
||||
timeCreated: 1754266431
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
externalObjects: {}
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+105
@@ -0,0 +1,105 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TMPro.Examples
|
||||
{
|
||||
public class SkewTextExample : MonoBehaviour
|
||||
{
|
||||
private TMP_Text m_TextComponent;
|
||||
|
||||
public AnimationCurve VertexCurve = new AnimationCurve(new Keyframe(0f, 0f), new Keyframe(0.25f, 2f), new Keyframe(0.5f, 0f), new Keyframe(0.75f, 2f), new Keyframe(1f, 0f));
|
||||
|
||||
public float CurveScale = 1f;
|
||||
|
||||
public float ShearAmount = 1f;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
m_TextComponent = base.gameObject.GetComponent<TMP_Text>();
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
StartCoroutine(WarpText());
|
||||
}
|
||||
|
||||
private AnimationCurve CopyAnimationCurve(AnimationCurve curve)
|
||||
{
|
||||
return new AnimationCurve
|
||||
{
|
||||
keys = curve.keys
|
||||
};
|
||||
}
|
||||
|
||||
private IEnumerator WarpText()
|
||||
{
|
||||
VertexCurve.preWrapMode = WrapMode.Once;
|
||||
VertexCurve.postWrapMode = WrapMode.Once;
|
||||
m_TextComponent.havePropertiesChanged = true;
|
||||
CurveScale *= 10f;
|
||||
float old_CurveScale = CurveScale;
|
||||
float old_ShearValue = ShearAmount;
|
||||
AnimationCurve old_curve = CopyAnimationCurve(VertexCurve);
|
||||
while (true)
|
||||
{
|
||||
if (!m_TextComponent.havePropertiesChanged && old_CurveScale == CurveScale && old_curve.keys[1].value == VertexCurve.keys[1].value && old_ShearValue == ShearAmount)
|
||||
{
|
||||
yield return null;
|
||||
continue;
|
||||
}
|
||||
old_CurveScale = CurveScale;
|
||||
old_curve = CopyAnimationCurve(VertexCurve);
|
||||
old_ShearValue = ShearAmount;
|
||||
m_TextComponent.ForceMeshUpdate();
|
||||
TMP_TextInfo textInfo = m_TextComponent.textInfo;
|
||||
int characterCount = textInfo.characterCount;
|
||||
if (characterCount == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
float x = m_TextComponent.bounds.min.x;
|
||||
float x2 = m_TextComponent.bounds.max.x;
|
||||
for (int i = 0; i < characterCount; i++)
|
||||
{
|
||||
if (textInfo.characterInfo[i].isVisible)
|
||||
{
|
||||
int vertexIndex = textInfo.characterInfo[i].vertexIndex;
|
||||
int materialReferenceIndex = textInfo.characterInfo[i].materialReferenceIndex;
|
||||
Vector3[] vertices = textInfo.meshInfo[materialReferenceIndex].vertices;
|
||||
Vector3 vector = new Vector2((vertices[vertexIndex].x + vertices[vertexIndex + 2].x) / 2f, textInfo.characterInfo[i].baseLine);
|
||||
vertices[vertexIndex] += -vector;
|
||||
vertices[vertexIndex + 1] += -vector;
|
||||
vertices[vertexIndex + 2] += -vector;
|
||||
vertices[vertexIndex + 3] += -vector;
|
||||
float num = ShearAmount * 0.01f;
|
||||
Vector3 vector2 = new Vector3(num * (textInfo.characterInfo[i].topRight.y - textInfo.characterInfo[i].baseLine), 0f, 0f);
|
||||
Vector3 vector3 = new Vector3(num * (textInfo.characterInfo[i].baseLine - textInfo.characterInfo[i].bottomRight.y), 0f, 0f);
|
||||
vertices[vertexIndex] += -vector3;
|
||||
vertices[vertexIndex + 1] += vector2;
|
||||
vertices[vertexIndex + 2] += vector2;
|
||||
vertices[vertexIndex + 3] += -vector3;
|
||||
float num2 = (vector.x - x) / (x2 - x);
|
||||
float num3 = num2 + 0.0001f;
|
||||
float y = VertexCurve.Evaluate(num2) * CurveScale;
|
||||
float y2 = VertexCurve.Evaluate(num3) * CurveScale;
|
||||
Vector3 lhs = new Vector3(1f, 0f, 0f);
|
||||
Vector3 rhs = new Vector3(num3 * (x2 - x) + x, y2) - new Vector3(vector.x, y);
|
||||
float num4 = Mathf.Acos(Vector3.Dot(lhs, rhs.normalized)) * 57.29578f;
|
||||
float z = ((Vector3.Cross(lhs, rhs).z > 0f) ? num4 : (360f - num4));
|
||||
Matrix4x4 matrix4x = Matrix4x4.TRS(new Vector3(0f, y, 0f), Quaternion.Euler(0f, 0f, z), Vector3.one);
|
||||
vertices[vertexIndex] = matrix4x.MultiplyPoint3x4(vertices[vertexIndex]);
|
||||
vertices[vertexIndex + 1] = matrix4x.MultiplyPoint3x4(vertices[vertexIndex + 1]);
|
||||
vertices[vertexIndex + 2] = matrix4x.MultiplyPoint3x4(vertices[vertexIndex + 2]);
|
||||
vertices[vertexIndex + 3] = matrix4x.MultiplyPoint3x4(vertices[vertexIndex + 3]);
|
||||
vertices[vertexIndex] += vector;
|
||||
vertices[vertexIndex + 1] += vector;
|
||||
vertices[vertexIndex + 2] += vector;
|
||||
vertices[vertexIndex + 3] += vector;
|
||||
}
|
||||
}
|
||||
m_TextComponent.UpdateVertexData();
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7cc2fd07ebef5ee2dc3238fe38524d59
|
||||
timeCreated: 1754266431
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
externalObjects: {}
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace TMPro.Examples
|
||||
{
|
||||
public class TMP_ExampleScript_01 : MonoBehaviour
|
||||
{
|
||||
public enum objectType
|
||||
{
|
||||
TextMeshPro = 0,
|
||||
TextMeshProUGUI = 1
|
||||
}
|
||||
|
||||
public objectType ObjectType;
|
||||
|
||||
public bool isStatic;
|
||||
|
||||
private TMP_Text m_text;
|
||||
|
||||
private const string k_label = "The count is <#0080ff>{0}</color>";
|
||||
|
||||
private int count;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (ObjectType == objectType.TextMeshPro)
|
||||
{
|
||||
m_text = GetComponent<TextMeshPro>() ?? base.gameObject.AddComponent<TextMeshPro>();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_text = GetComponent<TextMeshProUGUI>() ?? base.gameObject.AddComponent<TextMeshProUGUI>();
|
||||
}
|
||||
m_text.font = Resources.Load<TMP_FontAsset>("Fonts & Materials/Anton SDF");
|
||||
m_text.fontSharedMaterial = Resources.Load<Material>("Fonts & Materials/Anton SDF - Drop Shadow");
|
||||
m_text.fontSize = 120f;
|
||||
m_text.text = "A <#0080ff>simple</color> line of text.";
|
||||
Vector2 preferredValues = m_text.GetPreferredValues(float.PositiveInfinity, float.PositiveInfinity);
|
||||
m_text.rectTransform.sizeDelta = new Vector2(preferredValues.x, preferredValues.y);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (!isStatic)
|
||||
{
|
||||
m_text.SetText("The count is <#0080ff>{0}</color>", count % 1000);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a74a8724ad40affc6cb4e6ab790c9cea
|
||||
timeCreated: 1754266431
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
externalObjects: {}
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace TMPro.Examples
|
||||
{
|
||||
public class TMP_FrameRateCounter : MonoBehaviour
|
||||
{
|
||||
public enum FpsCounterAnchorPositions
|
||||
{
|
||||
TopLeft = 0,
|
||||
BottomLeft = 1,
|
||||
TopRight = 2,
|
||||
BottomRight = 3
|
||||
}
|
||||
|
||||
public float UpdateInterval = 5f;
|
||||
|
||||
private float m_LastInterval;
|
||||
|
||||
private int m_Frames;
|
||||
|
||||
public FpsCounterAnchorPositions AnchorPosition = FpsCounterAnchorPositions.TopRight;
|
||||
|
||||
private string htmlColorTag;
|
||||
|
||||
private const string fpsLabel = "{0:2}</color> <#8080ff>FPS \n<#FF8000>{1:2} <#8080ff>MS";
|
||||
|
||||
private TextMeshPro m_TextMeshPro;
|
||||
|
||||
private Transform m_frameCounter_transform;
|
||||
|
||||
private Camera m_camera;
|
||||
|
||||
private FpsCounterAnchorPositions last_AnchorPosition;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (base.enabled)
|
||||
{
|
||||
m_camera = Camera.main;
|
||||
Application.targetFrameRate = 9999;
|
||||
GameObject gameObject = new GameObject("Frame Counter");
|
||||
m_TextMeshPro = gameObject.AddComponent<TextMeshPro>();
|
||||
m_TextMeshPro.font = Resources.Load<TMP_FontAsset>("Fonts & Materials/LiberationSans SDF");
|
||||
m_TextMeshPro.fontSharedMaterial = Resources.Load<Material>("Fonts & Materials/LiberationSans SDF - Overlay");
|
||||
m_frameCounter_transform = gameObject.transform;
|
||||
m_frameCounter_transform.SetParent(m_camera.transform);
|
||||
m_frameCounter_transform.localRotation = Quaternion.identity;
|
||||
m_TextMeshPro.enableWordWrapping = false;
|
||||
m_TextMeshPro.fontSize = 24f;
|
||||
Set_FrameCounter_Position(AnchorPosition);
|
||||
last_AnchorPosition = AnchorPosition;
|
||||
}
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
m_LastInterval = Time.realtimeSinceStartup;
|
||||
m_Frames = 0;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (AnchorPosition != last_AnchorPosition)
|
||||
{
|
||||
Set_FrameCounter_Position(AnchorPosition);
|
||||
}
|
||||
last_AnchorPosition = AnchorPosition;
|
||||
m_Frames++;
|
||||
float realtimeSinceStartup = Time.realtimeSinceStartup;
|
||||
if (realtimeSinceStartup > m_LastInterval + UpdateInterval)
|
||||
{
|
||||
float num = (float)m_Frames / (realtimeSinceStartup - m_LastInterval);
|
||||
float arg = 1000f / Mathf.Max(num, 1E-05f);
|
||||
if (num < 30f)
|
||||
{
|
||||
htmlColorTag = "<color=yellow>";
|
||||
}
|
||||
else if (num < 10f)
|
||||
{
|
||||
htmlColorTag = "<color=red>";
|
||||
}
|
||||
else
|
||||
{
|
||||
htmlColorTag = "<color=green>";
|
||||
}
|
||||
m_TextMeshPro.SetText(htmlColorTag + "{0:2}</color> <#8080ff>FPS \n<#FF8000>{1:2} <#8080ff>MS", num, arg);
|
||||
m_Frames = 0;
|
||||
m_LastInterval = realtimeSinceStartup;
|
||||
}
|
||||
}
|
||||
|
||||
private void Set_FrameCounter_Position(FpsCounterAnchorPositions anchor_position)
|
||||
{
|
||||
m_TextMeshPro.margin = new Vector4(1f, 1f, 1f, 1f);
|
||||
switch (anchor_position)
|
||||
{
|
||||
case FpsCounterAnchorPositions.TopLeft:
|
||||
m_TextMeshPro.alignment = TextAlignmentOptions.TopLeft;
|
||||
m_TextMeshPro.rectTransform.pivot = new Vector2(0f, 1f);
|
||||
m_frameCounter_transform.position = m_camera.ViewportToWorldPoint(new Vector3(0f, 1f, 100f));
|
||||
break;
|
||||
case FpsCounterAnchorPositions.BottomLeft:
|
||||
m_TextMeshPro.alignment = TextAlignmentOptions.BottomLeft;
|
||||
m_TextMeshPro.rectTransform.pivot = new Vector2(0f, 0f);
|
||||
m_frameCounter_transform.position = m_camera.ViewportToWorldPoint(new Vector3(0f, 0f, 100f));
|
||||
break;
|
||||
case FpsCounterAnchorPositions.TopRight:
|
||||
m_TextMeshPro.alignment = TextAlignmentOptions.TopRight;
|
||||
m_TextMeshPro.rectTransform.pivot = new Vector2(1f, 1f);
|
||||
m_frameCounter_transform.position = m_camera.ViewportToWorldPoint(new Vector3(1f, 1f, 100f));
|
||||
break;
|
||||
case FpsCounterAnchorPositions.BottomRight:
|
||||
m_TextMeshPro.alignment = TextAlignmentOptions.BottomRight;
|
||||
m_TextMeshPro.rectTransform.pivot = new Vector2(1f, 0f);
|
||||
m_frameCounter_transform.position = m_camera.ViewportToWorldPoint(new Vector3(1f, 0f, 100f));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1a54c53eb4e48d8f878461e014fe7742
|
||||
timeCreated: 1754266431
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
externalObjects: {}
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace TMPro.Examples
|
||||
{
|
||||
public class TMP_TextEventCheck : MonoBehaviour
|
||||
{
|
||||
public TMP_TextEventHandler TextEventHandler;
|
||||
|
||||
private TMP_Text m_TextComponent;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
if (TextEventHandler != null)
|
||||
{
|
||||
m_TextComponent = TextEventHandler.GetComponent<TMP_Text>();
|
||||
TextEventHandler.onCharacterSelection.AddListener(OnCharacterSelection);
|
||||
TextEventHandler.onSpriteSelection.AddListener(OnSpriteSelection);
|
||||
TextEventHandler.onWordSelection.AddListener(OnWordSelection);
|
||||
TextEventHandler.onLineSelection.AddListener(OnLineSelection);
|
||||
TextEventHandler.onLinkSelection.AddListener(OnLinkSelection);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
if (TextEventHandler != null)
|
||||
{
|
||||
TextEventHandler.onCharacterSelection.RemoveListener(OnCharacterSelection);
|
||||
TextEventHandler.onSpriteSelection.RemoveListener(OnSpriteSelection);
|
||||
TextEventHandler.onWordSelection.RemoveListener(OnWordSelection);
|
||||
TextEventHandler.onLineSelection.RemoveListener(OnLineSelection);
|
||||
TextEventHandler.onLinkSelection.RemoveListener(OnLinkSelection);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnCharacterSelection(char c, int index)
|
||||
{
|
||||
Debug.Log("Character [" + c + "] at Index: " + index + " has been selected.");
|
||||
}
|
||||
|
||||
private void OnSpriteSelection(char c, int index)
|
||||
{
|
||||
Debug.Log("Sprite [" + c + "] at Index: " + index + " has been selected.");
|
||||
}
|
||||
|
||||
private void OnWordSelection(string word, int firstCharacterIndex, int length)
|
||||
{
|
||||
Debug.Log("Word [" + word + "] with first character index of " + firstCharacterIndex + " and length of " + length + " has been selected.");
|
||||
}
|
||||
|
||||
private void OnLineSelection(string lineText, int firstCharacterIndex, int length)
|
||||
{
|
||||
Debug.Log("Line [" + lineText + "] with first character index of " + firstCharacterIndex + " and length of " + length + " has been selected.");
|
||||
}
|
||||
|
||||
private void OnLinkSelection(string linkID, string linkText, int linkIndex)
|
||||
{
|
||||
if (m_TextComponent != null)
|
||||
{
|
||||
_ = ref m_TextComponent.textInfo.linkInfo[linkIndex];
|
||||
}
|
||||
Debug.Log("Link Index: " + linkIndex + " with ID [" + linkID + "] and Text \"" + linkText + "\" has been selected.");
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 54efb719a127edb2a5212e04e8987006
|
||||
timeCreated: 1754266431
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
externalObjects: {}
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace TMPro.Examples
|
||||
{
|
||||
public class TMP_TextInfoDebugTool : MonoBehaviour
|
||||
{
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 11cae6bd7323ff28f59fa7725fd3dbfe
|
||||
timeCreated: 1754266431
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
externalObjects: {}
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace TMPro.Examples
|
||||
{
|
||||
public class TMP_TextSelector_A : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler
|
||||
{
|
||||
private TextMeshPro m_TextMeshPro;
|
||||
|
||||
private Camera m_Camera;
|
||||
|
||||
private bool m_isHoveringObject;
|
||||
|
||||
private int m_selectedLink = -1;
|
||||
|
||||
private int m_lastCharIndex = -1;
|
||||
|
||||
private int m_lastWordIndex = -1;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
m_TextMeshPro = base.gameObject.GetComponent<TextMeshPro>();
|
||||
m_Camera = Camera.main;
|
||||
m_TextMeshPro.ForceMeshUpdate();
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
m_isHoveringObject = false;
|
||||
if (TMP_TextUtilities.IsIntersectingRectTransform(m_TextMeshPro.rectTransform, Input.mousePosition, Camera.main))
|
||||
{
|
||||
m_isHoveringObject = true;
|
||||
}
|
||||
if (!m_isHoveringObject)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int num = TMP_TextUtilities.FindIntersectingCharacter(m_TextMeshPro, Input.mousePosition, Camera.main, visibleOnly: true);
|
||||
if (num != -1 && num != m_lastCharIndex && (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)))
|
||||
{
|
||||
m_lastCharIndex = num;
|
||||
int materialReferenceIndex = m_TextMeshPro.textInfo.characterInfo[num].materialReferenceIndex;
|
||||
int vertexIndex = m_TextMeshPro.textInfo.characterInfo[num].vertexIndex;
|
||||
Color32 color = new Color32((byte)Random.Range(0, 255), (byte)Random.Range(0, 255), (byte)Random.Range(0, 255), byte.MaxValue);
|
||||
Color32[] colors = m_TextMeshPro.textInfo.meshInfo[materialReferenceIndex].colors32;
|
||||
colors[vertexIndex] = color;
|
||||
colors[vertexIndex + 1] = color;
|
||||
colors[vertexIndex + 2] = color;
|
||||
colors[vertexIndex + 3] = color;
|
||||
m_TextMeshPro.textInfo.meshInfo[materialReferenceIndex].mesh.colors32 = colors;
|
||||
}
|
||||
int num2 = TMP_TextUtilities.FindIntersectingLink(m_TextMeshPro, Input.mousePosition, m_Camera);
|
||||
if ((num2 == -1 && m_selectedLink != -1) || num2 != m_selectedLink)
|
||||
{
|
||||
m_selectedLink = -1;
|
||||
}
|
||||
if (num2 != -1 && num2 != m_selectedLink)
|
||||
{
|
||||
m_selectedLink = num2;
|
||||
TMP_LinkInfo tMP_LinkInfo = m_TextMeshPro.textInfo.linkInfo[num2];
|
||||
RectTransformUtility.ScreenPointToWorldPointInRectangle(m_TextMeshPro.rectTransform, Input.mousePosition, m_Camera, out var _);
|
||||
string linkID = tMP_LinkInfo.GetLinkID();
|
||||
if (!(linkID == "id_01"))
|
||||
{
|
||||
_ = linkID == "id_02";
|
||||
}
|
||||
}
|
||||
int num3 = TMP_TextUtilities.FindIntersectingWord(m_TextMeshPro, Input.mousePosition, Camera.main);
|
||||
if (num3 != -1 && num3 != m_lastWordIndex)
|
||||
{
|
||||
m_lastWordIndex = num3;
|
||||
TMP_WordInfo tMP_WordInfo = m_TextMeshPro.textInfo.wordInfo[num3];
|
||||
Vector3 position = m_TextMeshPro.transform.TransformPoint(m_TextMeshPro.textInfo.characterInfo[tMP_WordInfo.firstCharacterIndex].bottomLeft);
|
||||
position = Camera.main.WorldToScreenPoint(position);
|
||||
Color32[] colors2 = m_TextMeshPro.textInfo.meshInfo[0].colors32;
|
||||
Color32 color2 = new Color32((byte)Random.Range(0, 255), (byte)Random.Range(0, 255), (byte)Random.Range(0, 255), byte.MaxValue);
|
||||
for (int i = 0; i < tMP_WordInfo.characterCount; i++)
|
||||
{
|
||||
int vertexIndex2 = m_TextMeshPro.textInfo.characterInfo[tMP_WordInfo.firstCharacterIndex + i].vertexIndex;
|
||||
colors2[vertexIndex2] = color2;
|
||||
colors2[vertexIndex2 + 1] = color2;
|
||||
colors2[vertexIndex2 + 2] = color2;
|
||||
colors2[vertexIndex2 + 3] = color2;
|
||||
}
|
||||
m_TextMeshPro.mesh.colors32 = colors2;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnPointerEnter(PointerEventData eventData)
|
||||
{
|
||||
Debug.Log("OnPointerEnter()");
|
||||
m_isHoveringObject = true;
|
||||
}
|
||||
|
||||
public void OnPointerExit(PointerEventData eventData)
|
||||
{
|
||||
Debug.Log("OnPointerExit()");
|
||||
m_isHoveringObject = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9e740b8b0ef376f7ef63ead313fc8c51
|
||||
timeCreated: 1754266431
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
externalObjects: {}
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+255
@@ -0,0 +1,255 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace TMPro.Examples
|
||||
{
|
||||
public class TMP_TextSelector_B : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler, IPointerClickHandler, IPointerUpHandler
|
||||
{
|
||||
public RectTransform TextPopup_Prefab_01;
|
||||
|
||||
private RectTransform m_TextPopup_RectTransform;
|
||||
|
||||
private TextMeshProUGUI m_TextPopup_TMPComponent;
|
||||
|
||||
private const string k_LinkText = "You have selected link <#ffff00>";
|
||||
|
||||
private const string k_WordText = "Word Index: <#ffff00>";
|
||||
|
||||
private TextMeshProUGUI m_TextMeshPro;
|
||||
|
||||
private Canvas m_Canvas;
|
||||
|
||||
private Camera m_Camera;
|
||||
|
||||
private bool isHoveringObject;
|
||||
|
||||
private int m_selectedWord = -1;
|
||||
|
||||
private int m_selectedLink = -1;
|
||||
|
||||
private int m_lastIndex = -1;
|
||||
|
||||
private Matrix4x4 m_matrix;
|
||||
|
||||
private TMP_MeshInfo[] m_cachedMeshInfoVertexData;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
m_TextMeshPro = base.gameObject.GetComponent<TextMeshProUGUI>();
|
||||
m_Canvas = base.gameObject.GetComponentInParent<Canvas>();
|
||||
if (m_Canvas.renderMode == RenderMode.ScreenSpaceOverlay)
|
||||
{
|
||||
m_Camera = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Camera = m_Canvas.worldCamera;
|
||||
}
|
||||
m_TextPopup_RectTransform = Object.Instantiate(TextPopup_Prefab_01);
|
||||
m_TextPopup_RectTransform.SetParent(m_Canvas.transform, worldPositionStays: false);
|
||||
m_TextPopup_TMPComponent = m_TextPopup_RectTransform.GetComponentInChildren<TextMeshProUGUI>();
|
||||
m_TextPopup_RectTransform.gameObject.SetActive(value: false);
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
TMPro_EventManager.TEXT_CHANGED_EVENT.Add(ON_TEXT_CHANGED);
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
TMPro_EventManager.TEXT_CHANGED_EVENT.Remove(ON_TEXT_CHANGED);
|
||||
}
|
||||
|
||||
private void ON_TEXT_CHANGED(Object obj)
|
||||
{
|
||||
if (obj == m_TextMeshPro)
|
||||
{
|
||||
m_cachedMeshInfoVertexData = m_TextMeshPro.textInfo.CopyMeshInfoVertexData();
|
||||
}
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
if (isHoveringObject)
|
||||
{
|
||||
int num = TMP_TextUtilities.FindIntersectingCharacter(m_TextMeshPro, Input.mousePosition, m_Camera, visibleOnly: true);
|
||||
if (num == -1 || num != m_lastIndex)
|
||||
{
|
||||
RestoreCachedVertexAttributes(m_lastIndex);
|
||||
m_lastIndex = -1;
|
||||
}
|
||||
if (num != -1 && num != m_lastIndex && (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)))
|
||||
{
|
||||
m_lastIndex = num;
|
||||
int materialReferenceIndex = m_TextMeshPro.textInfo.characterInfo[num].materialReferenceIndex;
|
||||
int vertexIndex = m_TextMeshPro.textInfo.characterInfo[num].vertexIndex;
|
||||
Vector3[] vertices = m_TextMeshPro.textInfo.meshInfo[materialReferenceIndex].vertices;
|
||||
Vector3 vector = (Vector2)((vertices[vertexIndex] + vertices[vertexIndex + 2]) / 2f);
|
||||
vertices[vertexIndex] -= vector;
|
||||
vertices[vertexIndex + 1] -= vector;
|
||||
vertices[vertexIndex + 2] -= vector;
|
||||
vertices[vertexIndex + 3] -= vector;
|
||||
float num2 = 1.5f;
|
||||
m_matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, Vector3.one * num2);
|
||||
vertices[vertexIndex] = m_matrix.MultiplyPoint3x4(vertices[vertexIndex]);
|
||||
vertices[vertexIndex + 1] = m_matrix.MultiplyPoint3x4(vertices[vertexIndex + 1]);
|
||||
vertices[vertexIndex + 2] = m_matrix.MultiplyPoint3x4(vertices[vertexIndex + 2]);
|
||||
vertices[vertexIndex + 3] = m_matrix.MultiplyPoint3x4(vertices[vertexIndex + 3]);
|
||||
vertices[vertexIndex] += vector;
|
||||
vertices[vertexIndex + 1] += vector;
|
||||
vertices[vertexIndex + 2] += vector;
|
||||
vertices[vertexIndex + 3] += vector;
|
||||
Color32 color = new Color32(byte.MaxValue, byte.MaxValue, 192, byte.MaxValue);
|
||||
Color32[] colors = m_TextMeshPro.textInfo.meshInfo[materialReferenceIndex].colors32;
|
||||
colors[vertexIndex] = color;
|
||||
colors[vertexIndex + 1] = color;
|
||||
colors[vertexIndex + 2] = color;
|
||||
colors[vertexIndex + 3] = color;
|
||||
TMP_MeshInfo tMP_MeshInfo = m_TextMeshPro.textInfo.meshInfo[materialReferenceIndex];
|
||||
int dst = vertices.Length - 4;
|
||||
tMP_MeshInfo.SwapVertexData(vertexIndex, dst);
|
||||
m_TextMeshPro.UpdateVertexData(TMP_VertexDataUpdateFlags.All);
|
||||
}
|
||||
int num3 = TMP_TextUtilities.FindIntersectingWord(m_TextMeshPro, Input.mousePosition, m_Camera);
|
||||
if (m_TextPopup_RectTransform != null && m_selectedWord != -1 && (num3 == -1 || num3 != m_selectedWord))
|
||||
{
|
||||
TMP_WordInfo tMP_WordInfo = m_TextMeshPro.textInfo.wordInfo[m_selectedWord];
|
||||
for (int i = 0; i < tMP_WordInfo.characterCount; i++)
|
||||
{
|
||||
int num4 = tMP_WordInfo.firstCharacterIndex + i;
|
||||
int materialReferenceIndex2 = m_TextMeshPro.textInfo.characterInfo[num4].materialReferenceIndex;
|
||||
int vertexIndex2 = m_TextMeshPro.textInfo.characterInfo[num4].vertexIndex;
|
||||
Color32[] colors2 = m_TextMeshPro.textInfo.meshInfo[materialReferenceIndex2].colors32;
|
||||
colors2[vertexIndex2 + 3] = (colors2[vertexIndex2 + 2] = (colors2[vertexIndex2 + 1] = (colors2[vertexIndex2] = colors2[vertexIndex2].Tint(1.33333f))));
|
||||
}
|
||||
m_TextMeshPro.UpdateVertexData(TMP_VertexDataUpdateFlags.All);
|
||||
m_selectedWord = -1;
|
||||
}
|
||||
if (num3 != -1 && num3 != m_selectedWord && !Input.GetKey(KeyCode.LeftShift) && !Input.GetKey(KeyCode.RightShift))
|
||||
{
|
||||
m_selectedWord = num3;
|
||||
TMP_WordInfo tMP_WordInfo2 = m_TextMeshPro.textInfo.wordInfo[num3];
|
||||
for (int j = 0; j < tMP_WordInfo2.characterCount; j++)
|
||||
{
|
||||
int num5 = tMP_WordInfo2.firstCharacterIndex + j;
|
||||
int materialReferenceIndex3 = m_TextMeshPro.textInfo.characterInfo[num5].materialReferenceIndex;
|
||||
int vertexIndex3 = m_TextMeshPro.textInfo.characterInfo[num5].vertexIndex;
|
||||
Color32[] colors3 = m_TextMeshPro.textInfo.meshInfo[materialReferenceIndex3].colors32;
|
||||
colors3[vertexIndex3 + 3] = (colors3[vertexIndex3 + 2] = (colors3[vertexIndex3 + 1] = (colors3[vertexIndex3] = colors3[vertexIndex3].Tint(0.75f))));
|
||||
}
|
||||
m_TextMeshPro.UpdateVertexData(TMP_VertexDataUpdateFlags.All);
|
||||
}
|
||||
int num6 = TMP_TextUtilities.FindIntersectingLink(m_TextMeshPro, Input.mousePosition, m_Camera);
|
||||
if ((num6 == -1 && m_selectedLink != -1) || num6 != m_selectedLink)
|
||||
{
|
||||
m_TextPopup_RectTransform.gameObject.SetActive(value: false);
|
||||
m_selectedLink = -1;
|
||||
}
|
||||
if (num6 == -1 || num6 == m_selectedLink)
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_selectedLink = num6;
|
||||
TMP_LinkInfo tMP_LinkInfo = m_TextMeshPro.textInfo.linkInfo[num6];
|
||||
RectTransformUtility.ScreenPointToWorldPointInRectangle(m_TextMeshPro.rectTransform, Input.mousePosition, m_Camera, out var worldPoint);
|
||||
string linkID = tMP_LinkInfo.GetLinkID();
|
||||
if (!(linkID == "id_01"))
|
||||
{
|
||||
if (linkID == "id_02")
|
||||
{
|
||||
m_TextPopup_RectTransform.position = worldPoint;
|
||||
m_TextPopup_RectTransform.gameObject.SetActive(value: true);
|
||||
m_TextPopup_TMPComponent.text = "You have selected link <#ffff00> ID 02";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_TextPopup_RectTransform.position = worldPoint;
|
||||
m_TextPopup_RectTransform.gameObject.SetActive(value: true);
|
||||
m_TextPopup_TMPComponent.text = "You have selected link <#ffff00> ID 01";
|
||||
}
|
||||
}
|
||||
else if (m_lastIndex != -1)
|
||||
{
|
||||
RestoreCachedVertexAttributes(m_lastIndex);
|
||||
m_lastIndex = -1;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnPointerEnter(PointerEventData eventData)
|
||||
{
|
||||
isHoveringObject = true;
|
||||
}
|
||||
|
||||
public void OnPointerExit(PointerEventData eventData)
|
||||
{
|
||||
isHoveringObject = false;
|
||||
}
|
||||
|
||||
public void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
}
|
||||
|
||||
public void OnPointerUp(PointerEventData eventData)
|
||||
{
|
||||
}
|
||||
|
||||
private void RestoreCachedVertexAttributes(int index)
|
||||
{
|
||||
if (index != -1 && index <= m_TextMeshPro.textInfo.characterCount - 1)
|
||||
{
|
||||
int materialReferenceIndex = m_TextMeshPro.textInfo.characterInfo[index].materialReferenceIndex;
|
||||
int vertexIndex = m_TextMeshPro.textInfo.characterInfo[index].vertexIndex;
|
||||
Vector3[] vertices = m_cachedMeshInfoVertexData[materialReferenceIndex].vertices;
|
||||
Vector3[] vertices2 = m_TextMeshPro.textInfo.meshInfo[materialReferenceIndex].vertices;
|
||||
vertices2[vertexIndex] = vertices[vertexIndex];
|
||||
vertices2[vertexIndex + 1] = vertices[vertexIndex + 1];
|
||||
vertices2[vertexIndex + 2] = vertices[vertexIndex + 2];
|
||||
vertices2[vertexIndex + 3] = vertices[vertexIndex + 3];
|
||||
Color32[] colors = m_TextMeshPro.textInfo.meshInfo[materialReferenceIndex].colors32;
|
||||
Color32[] colors2 = m_cachedMeshInfoVertexData[materialReferenceIndex].colors32;
|
||||
colors[vertexIndex] = colors2[vertexIndex];
|
||||
colors[vertexIndex + 1] = colors2[vertexIndex + 1];
|
||||
colors[vertexIndex + 2] = colors2[vertexIndex + 2];
|
||||
colors[vertexIndex + 3] = colors2[vertexIndex + 3];
|
||||
Vector2[] uvs = m_cachedMeshInfoVertexData[materialReferenceIndex].uvs0;
|
||||
Vector2[] uvs2 = m_TextMeshPro.textInfo.meshInfo[materialReferenceIndex].uvs0;
|
||||
uvs2[vertexIndex] = uvs[vertexIndex];
|
||||
uvs2[vertexIndex + 1] = uvs[vertexIndex + 1];
|
||||
uvs2[vertexIndex + 2] = uvs[vertexIndex + 2];
|
||||
uvs2[vertexIndex + 3] = uvs[vertexIndex + 3];
|
||||
Vector2[] uvs3 = m_cachedMeshInfoVertexData[materialReferenceIndex].uvs2;
|
||||
Vector2[] uvs4 = m_TextMeshPro.textInfo.meshInfo[materialReferenceIndex].uvs2;
|
||||
uvs4[vertexIndex] = uvs3[vertexIndex];
|
||||
uvs4[vertexIndex + 1] = uvs3[vertexIndex + 1];
|
||||
uvs4[vertexIndex + 2] = uvs3[vertexIndex + 2];
|
||||
uvs4[vertexIndex + 3] = uvs3[vertexIndex + 3];
|
||||
int num = (vertices.Length / 4 - 1) * 4;
|
||||
vertices2[num] = vertices[num];
|
||||
vertices2[num + 1] = vertices[num + 1];
|
||||
vertices2[num + 2] = vertices[num + 2];
|
||||
vertices2[num + 3] = vertices[num + 3];
|
||||
colors2 = m_cachedMeshInfoVertexData[materialReferenceIndex].colors32;
|
||||
Color32[] colors3 = m_TextMeshPro.textInfo.meshInfo[materialReferenceIndex].colors32;
|
||||
colors3[num] = colors2[num];
|
||||
colors3[num + 1] = colors2[num + 1];
|
||||
colors3[num + 2] = colors2[num + 2];
|
||||
colors3[num + 3] = colors2[num + 3];
|
||||
uvs = m_cachedMeshInfoVertexData[materialReferenceIndex].uvs0;
|
||||
Vector2[] uvs5 = m_TextMeshPro.textInfo.meshInfo[materialReferenceIndex].uvs0;
|
||||
uvs5[num] = uvs[num];
|
||||
uvs5[num + 1] = uvs[num + 1];
|
||||
uvs5[num + 2] = uvs[num + 2];
|
||||
uvs5[num + 3] = uvs[num + 3];
|
||||
uvs3 = m_cachedMeshInfoVertexData[materialReferenceIndex].uvs2;
|
||||
Vector2[] uvs6 = m_TextMeshPro.textInfo.meshInfo[materialReferenceIndex].uvs2;
|
||||
uvs6[num] = uvs3[num];
|
||||
uvs6[num + 1] = uvs3[num + 1];
|
||||
uvs6[num + 2] = uvs3[num + 2];
|
||||
uvs6[num + 3] = uvs3[num + 3];
|
||||
m_TextMeshPro.UpdateVertexData(TMP_VertexDataUpdateFlags.All);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 47f3637b1b0879c2e0568c83b87d1d8f
|
||||
timeCreated: 1754266431
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
externalObjects: {}
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+124
@@ -0,0 +1,124 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace TMPro.Examples
|
||||
{
|
||||
public class TMP_UiFrameRateCounter : MonoBehaviour
|
||||
{
|
||||
public enum FpsCounterAnchorPositions
|
||||
{
|
||||
TopLeft = 0,
|
||||
BottomLeft = 1,
|
||||
TopRight = 2,
|
||||
BottomRight = 3
|
||||
}
|
||||
|
||||
public float UpdateInterval = 5f;
|
||||
|
||||
private float m_LastInterval;
|
||||
|
||||
private int m_Frames;
|
||||
|
||||
public FpsCounterAnchorPositions AnchorPosition = FpsCounterAnchorPositions.TopRight;
|
||||
|
||||
private string htmlColorTag;
|
||||
|
||||
private const string fpsLabel = "{0:2}</color> <#8080ff>FPS \n<#FF8000>{1:2} <#8080ff>MS";
|
||||
|
||||
private TextMeshProUGUI m_TextMeshPro;
|
||||
|
||||
private RectTransform m_frameCounter_transform;
|
||||
|
||||
private FpsCounterAnchorPositions last_AnchorPosition;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (base.enabled)
|
||||
{
|
||||
Application.targetFrameRate = 1000;
|
||||
GameObject gameObject = new GameObject("Frame Counter");
|
||||
m_frameCounter_transform = gameObject.AddComponent<RectTransform>();
|
||||
m_frameCounter_transform.SetParent(base.transform, worldPositionStays: false);
|
||||
m_TextMeshPro = gameObject.AddComponent<TextMeshProUGUI>();
|
||||
m_TextMeshPro.font = Resources.Load<TMP_FontAsset>("Fonts & Materials/LiberationSans SDF");
|
||||
m_TextMeshPro.fontSharedMaterial = Resources.Load<Material>("Fonts & Materials/LiberationSans SDF - Overlay");
|
||||
m_TextMeshPro.enableWordWrapping = false;
|
||||
m_TextMeshPro.fontSize = 36f;
|
||||
m_TextMeshPro.isOverlay = true;
|
||||
Set_FrameCounter_Position(AnchorPosition);
|
||||
last_AnchorPosition = AnchorPosition;
|
||||
}
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
m_LastInterval = Time.realtimeSinceStartup;
|
||||
m_Frames = 0;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (AnchorPosition != last_AnchorPosition)
|
||||
{
|
||||
Set_FrameCounter_Position(AnchorPosition);
|
||||
}
|
||||
last_AnchorPosition = AnchorPosition;
|
||||
m_Frames++;
|
||||
float realtimeSinceStartup = Time.realtimeSinceStartup;
|
||||
if (realtimeSinceStartup > m_LastInterval + UpdateInterval)
|
||||
{
|
||||
float num = (float)m_Frames / (realtimeSinceStartup - m_LastInterval);
|
||||
float arg = 1000f / Mathf.Max(num, 1E-05f);
|
||||
if (num < 30f)
|
||||
{
|
||||
htmlColorTag = "<color=yellow>";
|
||||
}
|
||||
else if (num < 10f)
|
||||
{
|
||||
htmlColorTag = "<color=red>";
|
||||
}
|
||||
else
|
||||
{
|
||||
htmlColorTag = "<color=green>";
|
||||
}
|
||||
m_TextMeshPro.SetText(htmlColorTag + "{0:2}</color> <#8080ff>FPS \n<#FF8000>{1:2} <#8080ff>MS", num, arg);
|
||||
m_Frames = 0;
|
||||
m_LastInterval = realtimeSinceStartup;
|
||||
}
|
||||
}
|
||||
|
||||
private void Set_FrameCounter_Position(FpsCounterAnchorPositions anchor_position)
|
||||
{
|
||||
switch (anchor_position)
|
||||
{
|
||||
case FpsCounterAnchorPositions.TopLeft:
|
||||
m_TextMeshPro.alignment = TextAlignmentOptions.TopLeft;
|
||||
m_frameCounter_transform.pivot = new Vector2(0f, 1f);
|
||||
m_frameCounter_transform.anchorMin = new Vector2(0.01f, 0.99f);
|
||||
m_frameCounter_transform.anchorMax = new Vector2(0.01f, 0.99f);
|
||||
m_frameCounter_transform.anchoredPosition = new Vector2(0f, 1f);
|
||||
break;
|
||||
case FpsCounterAnchorPositions.BottomLeft:
|
||||
m_TextMeshPro.alignment = TextAlignmentOptions.BottomLeft;
|
||||
m_frameCounter_transform.pivot = new Vector2(0f, 0f);
|
||||
m_frameCounter_transform.anchorMin = new Vector2(0.01f, 0.01f);
|
||||
m_frameCounter_transform.anchorMax = new Vector2(0.01f, 0.01f);
|
||||
m_frameCounter_transform.anchoredPosition = new Vector2(0f, 0f);
|
||||
break;
|
||||
case FpsCounterAnchorPositions.TopRight:
|
||||
m_TextMeshPro.alignment = TextAlignmentOptions.TopRight;
|
||||
m_frameCounter_transform.pivot = new Vector2(1f, 1f);
|
||||
m_frameCounter_transform.anchorMin = new Vector2(0.99f, 0.99f);
|
||||
m_frameCounter_transform.anchorMax = new Vector2(0.99f, 0.99f);
|
||||
m_frameCounter_transform.anchoredPosition = new Vector2(1f, 1f);
|
||||
break;
|
||||
case FpsCounterAnchorPositions.BottomRight:
|
||||
m_TextMeshPro.alignment = TextAlignmentOptions.BottomRight;
|
||||
m_frameCounter_transform.pivot = new Vector2(1f, 0f);
|
||||
m_frameCounter_transform.anchorMin = new Vector2(0.99f, 0.01f);
|
||||
m_frameCounter_transform.anchorMax = new Vector2(0.99f, 0.01f);
|
||||
m_frameCounter_transform.anchoredPosition = new Vector2(1f, 0f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7cba422eb7c134d053003a658c5b837c
|
||||
timeCreated: 1754266431
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
externalObjects: {}
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace TMPro.Examples
|
||||
{
|
||||
public class TMPro_InstructionOverlay : MonoBehaviour
|
||||
{
|
||||
public enum FpsCounterAnchorPositions
|
||||
{
|
||||
TopLeft = 0,
|
||||
BottomLeft = 1,
|
||||
TopRight = 2,
|
||||
BottomRight = 3
|
||||
}
|
||||
|
||||
public FpsCounterAnchorPositions AnchorPosition = FpsCounterAnchorPositions.BottomLeft;
|
||||
|
||||
private const string instructions = "Camera Control - <#ffff00>Shift + RMB\n</color>Zoom - <#ffff00>Mouse wheel.";
|
||||
|
||||
private TextMeshPro m_TextMeshPro;
|
||||
|
||||
private TextContainer m_textContainer;
|
||||
|
||||
private Transform m_frameCounter_transform;
|
||||
|
||||
private Camera m_camera;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (base.enabled)
|
||||
{
|
||||
m_camera = Camera.main;
|
||||
GameObject gameObject = new GameObject("Frame Counter");
|
||||
m_frameCounter_transform = gameObject.transform;
|
||||
m_frameCounter_transform.parent = m_camera.transform;
|
||||
m_frameCounter_transform.localRotation = Quaternion.identity;
|
||||
m_TextMeshPro = gameObject.AddComponent<TextMeshPro>();
|
||||
m_TextMeshPro.font = Resources.Load<TMP_FontAsset>("Fonts & Materials/LiberationSans SDF");
|
||||
m_TextMeshPro.fontSharedMaterial = Resources.Load<Material>("Fonts & Materials/LiberationSans SDF - Overlay");
|
||||
m_TextMeshPro.fontSize = 30f;
|
||||
m_TextMeshPro.isOverlay = true;
|
||||
m_textContainer = gameObject.GetComponent<TextContainer>();
|
||||
Set_FrameCounter_Position(AnchorPosition);
|
||||
m_TextMeshPro.text = "Camera Control - <#ffff00>Shift + RMB\n</color>Zoom - <#ffff00>Mouse wheel.";
|
||||
}
|
||||
}
|
||||
|
||||
private void Set_FrameCounter_Position(FpsCounterAnchorPositions anchor_position)
|
||||
{
|
||||
switch (anchor_position)
|
||||
{
|
||||
case FpsCounterAnchorPositions.TopLeft:
|
||||
m_textContainer.anchorPosition = TextContainerAnchors.TopLeft;
|
||||
m_frameCounter_transform.position = m_camera.ViewportToWorldPoint(new Vector3(0f, 1f, 100f));
|
||||
break;
|
||||
case FpsCounterAnchorPositions.BottomLeft:
|
||||
m_textContainer.anchorPosition = TextContainerAnchors.BottomLeft;
|
||||
m_frameCounter_transform.position = m_camera.ViewportToWorldPoint(new Vector3(0f, 0f, 100f));
|
||||
break;
|
||||
case FpsCounterAnchorPositions.TopRight:
|
||||
m_textContainer.anchorPosition = TextContainerAnchors.TopRight;
|
||||
m_frameCounter_transform.position = m_camera.ViewportToWorldPoint(new Vector3(1f, 1f, 100f));
|
||||
break;
|
||||
case FpsCounterAnchorPositions.BottomRight:
|
||||
m_textContainer.anchorPosition = TextContainerAnchors.BottomRight;
|
||||
m_frameCounter_transform.position = m_camera.ViewportToWorldPoint(new Vector3(1f, 0f, 100f));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 168af457cec814b549454fdc5db6358c
|
||||
timeCreated: 1754266431
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
externalObjects: {}
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TMPro.Examples
|
||||
{
|
||||
public class TeleType : MonoBehaviour
|
||||
{
|
||||
private string label01 = "Example <sprite=2> of using <sprite=7> <#ffa000>Graphics Inline</color> <sprite=5> with Text in <font=\"Bangers SDF\" material=\"Bangers SDF - Drop Shadow\">TextMesh<#40a0ff>Pro</color></font><sprite=0> and Unity<sprite=1>";
|
||||
|
||||
private string label02 = "Example <sprite=2> of using <sprite=7> <#ffa000>Graphics Inline</color> <sprite=5> with Text in <font=\"Bangers SDF\" material=\"Bangers SDF - Drop Shadow\">TextMesh<#40a0ff>Pro</color></font><sprite=0> and Unity<sprite=2>";
|
||||
|
||||
private TMP_Text m_textMeshPro;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
m_textMeshPro = GetComponent<TMP_Text>();
|
||||
m_textMeshPro.text = label01;
|
||||
m_textMeshPro.enableWordWrapping = true;
|
||||
m_textMeshPro.alignment = TextAlignmentOptions.Top;
|
||||
}
|
||||
|
||||
private IEnumerator Start()
|
||||
{
|
||||
m_textMeshPro.ForceMeshUpdate();
|
||||
int totalVisibleCharacters = m_textMeshPro.textInfo.characterCount;
|
||||
int counter = 0;
|
||||
while (true)
|
||||
{
|
||||
int num = counter % (totalVisibleCharacters + 1);
|
||||
m_textMeshPro.maxVisibleCharacters = num;
|
||||
if (num >= totalVisibleCharacters)
|
||||
{
|
||||
yield return new WaitForSeconds(1f);
|
||||
m_textMeshPro.text = label02;
|
||||
yield return new WaitForSeconds(1f);
|
||||
m_textMeshPro.text = label01;
|
||||
yield return new WaitForSeconds(1f);
|
||||
}
|
||||
counter++;
|
||||
yield return new WaitForSeconds(0.05f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 460dc54e55fd2bb3558ca6f3a91d534f
|
||||
timeCreated: 1754266431
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
externalObjects: {}
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TMPro.Examples
|
||||
{
|
||||
public class TextConsoleSimulator : MonoBehaviour
|
||||
{
|
||||
private TMP_Text m_TextComponent;
|
||||
|
||||
private bool hasTextChanged;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
m_TextComponent = base.gameObject.GetComponent<TMP_Text>();
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
StartCoroutine(RevealCharacters(m_TextComponent));
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
TMPro_EventManager.TEXT_CHANGED_EVENT.Add(ON_TEXT_CHANGED);
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
TMPro_EventManager.TEXT_CHANGED_EVENT.Remove(ON_TEXT_CHANGED);
|
||||
}
|
||||
|
||||
private void ON_TEXT_CHANGED(Object obj)
|
||||
{
|
||||
hasTextChanged = true;
|
||||
}
|
||||
|
||||
private IEnumerator RevealCharacters(TMP_Text textComponent)
|
||||
{
|
||||
textComponent.ForceMeshUpdate();
|
||||
TMP_TextInfo textInfo = textComponent.textInfo;
|
||||
int totalVisibleCharacters = textInfo.characterCount;
|
||||
int visibleCount = 0;
|
||||
while (true)
|
||||
{
|
||||
if (hasTextChanged)
|
||||
{
|
||||
totalVisibleCharacters = textInfo.characterCount;
|
||||
hasTextChanged = false;
|
||||
}
|
||||
if (visibleCount > totalVisibleCharacters)
|
||||
{
|
||||
yield return new WaitForSeconds(1f);
|
||||
visibleCount = 0;
|
||||
}
|
||||
textComponent.maxVisibleCharacters = visibleCount;
|
||||
visibleCount++;
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator RevealWords(TMP_Text textComponent)
|
||||
{
|
||||
textComponent.ForceMeshUpdate();
|
||||
int totalWordCount = textComponent.textInfo.wordCount;
|
||||
int totalVisibleCharacters = textComponent.textInfo.characterCount;
|
||||
int counter = 0;
|
||||
int visibleCount = 0;
|
||||
while (true)
|
||||
{
|
||||
int num = counter % (totalWordCount + 1);
|
||||
if (num == 0)
|
||||
{
|
||||
visibleCount = 0;
|
||||
}
|
||||
else if (num < totalWordCount)
|
||||
{
|
||||
visibleCount = textComponent.textInfo.wordInfo[num - 1].lastCharacterIndex + 1;
|
||||
}
|
||||
else if (num == totalWordCount)
|
||||
{
|
||||
visibleCount = totalVisibleCharacters;
|
||||
}
|
||||
textComponent.maxVisibleCharacters = visibleCount;
|
||||
if (visibleCount >= totalVisibleCharacters)
|
||||
{
|
||||
yield return new WaitForSeconds(1f);
|
||||
}
|
||||
counter++;
|
||||
yield return new WaitForSeconds(0.1f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 38f8f54f1c44bd37a1174b9112fc8015
|
||||
timeCreated: 1754266431
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
externalObjects: {}
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+166
@@ -0,0 +1,166 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TMPro.Examples
|
||||
{
|
||||
public class TextMeshProFloatingText : MonoBehaviour
|
||||
{
|
||||
public Font TheFont;
|
||||
|
||||
private GameObject m_floatingText;
|
||||
|
||||
private TextMeshPro m_textMeshPro;
|
||||
|
||||
private TextMesh m_textMesh;
|
||||
|
||||
private Transform m_transform;
|
||||
|
||||
private Transform m_floatingText_Transform;
|
||||
|
||||
private Transform m_cameraTransform;
|
||||
|
||||
private Vector3 lastPOS = Vector3.zero;
|
||||
|
||||
private Quaternion lastRotation = Quaternion.identity;
|
||||
|
||||
public int SpawnType;
|
||||
|
||||
public bool IsTextObjectScaleStatic;
|
||||
|
||||
private static WaitForEndOfFrame k_WaitForEndOfFrame = new WaitForEndOfFrame();
|
||||
|
||||
private static WaitForSeconds[] k_WaitForSecondsRandom = new WaitForSeconds[20]
|
||||
{
|
||||
new WaitForSeconds(0.05f),
|
||||
new WaitForSeconds(0.1f),
|
||||
new WaitForSeconds(0.15f),
|
||||
new WaitForSeconds(0.2f),
|
||||
new WaitForSeconds(0.25f),
|
||||
new WaitForSeconds(0.3f),
|
||||
new WaitForSeconds(0.35f),
|
||||
new WaitForSeconds(0.4f),
|
||||
new WaitForSeconds(0.45f),
|
||||
new WaitForSeconds(0.5f),
|
||||
new WaitForSeconds(0.55f),
|
||||
new WaitForSeconds(0.6f),
|
||||
new WaitForSeconds(0.65f),
|
||||
new WaitForSeconds(0.7f),
|
||||
new WaitForSeconds(0.75f),
|
||||
new WaitForSeconds(0.8f),
|
||||
new WaitForSeconds(0.85f),
|
||||
new WaitForSeconds(0.9f),
|
||||
new WaitForSeconds(0.95f),
|
||||
new WaitForSeconds(1f)
|
||||
};
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
m_transform = base.transform;
|
||||
m_floatingText = new GameObject(base.name + " floating text");
|
||||
m_cameraTransform = Camera.main.transform;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
if (SpawnType == 0)
|
||||
{
|
||||
m_textMeshPro = m_floatingText.AddComponent<TextMeshPro>();
|
||||
m_textMeshPro.rectTransform.sizeDelta = new Vector2(3f, 3f);
|
||||
m_floatingText_Transform = m_floatingText.transform;
|
||||
m_floatingText_Transform.position = m_transform.position + new Vector3(0f, 15f, 0f);
|
||||
m_textMeshPro.alignment = TextAlignmentOptions.Center;
|
||||
m_textMeshPro.color = new Color32((byte)Random.Range(0, 255), (byte)Random.Range(0, 255), (byte)Random.Range(0, 255), byte.MaxValue);
|
||||
m_textMeshPro.fontSize = 24f;
|
||||
m_textMeshPro.enableKerning = false;
|
||||
m_textMeshPro.text = string.Empty;
|
||||
m_textMeshPro.isTextObjectScaleStatic = IsTextObjectScaleStatic;
|
||||
StartCoroutine(DisplayTextMeshProFloatingText());
|
||||
}
|
||||
else if (SpawnType == 1)
|
||||
{
|
||||
m_floatingText_Transform = m_floatingText.transform;
|
||||
m_floatingText_Transform.position = m_transform.position + new Vector3(0f, 15f, 0f);
|
||||
m_textMesh = m_floatingText.AddComponent<TextMesh>();
|
||||
m_textMesh.font = Resources.Load<Font>("Fonts/ARIAL");
|
||||
m_textMesh.GetComponent<Renderer>().sharedMaterial = m_textMesh.font.material;
|
||||
m_textMesh.color = new Color32((byte)Random.Range(0, 255), (byte)Random.Range(0, 255), (byte)Random.Range(0, 255), byte.MaxValue);
|
||||
m_textMesh.anchor = TextAnchor.LowerCenter;
|
||||
m_textMesh.fontSize = 24;
|
||||
StartCoroutine(DisplayTextMeshFloatingText());
|
||||
}
|
||||
else
|
||||
{
|
||||
_ = SpawnType;
|
||||
_ = 2;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerator DisplayTextMeshProFloatingText()
|
||||
{
|
||||
float CountDuration = 2f;
|
||||
float starting_Count = Random.Range(5f, 20f);
|
||||
float current_Count = starting_Count;
|
||||
Vector3 start_pos = m_floatingText_Transform.position;
|
||||
Color32 start_color = m_textMeshPro.color;
|
||||
float alpha = 255f;
|
||||
float fadeDuration = 3f / starting_Count * CountDuration;
|
||||
while (current_Count > 0f)
|
||||
{
|
||||
current_Count -= Time.deltaTime / CountDuration * starting_Count;
|
||||
if (current_Count <= 3f)
|
||||
{
|
||||
alpha = Mathf.Clamp(alpha - Time.deltaTime / fadeDuration * 255f, 0f, 255f);
|
||||
}
|
||||
m_textMeshPro.text = ((int)current_Count).ToString();
|
||||
m_textMeshPro.color = new Color32(start_color.r, start_color.g, start_color.b, (byte)alpha);
|
||||
m_floatingText_Transform.position += new Vector3(0f, starting_Count * Time.deltaTime, 0f);
|
||||
if (!lastPOS.Compare(m_cameraTransform.position, 1000) || !lastRotation.Compare(m_cameraTransform.rotation, 1000))
|
||||
{
|
||||
lastPOS = m_cameraTransform.position;
|
||||
lastRotation = m_cameraTransform.rotation;
|
||||
m_floatingText_Transform.rotation = lastRotation;
|
||||
Vector3 vector = m_transform.position - lastPOS;
|
||||
m_transform.forward = new Vector3(vector.x, 0f, vector.z);
|
||||
}
|
||||
yield return k_WaitForEndOfFrame;
|
||||
}
|
||||
yield return k_WaitForSecondsRandom[Random.Range(0, 19)];
|
||||
m_floatingText_Transform.position = start_pos;
|
||||
StartCoroutine(DisplayTextMeshProFloatingText());
|
||||
}
|
||||
|
||||
public IEnumerator DisplayTextMeshFloatingText()
|
||||
{
|
||||
float CountDuration = 2f;
|
||||
float starting_Count = Random.Range(5f, 20f);
|
||||
float current_Count = starting_Count;
|
||||
Vector3 start_pos = m_floatingText_Transform.position;
|
||||
Color32 start_color = m_textMesh.color;
|
||||
float alpha = 255f;
|
||||
float fadeDuration = 3f / starting_Count * CountDuration;
|
||||
while (current_Count > 0f)
|
||||
{
|
||||
current_Count -= Time.deltaTime / CountDuration * starting_Count;
|
||||
if (current_Count <= 3f)
|
||||
{
|
||||
alpha = Mathf.Clamp(alpha - Time.deltaTime / fadeDuration * 255f, 0f, 255f);
|
||||
}
|
||||
m_textMesh.text = ((int)current_Count).ToString();
|
||||
m_textMesh.color = new Color32(start_color.r, start_color.g, start_color.b, (byte)alpha);
|
||||
m_floatingText_Transform.position += new Vector3(0f, starting_Count * Time.deltaTime, 0f);
|
||||
if (!lastPOS.Compare(m_cameraTransform.position, 1000) || !lastRotation.Compare(m_cameraTransform.rotation, 1000))
|
||||
{
|
||||
lastPOS = m_cameraTransform.position;
|
||||
lastRotation = m_cameraTransform.rotation;
|
||||
m_floatingText_Transform.rotation = lastRotation;
|
||||
Vector3 vector = m_transform.position - lastPOS;
|
||||
m_transform.forward = new Vector3(vector.x, 0f, vector.z);
|
||||
}
|
||||
yield return k_WaitForEndOfFrame;
|
||||
}
|
||||
yield return k_WaitForSecondsRandom[Random.Range(0, 20)];
|
||||
m_floatingText_Transform.position = start_pos;
|
||||
StartCoroutine(DisplayTextMeshFloatingText());
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 427e65ebb2d527aa189759da011906d8
|
||||
timeCreated: 1754266431
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
externalObjects: {}
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace TMPro.Examples
|
||||
{
|
||||
public class TextMeshSpawner : MonoBehaviour
|
||||
{
|
||||
public int SpawnType;
|
||||
|
||||
public int NumberOfNPC = 12;
|
||||
|
||||
public Font TheFont;
|
||||
|
||||
private TextMeshProFloatingText floatingText_Script;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
for (int i = 0; i < NumberOfNPC; i++)
|
||||
{
|
||||
if (SpawnType == 0)
|
||||
{
|
||||
GameObject gameObject = new GameObject();
|
||||
gameObject.transform.position = new Vector3(Random.Range(-95f, 95f), 0.5f, Random.Range(-95f, 95f));
|
||||
TextMeshPro textMeshPro = gameObject.AddComponent<TextMeshPro>();
|
||||
textMeshPro.fontSize = 96f;
|
||||
textMeshPro.text = "!";
|
||||
textMeshPro.color = new Color32(byte.MaxValue, byte.MaxValue, 0, byte.MaxValue);
|
||||
floatingText_Script = gameObject.AddComponent<TextMeshProFloatingText>();
|
||||
floatingText_Script.SpawnType = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
GameObject gameObject2 = new GameObject();
|
||||
gameObject2.transform.position = new Vector3(Random.Range(-95f, 95f), 0.5f, Random.Range(-95f, 95f));
|
||||
TextMesh textMesh = gameObject2.AddComponent<TextMesh>();
|
||||
textMesh.GetComponent<Renderer>().sharedMaterial = TheFont.material;
|
||||
textMesh.font = TheFont;
|
||||
textMesh.anchor = TextAnchor.LowerCenter;
|
||||
textMesh.fontSize = 96;
|
||||
textMesh.color = new Color32(byte.MaxValue, byte.MaxValue, 0, byte.MaxValue);
|
||||
textMesh.text = "!";
|
||||
floatingText_Script = gameObject2.AddComponent<TextMeshProFloatingText>();
|
||||
floatingText_Script.SpawnType = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 53fcee8fb819807aa678e32685ac3630
|
||||
timeCreated: 1754266431
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
externalObjects: {}
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TMPro.Examples
|
||||
{
|
||||
public class VertexColorCycler : MonoBehaviour
|
||||
{
|
||||
private TMP_Text m_TextComponent;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
m_TextComponent = GetComponent<TMP_Text>();
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
StartCoroutine(AnimateVertexColors());
|
||||
}
|
||||
|
||||
private IEnumerator AnimateVertexColors()
|
||||
{
|
||||
m_TextComponent.ForceMeshUpdate();
|
||||
TMP_TextInfo textInfo = m_TextComponent.textInfo;
|
||||
int currentCharacter = 0;
|
||||
_ = (Color32)m_TextComponent.color;
|
||||
while (true)
|
||||
{
|
||||
int characterCount = textInfo.characterCount;
|
||||
if (characterCount == 0)
|
||||
{
|
||||
yield return new WaitForSeconds(0.25f);
|
||||
continue;
|
||||
}
|
||||
int materialReferenceIndex = textInfo.characterInfo[currentCharacter].materialReferenceIndex;
|
||||
Color32[] colors = textInfo.meshInfo[materialReferenceIndex].colors32;
|
||||
int vertexIndex = textInfo.characterInfo[currentCharacter].vertexIndex;
|
||||
if (textInfo.characterInfo[currentCharacter].isVisible)
|
||||
{
|
||||
colors[vertexIndex + 3] = (colors[vertexIndex + 2] = (colors[vertexIndex + 1] = (colors[vertexIndex] = new Color32((byte)Random.Range(0, 255), (byte)Random.Range(0, 255), (byte)Random.Range(0, 255), byte.MaxValue))));
|
||||
m_TextComponent.UpdateVertexData(TMP_VertexDataUpdateFlags.Colors32);
|
||||
}
|
||||
currentCharacter = (currentCharacter + 1) % characterCount;
|
||||
yield return new WaitForSeconds(0.05f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f15a49c655e724fde939390b55b5dd92
|
||||
timeCreated: 1754266431
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
externalObjects: {}
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+118
@@ -0,0 +1,118 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TMPro.Examples
|
||||
{
|
||||
public class VertexJitter : MonoBehaviour
|
||||
{
|
||||
private struct VertexAnim
|
||||
{
|
||||
public float angleRange;
|
||||
|
||||
public float angle;
|
||||
|
||||
public float speed;
|
||||
}
|
||||
|
||||
public float AngleMultiplier = 1f;
|
||||
|
||||
public float SpeedMultiplier = 1f;
|
||||
|
||||
public float CurveScale = 1f;
|
||||
|
||||
private TMP_Text m_TextComponent;
|
||||
|
||||
private bool hasTextChanged;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
m_TextComponent = GetComponent<TMP_Text>();
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
TMPro_EventManager.TEXT_CHANGED_EVENT.Add(ON_TEXT_CHANGED);
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
TMPro_EventManager.TEXT_CHANGED_EVENT.Remove(ON_TEXT_CHANGED);
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
StartCoroutine(AnimateVertexColors());
|
||||
}
|
||||
|
||||
private void ON_TEXT_CHANGED(Object obj)
|
||||
{
|
||||
if (obj == m_TextComponent)
|
||||
{
|
||||
hasTextChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator AnimateVertexColors()
|
||||
{
|
||||
m_TextComponent.ForceMeshUpdate();
|
||||
TMP_TextInfo textInfo = m_TextComponent.textInfo;
|
||||
int loopCount = 0;
|
||||
hasTextChanged = true;
|
||||
VertexAnim[] vertexAnim = new VertexAnim[1024];
|
||||
for (int i = 0; i < 1024; i++)
|
||||
{
|
||||
vertexAnim[i].angleRange = Random.Range(10f, 25f);
|
||||
vertexAnim[i].speed = Random.Range(1f, 3f);
|
||||
}
|
||||
TMP_MeshInfo[] cachedMeshInfo = textInfo.CopyMeshInfoVertexData();
|
||||
while (true)
|
||||
{
|
||||
if (hasTextChanged)
|
||||
{
|
||||
cachedMeshInfo = textInfo.CopyMeshInfoVertexData();
|
||||
hasTextChanged = false;
|
||||
}
|
||||
int characterCount = textInfo.characterCount;
|
||||
if (characterCount == 0)
|
||||
{
|
||||
yield return new WaitForSeconds(0.25f);
|
||||
continue;
|
||||
}
|
||||
for (int j = 0; j < characterCount; j++)
|
||||
{
|
||||
if (textInfo.characterInfo[j].isVisible)
|
||||
{
|
||||
VertexAnim vertexAnim2 = vertexAnim[j];
|
||||
int materialReferenceIndex = textInfo.characterInfo[j].materialReferenceIndex;
|
||||
int vertexIndex = textInfo.characterInfo[j].vertexIndex;
|
||||
Vector3[] vertices = cachedMeshInfo[materialReferenceIndex].vertices;
|
||||
Vector3 vector = (Vector2)((vertices[vertexIndex] + vertices[vertexIndex + 2]) / 2f);
|
||||
Vector3[] vertices2 = textInfo.meshInfo[materialReferenceIndex].vertices;
|
||||
vertices2[vertexIndex] = vertices[vertexIndex] - vector;
|
||||
vertices2[vertexIndex + 1] = vertices[vertexIndex + 1] - vector;
|
||||
vertices2[vertexIndex + 2] = vertices[vertexIndex + 2] - vector;
|
||||
vertices2[vertexIndex + 3] = vertices[vertexIndex + 3] - vector;
|
||||
vertexAnim2.angle = Mathf.SmoothStep(0f - vertexAnim2.angleRange, vertexAnim2.angleRange, Mathf.PingPong((float)loopCount / 25f * vertexAnim2.speed, 1f));
|
||||
Matrix4x4 matrix4x = Matrix4x4.TRS(new Vector3(Random.Range(-0.25f, 0.25f), Random.Range(-0.25f, 0.25f), 0f) * CurveScale, Quaternion.Euler(0f, 0f, Random.Range(-5f, 5f) * AngleMultiplier), Vector3.one);
|
||||
vertices2[vertexIndex] = matrix4x.MultiplyPoint3x4(vertices2[vertexIndex]);
|
||||
vertices2[vertexIndex + 1] = matrix4x.MultiplyPoint3x4(vertices2[vertexIndex + 1]);
|
||||
vertices2[vertexIndex + 2] = matrix4x.MultiplyPoint3x4(vertices2[vertexIndex + 2]);
|
||||
vertices2[vertexIndex + 3] = matrix4x.MultiplyPoint3x4(vertices2[vertexIndex + 3]);
|
||||
vertices2[vertexIndex] += vector;
|
||||
vertices2[vertexIndex + 1] += vector;
|
||||
vertices2[vertexIndex + 2] += vector;
|
||||
vertices2[vertexIndex + 3] += vector;
|
||||
vertexAnim[j] = vertexAnim2;
|
||||
}
|
||||
}
|
||||
for (int k = 0; k < textInfo.meshInfo.Length; k++)
|
||||
{
|
||||
textInfo.meshInfo[k].mesh.vertices = textInfo.meshInfo[k].vertices;
|
||||
m_TextComponent.UpdateGeometry(textInfo.meshInfo[k].mesh, k);
|
||||
}
|
||||
loopCount++;
|
||||
yield return new WaitForSeconds(0.1f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2bae53bce5ebb1df3e08cbf70e12e1da
|
||||
timeCreated: 1754266431
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
externalObjects: {}
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+114
@@ -0,0 +1,114 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TMPro.Examples
|
||||
{
|
||||
public class VertexShakeA : MonoBehaviour
|
||||
{
|
||||
public float AngleMultiplier = 1f;
|
||||
|
||||
public float SpeedMultiplier = 1f;
|
||||
|
||||
public float ScaleMultiplier = 1f;
|
||||
|
||||
public float RotationMultiplier = 1f;
|
||||
|
||||
private TMP_Text m_TextComponent;
|
||||
|
||||
private bool hasTextChanged;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
m_TextComponent = GetComponent<TMP_Text>();
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
TMPro_EventManager.TEXT_CHANGED_EVENT.Add(ON_TEXT_CHANGED);
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
TMPro_EventManager.TEXT_CHANGED_EVENT.Remove(ON_TEXT_CHANGED);
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
StartCoroutine(AnimateVertexColors());
|
||||
}
|
||||
|
||||
private void ON_TEXT_CHANGED(Object obj)
|
||||
{
|
||||
if ((bool)(obj = m_TextComponent))
|
||||
{
|
||||
hasTextChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator AnimateVertexColors()
|
||||
{
|
||||
m_TextComponent.ForceMeshUpdate();
|
||||
TMP_TextInfo textInfo = m_TextComponent.textInfo;
|
||||
Vector3[][] copyOfVertices = new Vector3[0][];
|
||||
hasTextChanged = true;
|
||||
while (true)
|
||||
{
|
||||
if (hasTextChanged)
|
||||
{
|
||||
if (copyOfVertices.Length < textInfo.meshInfo.Length)
|
||||
{
|
||||
copyOfVertices = new Vector3[textInfo.meshInfo.Length][];
|
||||
}
|
||||
for (int i = 0; i < textInfo.meshInfo.Length; i++)
|
||||
{
|
||||
int num = textInfo.meshInfo[i].vertices.Length;
|
||||
copyOfVertices[i] = new Vector3[num];
|
||||
}
|
||||
hasTextChanged = false;
|
||||
}
|
||||
if (textInfo.characterCount == 0)
|
||||
{
|
||||
yield return new WaitForSeconds(0.25f);
|
||||
continue;
|
||||
}
|
||||
int lineCount = textInfo.lineCount;
|
||||
for (int j = 0; j < lineCount; j++)
|
||||
{
|
||||
int firstCharacterIndex = textInfo.lineInfo[j].firstCharacterIndex;
|
||||
int lastCharacterIndex = textInfo.lineInfo[j].lastCharacterIndex;
|
||||
Vector3 vector = (textInfo.characterInfo[firstCharacterIndex].bottomLeft + textInfo.characterInfo[lastCharacterIndex].topRight) / 2f;
|
||||
Quaternion q = Quaternion.Euler(0f, 0f, Random.Range(-0.25f, 0.25f) * RotationMultiplier);
|
||||
for (int k = firstCharacterIndex; k <= lastCharacterIndex; k++)
|
||||
{
|
||||
if (textInfo.characterInfo[k].isVisible)
|
||||
{
|
||||
int materialReferenceIndex = textInfo.characterInfo[k].materialReferenceIndex;
|
||||
int vertexIndex = textInfo.characterInfo[k].vertexIndex;
|
||||
Vector3[] vertices = textInfo.meshInfo[materialReferenceIndex].vertices;
|
||||
copyOfVertices[materialReferenceIndex][vertexIndex] = vertices[vertexIndex] - vector;
|
||||
copyOfVertices[materialReferenceIndex][vertexIndex + 1] = vertices[vertexIndex + 1] - vector;
|
||||
copyOfVertices[materialReferenceIndex][vertexIndex + 2] = vertices[vertexIndex + 2] - vector;
|
||||
copyOfVertices[materialReferenceIndex][vertexIndex + 3] = vertices[vertexIndex + 3] - vector;
|
||||
float num2 = Random.Range(0.995f - 0.001f * ScaleMultiplier, 1.005f + 0.001f * ScaleMultiplier);
|
||||
Matrix4x4 matrix4x = Matrix4x4.TRS(Vector3.one, q, Vector3.one * num2);
|
||||
copyOfVertices[materialReferenceIndex][vertexIndex] = matrix4x.MultiplyPoint3x4(copyOfVertices[materialReferenceIndex][vertexIndex]);
|
||||
copyOfVertices[materialReferenceIndex][vertexIndex + 1] = matrix4x.MultiplyPoint3x4(copyOfVertices[materialReferenceIndex][vertexIndex + 1]);
|
||||
copyOfVertices[materialReferenceIndex][vertexIndex + 2] = matrix4x.MultiplyPoint3x4(copyOfVertices[materialReferenceIndex][vertexIndex + 2]);
|
||||
copyOfVertices[materialReferenceIndex][vertexIndex + 3] = matrix4x.MultiplyPoint3x4(copyOfVertices[materialReferenceIndex][vertexIndex + 3]);
|
||||
copyOfVertices[materialReferenceIndex][vertexIndex] += vector;
|
||||
copyOfVertices[materialReferenceIndex][vertexIndex + 1] += vector;
|
||||
copyOfVertices[materialReferenceIndex][vertexIndex + 2] += vector;
|
||||
copyOfVertices[materialReferenceIndex][vertexIndex + 3] += vector;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int l = 0; l < textInfo.meshInfo.Length; l++)
|
||||
{
|
||||
textInfo.meshInfo[l].mesh.vertices = copyOfVertices[l];
|
||||
m_TextComponent.UpdateGeometry(textInfo.meshInfo[l].mesh, l);
|
||||
}
|
||||
yield return new WaitForSeconds(0.1f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6fc005c7e23ff6c2592fcc6544ac9c8a
|
||||
timeCreated: 1754266431
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
externalObjects: {}
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+126
@@ -0,0 +1,126 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TMPro.Examples
|
||||
{
|
||||
public class VertexShakeB : MonoBehaviour
|
||||
{
|
||||
public float AngleMultiplier = 1f;
|
||||
|
||||
public float SpeedMultiplier = 1f;
|
||||
|
||||
public float CurveScale = 1f;
|
||||
|
||||
private TMP_Text m_TextComponent;
|
||||
|
||||
private bool hasTextChanged;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
m_TextComponent = GetComponent<TMP_Text>();
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
TMPro_EventManager.TEXT_CHANGED_EVENT.Add(ON_TEXT_CHANGED);
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
TMPro_EventManager.TEXT_CHANGED_EVENT.Remove(ON_TEXT_CHANGED);
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
StartCoroutine(AnimateVertexColors());
|
||||
}
|
||||
|
||||
private void ON_TEXT_CHANGED(Object obj)
|
||||
{
|
||||
if ((bool)(obj = m_TextComponent))
|
||||
{
|
||||
hasTextChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator AnimateVertexColors()
|
||||
{
|
||||
m_TextComponent.ForceMeshUpdate();
|
||||
TMP_TextInfo textInfo = m_TextComponent.textInfo;
|
||||
Vector3[][] copyOfVertices = new Vector3[0][];
|
||||
hasTextChanged = true;
|
||||
while (true)
|
||||
{
|
||||
if (hasTextChanged)
|
||||
{
|
||||
if (copyOfVertices.Length < textInfo.meshInfo.Length)
|
||||
{
|
||||
copyOfVertices = new Vector3[textInfo.meshInfo.Length][];
|
||||
}
|
||||
for (int i = 0; i < textInfo.meshInfo.Length; i++)
|
||||
{
|
||||
int num = textInfo.meshInfo[i].vertices.Length;
|
||||
copyOfVertices[i] = new Vector3[num];
|
||||
}
|
||||
hasTextChanged = false;
|
||||
}
|
||||
if (textInfo.characterCount == 0)
|
||||
{
|
||||
yield return new WaitForSeconds(0.25f);
|
||||
continue;
|
||||
}
|
||||
int lineCount = textInfo.lineCount;
|
||||
for (int j = 0; j < lineCount; j++)
|
||||
{
|
||||
int firstCharacterIndex = textInfo.lineInfo[j].firstCharacterIndex;
|
||||
int lastCharacterIndex = textInfo.lineInfo[j].lastCharacterIndex;
|
||||
Vector3 vector = (textInfo.characterInfo[firstCharacterIndex].bottomLeft + textInfo.characterInfo[lastCharacterIndex].topRight) / 2f;
|
||||
Quaternion q = Quaternion.Euler(0f, 0f, Random.Range(-0.25f, 0.25f));
|
||||
for (int k = firstCharacterIndex; k <= lastCharacterIndex; k++)
|
||||
{
|
||||
if (textInfo.characterInfo[k].isVisible)
|
||||
{
|
||||
int materialReferenceIndex = textInfo.characterInfo[k].materialReferenceIndex;
|
||||
int vertexIndex = textInfo.characterInfo[k].vertexIndex;
|
||||
Vector3[] vertices = textInfo.meshInfo[materialReferenceIndex].vertices;
|
||||
Vector3 vector2 = (vertices[vertexIndex] + vertices[vertexIndex + 2]) / 2f;
|
||||
copyOfVertices[materialReferenceIndex][vertexIndex] = vertices[vertexIndex] - vector2;
|
||||
copyOfVertices[materialReferenceIndex][vertexIndex + 1] = vertices[vertexIndex + 1] - vector2;
|
||||
copyOfVertices[materialReferenceIndex][vertexIndex + 2] = vertices[vertexIndex + 2] - vector2;
|
||||
copyOfVertices[materialReferenceIndex][vertexIndex + 3] = vertices[vertexIndex + 3] - vector2;
|
||||
float num2 = Random.Range(0.95f, 1.05f);
|
||||
Matrix4x4 matrix4x = Matrix4x4.TRS(Vector3.one, Quaternion.identity, Vector3.one * num2);
|
||||
copyOfVertices[materialReferenceIndex][vertexIndex] = matrix4x.MultiplyPoint3x4(copyOfVertices[materialReferenceIndex][vertexIndex]);
|
||||
copyOfVertices[materialReferenceIndex][vertexIndex + 1] = matrix4x.MultiplyPoint3x4(copyOfVertices[materialReferenceIndex][vertexIndex + 1]);
|
||||
copyOfVertices[materialReferenceIndex][vertexIndex + 2] = matrix4x.MultiplyPoint3x4(copyOfVertices[materialReferenceIndex][vertexIndex + 2]);
|
||||
copyOfVertices[materialReferenceIndex][vertexIndex + 3] = matrix4x.MultiplyPoint3x4(copyOfVertices[materialReferenceIndex][vertexIndex + 3]);
|
||||
copyOfVertices[materialReferenceIndex][vertexIndex] += vector2;
|
||||
copyOfVertices[materialReferenceIndex][vertexIndex + 1] += vector2;
|
||||
copyOfVertices[materialReferenceIndex][vertexIndex + 2] += vector2;
|
||||
copyOfVertices[materialReferenceIndex][vertexIndex + 3] += vector2;
|
||||
copyOfVertices[materialReferenceIndex][vertexIndex] -= vector;
|
||||
copyOfVertices[materialReferenceIndex][vertexIndex + 1] -= vector;
|
||||
copyOfVertices[materialReferenceIndex][vertexIndex + 2] -= vector;
|
||||
copyOfVertices[materialReferenceIndex][vertexIndex + 3] -= vector;
|
||||
matrix4x = Matrix4x4.TRS(Vector3.one, q, Vector3.one);
|
||||
copyOfVertices[materialReferenceIndex][vertexIndex] = matrix4x.MultiplyPoint3x4(copyOfVertices[materialReferenceIndex][vertexIndex]);
|
||||
copyOfVertices[materialReferenceIndex][vertexIndex + 1] = matrix4x.MultiplyPoint3x4(copyOfVertices[materialReferenceIndex][vertexIndex + 1]);
|
||||
copyOfVertices[materialReferenceIndex][vertexIndex + 2] = matrix4x.MultiplyPoint3x4(copyOfVertices[materialReferenceIndex][vertexIndex + 2]);
|
||||
copyOfVertices[materialReferenceIndex][vertexIndex + 3] = matrix4x.MultiplyPoint3x4(copyOfVertices[materialReferenceIndex][vertexIndex + 3]);
|
||||
copyOfVertices[materialReferenceIndex][vertexIndex] += vector;
|
||||
copyOfVertices[materialReferenceIndex][vertexIndex + 1] += vector;
|
||||
copyOfVertices[materialReferenceIndex][vertexIndex + 2] += vector;
|
||||
copyOfVertices[materialReferenceIndex][vertexIndex + 3] += vector;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int l = 0; l < textInfo.meshInfo.Length; l++)
|
||||
{
|
||||
textInfo.meshInfo[l].mesh.vertices = copyOfVertices[l];
|
||||
m_TextComponent.UpdateGeometry(textInfo.meshInfo[l].mesh, l);
|
||||
}
|
||||
yield return new WaitForSeconds(0.1f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e7b927fab84054fe0ef0f4c6efbe00b1
|
||||
timeCreated: 1754266431
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
externalObjects: {}
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+122
@@ -0,0 +1,122 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TMPro.Examples
|
||||
{
|
||||
public class VertexZoom : MonoBehaviour
|
||||
{
|
||||
public float AngleMultiplier = 1f;
|
||||
|
||||
public float SpeedMultiplier = 1f;
|
||||
|
||||
public float CurveScale = 1f;
|
||||
|
||||
private TMP_Text m_TextComponent;
|
||||
|
||||
private bool hasTextChanged;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
m_TextComponent = GetComponent<TMP_Text>();
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
TMPro_EventManager.TEXT_CHANGED_EVENT.Add(ON_TEXT_CHANGED);
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
TMPro_EventManager.TEXT_CHANGED_EVENT.Remove(ON_TEXT_CHANGED);
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
StartCoroutine(AnimateVertexColors());
|
||||
}
|
||||
|
||||
private void ON_TEXT_CHANGED(Object obj)
|
||||
{
|
||||
if (obj == m_TextComponent)
|
||||
{
|
||||
hasTextChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator AnimateVertexColors()
|
||||
{
|
||||
m_TextComponent.ForceMeshUpdate();
|
||||
TMP_TextInfo textInfo = m_TextComponent.textInfo;
|
||||
TMP_MeshInfo[] cachedMeshInfoVertexData = textInfo.CopyMeshInfoVertexData();
|
||||
List<float> modifiedCharScale = new List<float>();
|
||||
List<int> scaleSortingOrder = new List<int>();
|
||||
hasTextChanged = true;
|
||||
while (true)
|
||||
{
|
||||
if (hasTextChanged)
|
||||
{
|
||||
cachedMeshInfoVertexData = textInfo.CopyMeshInfoVertexData();
|
||||
hasTextChanged = false;
|
||||
}
|
||||
int characterCount = textInfo.characterCount;
|
||||
if (characterCount == 0)
|
||||
{
|
||||
yield return new WaitForSeconds(0.25f);
|
||||
continue;
|
||||
}
|
||||
modifiedCharScale.Clear();
|
||||
scaleSortingOrder.Clear();
|
||||
for (int i = 0; i < characterCount; i++)
|
||||
{
|
||||
if (textInfo.characterInfo[i].isVisible)
|
||||
{
|
||||
int materialReferenceIndex = textInfo.characterInfo[i].materialReferenceIndex;
|
||||
int vertexIndex = textInfo.characterInfo[i].vertexIndex;
|
||||
Vector3[] vertices = cachedMeshInfoVertexData[materialReferenceIndex].vertices;
|
||||
Vector3 vector = (Vector2)((vertices[vertexIndex] + vertices[vertexIndex + 2]) / 2f);
|
||||
Vector3[] vertices2 = textInfo.meshInfo[materialReferenceIndex].vertices;
|
||||
vertices2[vertexIndex] = vertices[vertexIndex] - vector;
|
||||
vertices2[vertexIndex + 1] = vertices[vertexIndex + 1] - vector;
|
||||
vertices2[vertexIndex + 2] = vertices[vertexIndex + 2] - vector;
|
||||
vertices2[vertexIndex + 3] = vertices[vertexIndex + 3] - vector;
|
||||
float num = Random.Range(1f, 1.5f);
|
||||
modifiedCharScale.Add(num);
|
||||
scaleSortingOrder.Add(modifiedCharScale.Count - 1);
|
||||
Matrix4x4 matrix4x = Matrix4x4.TRS(new Vector3(0f, 0f, 0f), Quaternion.identity, Vector3.one * num);
|
||||
vertices2[vertexIndex] = matrix4x.MultiplyPoint3x4(vertices2[vertexIndex]);
|
||||
vertices2[vertexIndex + 1] = matrix4x.MultiplyPoint3x4(vertices2[vertexIndex + 1]);
|
||||
vertices2[vertexIndex + 2] = matrix4x.MultiplyPoint3x4(vertices2[vertexIndex + 2]);
|
||||
vertices2[vertexIndex + 3] = matrix4x.MultiplyPoint3x4(vertices2[vertexIndex + 3]);
|
||||
vertices2[vertexIndex] += vector;
|
||||
vertices2[vertexIndex + 1] += vector;
|
||||
vertices2[vertexIndex + 2] += vector;
|
||||
vertices2[vertexIndex + 3] += vector;
|
||||
Vector2[] uvs = cachedMeshInfoVertexData[materialReferenceIndex].uvs0;
|
||||
Vector2[] uvs2 = textInfo.meshInfo[materialReferenceIndex].uvs0;
|
||||
uvs2[vertexIndex] = uvs[vertexIndex];
|
||||
uvs2[vertexIndex + 1] = uvs[vertexIndex + 1];
|
||||
uvs2[vertexIndex + 2] = uvs[vertexIndex + 2];
|
||||
uvs2[vertexIndex + 3] = uvs[vertexIndex + 3];
|
||||
Color32[] colors = cachedMeshInfoVertexData[materialReferenceIndex].colors32;
|
||||
Color32[] colors2 = textInfo.meshInfo[materialReferenceIndex].colors32;
|
||||
colors2[vertexIndex] = colors[vertexIndex];
|
||||
colors2[vertexIndex + 1] = colors[vertexIndex + 1];
|
||||
colors2[vertexIndex + 2] = colors[vertexIndex + 2];
|
||||
colors2[vertexIndex + 3] = colors[vertexIndex + 3];
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < textInfo.meshInfo.Length; j++)
|
||||
{
|
||||
scaleSortingOrder.Sort((int a, int b) => modifiedCharScale[a].CompareTo(modifiedCharScale[b]));
|
||||
textInfo.meshInfo[j].SortGeometry(scaleSortingOrder);
|
||||
textInfo.meshInfo[j].mesh.vertices = textInfo.meshInfo[j].vertices;
|
||||
textInfo.meshInfo[j].mesh.uv = textInfo.meshInfo[j].uvs0;
|
||||
textInfo.meshInfo[j].mesh.colors32 = textInfo.meshInfo[j].colors32;
|
||||
m_TextComponent.UpdateGeometry(textInfo.meshInfo[j].mesh, j);
|
||||
}
|
||||
yield return new WaitForSeconds(0.1f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fbfbeba88a7f8386c1e84804ac5497e2
|
||||
timeCreated: 1754266431
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
externalObjects: {}
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+98
@@ -0,0 +1,98 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TMPro.Examples
|
||||
{
|
||||
public class WarpTextExample : MonoBehaviour
|
||||
{
|
||||
private TMP_Text m_TextComponent;
|
||||
|
||||
public AnimationCurve VertexCurve = new AnimationCurve(new Keyframe(0f, 0f), new Keyframe(0.25f, 2f), new Keyframe(0.5f, 0f), new Keyframe(0.75f, 2f), new Keyframe(1f, 0f));
|
||||
|
||||
public float AngleMultiplier = 1f;
|
||||
|
||||
public float SpeedMultiplier = 1f;
|
||||
|
||||
public float CurveScale = 1f;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
m_TextComponent = base.gameObject.GetComponent<TMP_Text>();
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
StartCoroutine(WarpText());
|
||||
}
|
||||
|
||||
private AnimationCurve CopyAnimationCurve(AnimationCurve curve)
|
||||
{
|
||||
return new AnimationCurve
|
||||
{
|
||||
keys = curve.keys
|
||||
};
|
||||
}
|
||||
|
||||
private IEnumerator WarpText()
|
||||
{
|
||||
VertexCurve.preWrapMode = WrapMode.Once;
|
||||
VertexCurve.postWrapMode = WrapMode.Once;
|
||||
m_TextComponent.havePropertiesChanged = true;
|
||||
CurveScale *= 10f;
|
||||
float old_CurveScale = CurveScale;
|
||||
AnimationCurve old_curve = CopyAnimationCurve(VertexCurve);
|
||||
while (true)
|
||||
{
|
||||
if (!m_TextComponent.havePropertiesChanged && old_CurveScale == CurveScale && old_curve.keys[1].value == VertexCurve.keys[1].value)
|
||||
{
|
||||
yield return null;
|
||||
continue;
|
||||
}
|
||||
old_CurveScale = CurveScale;
|
||||
old_curve = CopyAnimationCurve(VertexCurve);
|
||||
m_TextComponent.ForceMeshUpdate();
|
||||
TMP_TextInfo textInfo = m_TextComponent.textInfo;
|
||||
int characterCount = textInfo.characterCount;
|
||||
if (characterCount == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
float x = m_TextComponent.bounds.min.x;
|
||||
float x2 = m_TextComponent.bounds.max.x;
|
||||
for (int i = 0; i < characterCount; i++)
|
||||
{
|
||||
if (textInfo.characterInfo[i].isVisible)
|
||||
{
|
||||
int vertexIndex = textInfo.characterInfo[i].vertexIndex;
|
||||
int materialReferenceIndex = textInfo.characterInfo[i].materialReferenceIndex;
|
||||
Vector3[] vertices = textInfo.meshInfo[materialReferenceIndex].vertices;
|
||||
Vector3 vector = new Vector2((vertices[vertexIndex].x + vertices[vertexIndex + 2].x) / 2f, textInfo.characterInfo[i].baseLine);
|
||||
vertices[vertexIndex] += -vector;
|
||||
vertices[vertexIndex + 1] += -vector;
|
||||
vertices[vertexIndex + 2] += -vector;
|
||||
vertices[vertexIndex + 3] += -vector;
|
||||
float num = (vector.x - x) / (x2 - x);
|
||||
float num2 = num + 0.0001f;
|
||||
float y = VertexCurve.Evaluate(num) * CurveScale;
|
||||
float y2 = VertexCurve.Evaluate(num2) * CurveScale;
|
||||
Vector3 lhs = new Vector3(1f, 0f, 0f);
|
||||
Vector3 rhs = new Vector3(num2 * (x2 - x) + x, y2) - new Vector3(vector.x, y);
|
||||
float num3 = Mathf.Acos(Vector3.Dot(lhs, rhs.normalized)) * 57.29578f;
|
||||
float z = ((Vector3.Cross(lhs, rhs).z > 0f) ? num3 : (360f - num3));
|
||||
Matrix4x4 matrix4x = Matrix4x4.TRS(new Vector3(0f, y, 0f), Quaternion.Euler(0f, 0f, z), Vector3.one);
|
||||
vertices[vertexIndex] = matrix4x.MultiplyPoint3x4(vertices[vertexIndex]);
|
||||
vertices[vertexIndex + 1] = matrix4x.MultiplyPoint3x4(vertices[vertexIndex + 1]);
|
||||
vertices[vertexIndex + 2] = matrix4x.MultiplyPoint3x4(vertices[vertexIndex + 2]);
|
||||
vertices[vertexIndex + 3] = matrix4x.MultiplyPoint3x4(vertices[vertexIndex + 3]);
|
||||
vertices[vertexIndex] += vector;
|
||||
vertices[vertexIndex + 1] += vector;
|
||||
vertices[vertexIndex + 2] += vector;
|
||||
vertices[vertexIndex + 3] += vector;
|
||||
}
|
||||
}
|
||||
m_TextComponent.UpdateVertexData();
|
||||
yield return new WaitForSeconds(0.025f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7cd06716c7951d3df214b96b05d6b44c
|
||||
timeCreated: 1754266431
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
externalObjects: {}
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
|
||||
namespace TMPro
|
||||
{
|
||||
[Serializable]
|
||||
public class TMP_DigitValidator : TMP_InputValidator
|
||||
{
|
||||
public override char Validate(ref string text, ref int pos, char ch)
|
||||
{
|
||||
if (ch >= '0' && ch <= '9')
|
||||
{
|
||||
text += ch;
|
||||
pos++;
|
||||
return ch;
|
||||
}
|
||||
return '\0';
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e4ffb2f7ab803735689198c4bee849c6
|
||||
timeCreated: 1754266431
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
externalObjects: {}
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+124
@@ -0,0 +1,124 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TMPro
|
||||
{
|
||||
[Serializable]
|
||||
public class TMP_PhoneNumberValidator : TMP_InputValidator
|
||||
{
|
||||
public override char Validate(ref string text, ref int pos, char ch)
|
||||
{
|
||||
Debug.Log("Trying to validate...");
|
||||
if (ch < '0' && ch > '9')
|
||||
{
|
||||
return '\0';
|
||||
}
|
||||
int length = text.Length;
|
||||
for (int i = 0; i < length + 1; i++)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
if (i == length)
|
||||
{
|
||||
text = "(" + ch;
|
||||
}
|
||||
pos = 2;
|
||||
break;
|
||||
case 1:
|
||||
if (i == length)
|
||||
{
|
||||
text += ch;
|
||||
}
|
||||
pos = 2;
|
||||
break;
|
||||
case 2:
|
||||
if (i == length)
|
||||
{
|
||||
text += ch;
|
||||
}
|
||||
pos = 3;
|
||||
break;
|
||||
case 3:
|
||||
if (i == length)
|
||||
{
|
||||
text = text + ch + ") ";
|
||||
}
|
||||
pos = 6;
|
||||
break;
|
||||
case 4:
|
||||
if (i == length)
|
||||
{
|
||||
text = text + ") " + ch;
|
||||
}
|
||||
pos = 7;
|
||||
break;
|
||||
case 5:
|
||||
if (i == length)
|
||||
{
|
||||
text = text + " " + ch;
|
||||
}
|
||||
pos = 7;
|
||||
break;
|
||||
case 6:
|
||||
if (i == length)
|
||||
{
|
||||
text += ch;
|
||||
}
|
||||
pos = 7;
|
||||
break;
|
||||
case 7:
|
||||
if (i == length)
|
||||
{
|
||||
text += ch;
|
||||
}
|
||||
pos = 8;
|
||||
break;
|
||||
case 8:
|
||||
if (i == length)
|
||||
{
|
||||
text = text + ch + "-";
|
||||
}
|
||||
pos = 10;
|
||||
break;
|
||||
case 9:
|
||||
if (i == length)
|
||||
{
|
||||
text = text + "-" + ch;
|
||||
}
|
||||
pos = 11;
|
||||
break;
|
||||
case 10:
|
||||
if (i == length)
|
||||
{
|
||||
text += ch;
|
||||
}
|
||||
pos = 11;
|
||||
break;
|
||||
case 11:
|
||||
if (i == length)
|
||||
{
|
||||
text += ch;
|
||||
}
|
||||
pos = 12;
|
||||
break;
|
||||
case 12:
|
||||
if (i == length)
|
||||
{
|
||||
text += ch;
|
||||
}
|
||||
pos = 13;
|
||||
break;
|
||||
case 13:
|
||||
if (i == length)
|
||||
{
|
||||
text += ch;
|
||||
}
|
||||
pos = 14;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ch;
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ef463a078c3091e4533b2fbdcc487a4f
|
||||
timeCreated: 1754266431
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
externalObjects: {}
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+251
@@ -0,0 +1,251 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.Events;
|
||||
|
||||
namespace TMPro
|
||||
{
|
||||
public class TMP_TextEventHandler : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler
|
||||
{
|
||||
[Serializable]
|
||||
public class CharacterSelectionEvent : UnityEvent<char, int>
|
||||
{
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class SpriteSelectionEvent : UnityEvent<char, int>
|
||||
{
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class WordSelectionEvent : UnityEvent<string, int, int>
|
||||
{
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class LineSelectionEvent : UnityEvent<string, int, int>
|
||||
{
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class LinkSelectionEvent : UnityEvent<string, string, int>
|
||||
{
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
private CharacterSelectionEvent m_OnCharacterSelection = new CharacterSelectionEvent();
|
||||
|
||||
[SerializeField]
|
||||
private SpriteSelectionEvent m_OnSpriteSelection = new SpriteSelectionEvent();
|
||||
|
||||
[SerializeField]
|
||||
private WordSelectionEvent m_OnWordSelection = new WordSelectionEvent();
|
||||
|
||||
[SerializeField]
|
||||
private LineSelectionEvent m_OnLineSelection = new LineSelectionEvent();
|
||||
|
||||
[SerializeField]
|
||||
private LinkSelectionEvent m_OnLinkSelection = new LinkSelectionEvent();
|
||||
|
||||
private TMP_Text m_TextComponent;
|
||||
|
||||
private Camera m_Camera;
|
||||
|
||||
private Canvas m_Canvas;
|
||||
|
||||
private int m_selectedLink = -1;
|
||||
|
||||
private int m_lastCharIndex = -1;
|
||||
|
||||
private int m_lastWordIndex = -1;
|
||||
|
||||
private int m_lastLineIndex = -1;
|
||||
|
||||
public CharacterSelectionEvent onCharacterSelection
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_OnCharacterSelection;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_OnCharacterSelection = value;
|
||||
}
|
||||
}
|
||||
|
||||
public SpriteSelectionEvent onSpriteSelection
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_OnSpriteSelection;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_OnSpriteSelection = value;
|
||||
}
|
||||
}
|
||||
|
||||
public WordSelectionEvent onWordSelection
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_OnWordSelection;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_OnWordSelection = value;
|
||||
}
|
||||
}
|
||||
|
||||
public LineSelectionEvent onLineSelection
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_OnLineSelection;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_OnLineSelection = value;
|
||||
}
|
||||
}
|
||||
|
||||
public LinkSelectionEvent onLinkSelection
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_OnLinkSelection;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_OnLinkSelection = value;
|
||||
}
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
m_TextComponent = base.gameObject.GetComponent<TMP_Text>();
|
||||
if (m_TextComponent.GetType() == typeof(TextMeshProUGUI))
|
||||
{
|
||||
m_Canvas = base.gameObject.GetComponentInParent<Canvas>();
|
||||
if (m_Canvas != null)
|
||||
{
|
||||
if (m_Canvas.renderMode == RenderMode.ScreenSpaceOverlay)
|
||||
{
|
||||
m_Camera = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Camera = m_Canvas.worldCamera;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Camera = Camera.main;
|
||||
}
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
if (TMP_TextUtilities.IsIntersectingRectTransform(m_TextComponent.rectTransform, Input.mousePosition, m_Camera))
|
||||
{
|
||||
int num = TMP_TextUtilities.FindIntersectingCharacter(m_TextComponent, Input.mousePosition, m_Camera, visibleOnly: true);
|
||||
if (num != -1 && num != m_lastCharIndex)
|
||||
{
|
||||
m_lastCharIndex = num;
|
||||
switch (m_TextComponent.textInfo.characterInfo[num].elementType)
|
||||
{
|
||||
case TMP_TextElementType.Character:
|
||||
SendOnCharacterSelection(m_TextComponent.textInfo.characterInfo[num].character, num);
|
||||
break;
|
||||
case TMP_TextElementType.Sprite:
|
||||
SendOnSpriteSelection(m_TextComponent.textInfo.characterInfo[num].character, num);
|
||||
break;
|
||||
}
|
||||
}
|
||||
int num2 = TMP_TextUtilities.FindIntersectingWord(m_TextComponent, Input.mousePosition, m_Camera);
|
||||
if (num2 != -1 && num2 != m_lastWordIndex)
|
||||
{
|
||||
m_lastWordIndex = num2;
|
||||
TMP_WordInfo tMP_WordInfo = m_TextComponent.textInfo.wordInfo[num2];
|
||||
SendOnWordSelection(tMP_WordInfo.GetWord(), tMP_WordInfo.firstCharacterIndex, tMP_WordInfo.characterCount);
|
||||
}
|
||||
int num3 = TMP_TextUtilities.FindIntersectingLine(m_TextComponent, Input.mousePosition, m_Camera);
|
||||
if (num3 != -1 && num3 != m_lastLineIndex)
|
||||
{
|
||||
m_lastLineIndex = num3;
|
||||
TMP_LineInfo tMP_LineInfo = m_TextComponent.textInfo.lineInfo[num3];
|
||||
char[] array = new char[tMP_LineInfo.characterCount];
|
||||
for (int i = 0; i < tMP_LineInfo.characterCount && i < m_TextComponent.textInfo.characterInfo.Length; i++)
|
||||
{
|
||||
array[i] = m_TextComponent.textInfo.characterInfo[i + tMP_LineInfo.firstCharacterIndex].character;
|
||||
}
|
||||
string line = new string(array);
|
||||
SendOnLineSelection(line, tMP_LineInfo.firstCharacterIndex, tMP_LineInfo.characterCount);
|
||||
}
|
||||
int num4 = TMP_TextUtilities.FindIntersectingLink(m_TextComponent, Input.mousePosition, m_Camera);
|
||||
if (num4 != -1 && num4 != m_selectedLink)
|
||||
{
|
||||
m_selectedLink = num4;
|
||||
TMP_LinkInfo tMP_LinkInfo = m_TextComponent.textInfo.linkInfo[num4];
|
||||
SendOnLinkSelection(tMP_LinkInfo.GetLinkID(), tMP_LinkInfo.GetLinkText(), num4);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_selectedLink = -1;
|
||||
m_lastCharIndex = -1;
|
||||
m_lastWordIndex = -1;
|
||||
m_lastLineIndex = -1;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnPointerEnter(PointerEventData eventData)
|
||||
{
|
||||
}
|
||||
|
||||
public void OnPointerExit(PointerEventData eventData)
|
||||
{
|
||||
}
|
||||
|
||||
private void SendOnCharacterSelection(char character, int characterIndex)
|
||||
{
|
||||
if (onCharacterSelection != null)
|
||||
{
|
||||
onCharacterSelection.Invoke(character, characterIndex);
|
||||
}
|
||||
}
|
||||
|
||||
private void SendOnSpriteSelection(char character, int characterIndex)
|
||||
{
|
||||
if (onSpriteSelection != null)
|
||||
{
|
||||
onSpriteSelection.Invoke(character, characterIndex);
|
||||
}
|
||||
}
|
||||
|
||||
private void SendOnWordSelection(string word, int charIndex, int length)
|
||||
{
|
||||
if (onWordSelection != null)
|
||||
{
|
||||
onWordSelection.Invoke(word, charIndex, length);
|
||||
}
|
||||
}
|
||||
|
||||
private void SendOnLineSelection(string line, int charIndex, int length)
|
||||
{
|
||||
if (onLineSelection != null)
|
||||
{
|
||||
onLineSelection.Invoke(line, charIndex, length);
|
||||
}
|
||||
}
|
||||
|
||||
private void SendOnLinkSelection(string linkID, string linkText, int linkIndex)
|
||||
{
|
||||
if (onLinkSelection != null)
|
||||
{
|
||||
onLinkSelection.Invoke(linkID, linkText, linkIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2744e1a639fc99f1ff213a39e8340251
|
||||
timeCreated: 1754266431
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
externalObjects: {}
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in new issue
Block a user