Imported UI Assets

This commit is contained in:
MarcoHampel
2024-02-01 22:45:59 -05:00
parent 95a3f673f0
commit 5192d8b669
1355 changed files with 518302 additions and 153 deletions

View File

@ -0,0 +1,19 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
namespace Michsky.UI.Heat
{
public class AchievementItem : MonoBehaviour
{
[Header("Default Resources")]
public Image iconObj;
public Image backgroundObj;
public TextMeshProUGUI titleObj;
public TextMeshProUGUI descriptionObj;
public GameObject lockedIndicator;
public GameObject unlockedIndicator;
public List<Image> images = new List<Image>();
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 809099ef27bb0814dad7bf0236c078f7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: 9dea0dfd7806a334e886b3f8a1b14b82, type: 3}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 264857
packageName: Heat - Complete Modern UI
packageVersion: 1.0.4
assetPath: Assets/Heat - Complete Modern UI/Scripts/Achievements/AchievementItem.cs
uploadId: 629893

View File

@ -0,0 +1,41 @@
using System.Collections.Generic;
using UnityEngine;
namespace Michsky.UI.Heat
{
[CreateAssetMenu(fileName = "New Achievement Library", menuName = "Heat UI/Achievement Library")]
public class AchievementLibrary : ScriptableObject
{
[Space(10)]
public List<AchievementItem> achievements = new List<AchievementItem>();
public enum AchievementType { Common, Rare, Legendary }
public enum DataBehaviour { Default, Unlocked }
[System.Serializable]
public class AchievementItem
{
public string title = "New Achievement";
public Sprite icon;
[TextArea] public string description;
public AchievementType type;
public DataBehaviour dataBehaviour;
[Header("Hidden")]
public bool isHidden;
public string hiddenTitle = "Hidden Achievement";
public Sprite hiddenIcon;
[TextArea] public string hiddenDescription = "This is a hidden achievement and must be unlocked to preview.";
[Header("Localization")]
[Tooltip("If you're not using localization, you can leave this field blank.")]
public string titleKey;
[Tooltip("If you're not using localization, you can leave this field blank.")]
public string decriptionKey;
[Tooltip("If you're not using localization, you can leave this field blank.")]
public string hiddenTitleKey = "AchievementHiddenTitle";
[Tooltip("If you're not using localization, you can leave this field blank.")]
public string hiddenDescKey = "AchievementHiddenDesc";
}
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: c6902ec504077034682a24926832eb0e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: 9dea0dfd7806a334e886b3f8a1b14b82, type: 3}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 264857
packageName: Heat - Complete Modern UI
packageVersion: 1.0.4
assetPath: Assets/Heat - Complete Modern UI/Scripts/Achievements/AchievementLibrary.cs
uploadId: 629893

View File

@ -0,0 +1,248 @@
using UnityEngine;
using UnityEngine.UI;
using TMPro;
namespace Michsky.UI.Heat
{
[DisallowMultipleComponent]
public class AchievementManager : MonoBehaviour
{
// Resources
public UIManager UIManagerAsset;
[SerializeField] private Transform allParent;
[SerializeField] private Transform commonParent;
[SerializeField] private Transform rareParent;
[SerializeField] private Transform legendaryParent;
[SerializeField] private GameObject achievementPreset;
[SerializeField] private TextMeshProUGUI totalUnlockedObj;
[SerializeField] private TextMeshProUGUI totalValueObj;
[SerializeField] private TextMeshProUGUI commonUnlockedObj;
[SerializeField] private TextMeshProUGUI commonlTotalObj;
[SerializeField] private TextMeshProUGUI rareUnlockedObj;
[SerializeField] private TextMeshProUGUI rareTotalObj;
[SerializeField] private TextMeshProUGUI legendaryUnlockedObj;
[SerializeField] private TextMeshProUGUI legendaryTotalObj;
// Settings
public bool useLocalization = true;
[SerializeField] private bool useAlphabeticalOrder = true;
// Values
int totalCount;
int commonCount;
int rareCount;
int legendaryCount;
int totalUnlockedCount;
int commonUnlockedCount;
int rareUnlockedCount;
int legendaryUnlockedCount;
// Helpers
LocalizedObject localizedObject;
void Awake()
{
InitializeItems();
}
static int SortByName(AchievementLibrary.AchievementItem o1, AchievementLibrary.AchievementItem o2)
{
// Compare the names and sort by A to Z
return o1.title.CompareTo(o2.title);
}
public void InitializeItems()
{
// Check for core resources
if (UIManagerAsset == null || UIManagerAsset.achievementLibrary == null || achievementPreset == null)
return;
// Sort achievements by alphabetical order if enabled
if (useAlphabeticalOrder == true)
UIManagerAsset.achievementLibrary.achievements.Sort(SortByName);
// Check for localization
if (useLocalization == true)
{
localizedObject = gameObject.GetComponent<LocalizedObject>();
if (localizedObject == null || localizedObject.CheckLocalizationStatus() == false) { useLocalization = false; }
}
// Clear parent transforms and start the loop
foreach (Transform child in allParent) { Destroy(child.gameObject); }
foreach (Transform child in commonParent) { Destroy(child.gameObject); }
foreach (Transform child in rareParent) { Destroy(child.gameObject); }
foreach (Transform child in legendaryParent) { Destroy(child.gameObject); }
for (int i = 0; i < UIManagerAsset.achievementLibrary.achievements.Count; i++)
{
// Temp variables
Transform parent = null;
AchievementLibrary.AchievementType type = default;
totalCount++;
// Set achievement type and parent
if (UIManagerAsset.achievementLibrary.achievements[i].type == AchievementLibrary.AchievementType.Common) { parent = commonParent; type = AchievementLibrary.AchievementType.Common; commonCount++; }
else if (UIManagerAsset.achievementLibrary.achievements[i].type == AchievementLibrary.AchievementType.Rare) { parent = rareParent; type = AchievementLibrary.AchievementType.Rare; rareCount++; }
else if (UIManagerAsset.achievementLibrary.achievements[i].type == AchievementLibrary.AchievementType.Legendary) { parent = legendaryParent; type = AchievementLibrary.AchievementType.Legendary; legendaryCount++; }
// Create the base object
GameObject go = Instantiate(achievementPreset, new Vector3(0, 0, 0), Quaternion.identity) as GameObject;
go.transform.SetParent(parent, false);
// Get the ach component
AchievementItem tempAI = go.GetComponent<AchievementItem>();
tempAI.lockedIndicator.SetActive(true);
tempAI.unlockedIndicator.SetActive(false);
// Check for the state
if (UIManagerAsset.achievementLibrary.achievements[i].isHidden == true
&& PlayerPrefs.GetString("ACH_" + UIManagerAsset.achievementLibrary.achievements[i].title) == "true"
|| UIManagerAsset.achievementLibrary.achievements[i].isHidden == false
|| UIManagerAsset.achievementLibrary.achievements[i].dataBehaviour == AchievementLibrary.DataBehaviour.Unlocked)
{
tempAI.iconObj.sprite = UIManagerAsset.achievementLibrary.achievements[i].icon;
// Check for localization
if (useLocalization == false)
{
tempAI.titleObj.text = UIManagerAsset.achievementLibrary.achievements[i].title;
tempAI.descriptionObj.text = UIManagerAsset.achievementLibrary.achievements[i].description;
}
else
{
LocalizedObject titleLoc = tempAI.titleObj.GetComponent<LocalizedObject>();
if (titleLoc != null) { titleLoc.tableIndex = localizedObject.tableIndex; titleLoc.localizationKey = UIManagerAsset.achievementLibrary.achievements[i].titleKey; }
LocalizedObject descLoc = tempAI.descriptionObj.GetComponent<LocalizedObject>();
if (descLoc != null) { descLoc.tableIndex = localizedObject.tableIndex; descLoc.localizationKey = UIManagerAsset.achievementLibrary.achievements[i].decriptionKey; }
}
}
// Set hidden if it's not unlocked and marked as hidden
else
{
tempAI.iconObj.sprite = UIManagerAsset.achievementLibrary.achievements[i].hiddenIcon;
// Check for localization
if (useLocalization == false)
{
tempAI.titleObj.text = UIManagerAsset.achievementLibrary.achievements[i].hiddenTitle;
tempAI.descriptionObj.text = UIManagerAsset.achievementLibrary.achievements[i].hiddenDescription;
}
else
{
LocalizedObject titleLoc = tempAI.titleObj.GetComponent<LocalizedObject>();
if (titleLoc != null) { titleLoc.tableIndex = localizedObject.tableIndex; titleLoc.localizationKey = UIManagerAsset.achievementLibrary.achievements[i].hiddenTitleKey; }
LocalizedObject descLoc = tempAI.descriptionObj.GetComponent<LocalizedObject>();
if (descLoc != null) { descLoc.tableIndex = localizedObject.tableIndex; descLoc.localizationKey = UIManagerAsset.achievementLibrary.achievements[i].hiddenDescKey; }
}
}
// Change variable colors depending on the ach type
for (int x = 0; x < tempAI.images.Count; x++)
{
if (type == AchievementLibrary.AchievementType.Common) { tempAI.images[x].color = new Color(UIManagerAsset.commonColor.r, UIManagerAsset.commonColor.g, UIManagerAsset.commonColor.b, tempAI.images[x].color.a); }
else if (type == AchievementLibrary.AchievementType.Rare) { tempAI.images[x].color = new Color(UIManagerAsset.rareColor.r, UIManagerAsset.rareColor.g, UIManagerAsset.rareColor.b, tempAI.images[x].color.a); }
else if (type == AchievementLibrary.AchievementType.Legendary) { tempAI.images[x].color = new Color(UIManagerAsset.legendaryColor.r, UIManagerAsset.legendaryColor.g, UIManagerAsset.legendaryColor.b, tempAI.images[x].color.a); }
}
if (!PlayerPrefs.HasKey("ACH_" + UIManagerAsset.achievementLibrary.achievements[i].title)
&& UIManagerAsset.achievementLibrary.achievements[i].dataBehaviour == AchievementLibrary.DataBehaviour.Unlocked
|| PlayerPrefs.GetString("ACH_" + UIManagerAsset.achievementLibrary.achievements[i].title) == "true")
{
if (tempAI.lockedIndicator != null) { tempAI.lockedIndicator.SetActive(false); }
if (tempAI.unlockedIndicator != null) { tempAI.unlockedIndicator.SetActive(true); }
if (type == AchievementLibrary.AchievementType.Common) { commonUnlockedCount++; }
else if (type == AchievementLibrary.AchievementType.Rare) { rareUnlockedCount++; }
else if (type == AchievementLibrary.AchievementType.Legendary) { legendaryUnlockedCount++; }
totalUnlockedCount++;
}
// Duplicate the object to the all parent
GameObject allGo = Instantiate(go, new Vector3(0, 0, 0), Quaternion.identity) as GameObject;
allGo.transform.SetParent(allParent, false);
}
// Parse text data
ParseTotalText();
}
void ParseTotalText()
{
// Parsing data to text and changing colors
if (totalValueObj != null) { totalValueObj.text = totalCount.ToString(); }
if (totalUnlockedObj != null) { totalUnlockedObj.text = totalUnlockedCount.ToString(); }
if (commonUnlockedObj != null) { commonUnlockedObj.text = commonUnlockedCount.ToString(); }
if (rareUnlockedObj != null) { rareUnlockedObj.text = rareUnlockedCount.ToString(); }
if (legendaryUnlockedObj != null) { legendaryUnlockedObj.text = legendaryUnlockedCount.ToString(); }
if (commonlTotalObj != null)
{
commonlTotalObj.text = commonCount.ToString();
foreach (Transform obj in commonlTotalObj.transform.parent)
{
TextMeshProUGUI tempTMP = obj.GetComponent<TextMeshProUGUI>();
if (tempTMP != null)
{
tempTMP.color = new Color(UIManagerAsset.commonColor.r, UIManagerAsset.commonColor.g, UIManagerAsset.commonColor.b, tempTMP.color.a);
Image glowIMG = tempTMP.GetComponentInChildren<Image>();
if (glowIMG != null) { glowIMG.color = new Color(UIManagerAsset.commonColor.r, UIManagerAsset.commonColor.g, UIManagerAsset.commonColor.b, glowIMG.color.a); }
continue;
}
Image tempIMG = obj.GetComponent<Image>();
if (tempIMG != null) { tempIMG.color = new Color(UIManagerAsset.commonColor.r, UIManagerAsset.commonColor.g, UIManagerAsset.commonColor.b, tempIMG.color.a); }
}
}
if (rareTotalObj != null)
{
rareTotalObj.text = rareCount.ToString();
foreach (Transform obj in rareTotalObj.transform.parent)
{
TextMeshProUGUI tempTMP = obj.GetComponent<TextMeshProUGUI>();
if (tempTMP != null)
{
tempTMP.color = new Color(UIManagerAsset.rareColor.r, UIManagerAsset.rareColor.g, UIManagerAsset.rareColor.b, tempTMP.color.a);
Image glowIMG = tempTMP.GetComponentInChildren<Image>();
if (glowIMG != null) { glowIMG.color = new Color(UIManagerAsset.rareColor.r, UIManagerAsset.rareColor.g, UIManagerAsset.rareColor.b, glowIMG.color.a); }
continue;
}
Image tempIMG = obj.GetComponent<Image>();
if (tempIMG != null) { tempIMG.color = new Color(UIManagerAsset.rareColor.r, UIManagerAsset.rareColor.g, UIManagerAsset.rareColor.b, tempIMG.color.a); }
}
}
if (legendaryTotalObj != null)
{
legendaryTotalObj.text = legendaryCount.ToString();
foreach (Transform obj in legendaryTotalObj.transform.parent)
{
TextMeshProUGUI tempTMP = obj.GetComponent<TextMeshProUGUI>();
if (tempTMP != null)
{
tempTMP.color = new Color(UIManagerAsset.legendaryColor.r, UIManagerAsset.legendaryColor.g, UIManagerAsset.legendaryColor.b, tempTMP.color.a);
Image glowIMG = tempTMP.GetComponentInChildren<Image>();
if (glowIMG != null) { glowIMG.color = new Color(UIManagerAsset.legendaryColor.r, UIManagerAsset.legendaryColor.g, UIManagerAsset.legendaryColor.b, glowIMG.color.a); }
continue;
}
Image tempIMG = obj.GetComponent<Image>();
if (tempIMG != null) { tempIMG.color = new Color(UIManagerAsset.legendaryColor.r, UIManagerAsset.legendaryColor.g, UIManagerAsset.legendaryColor.b, tempIMG.color.a); }
}
}
}
public static void SetAchievement(string title, bool value)
{
if (value == true) { PlayerPrefs.SetString("ACH_" + title, "true"); }
else { PlayerPrefs.SetString("ACH_" + title, "false"); }
}
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: a9ee1424f72a804488dc6ea2159e71b6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: 9dea0dfd7806a334e886b3f8a1b14b82, type: 3}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 264857
packageName: Heat - Complete Modern UI
packageVersion: 1.0.4
assetPath: Assets/Heat - Complete Modern UI/Scripts/Achievements/AchievementManager.cs
uploadId: 629893

View File

@ -0,0 +1,79 @@
#if UNITY_EDITOR
using UnityEngine;
using UnityEditor;
namespace Michsky.UI.Heat
{
[CanEditMultipleObjects]
[CustomEditor(typeof(AchievementManager))]
public class AchievementManagerEditor : Editor
{
private AchievementManager amTarget;
private GUISkin customSkin;
private void OnEnable()
{
amTarget = (AchievementManager)target;
if (EditorGUIUtility.isProSkin == true) { customSkin = HeatUIEditorHandler.GetDarkEditor(customSkin); }
else { customSkin = HeatUIEditorHandler.GetLightEditor(customSkin); }
}
public override void OnInspectorGUI()
{
var UIManagerAsset = serializedObject.FindProperty("UIManagerAsset");
var allParent = serializedObject.FindProperty("allParent");
var commonParent = serializedObject.FindProperty("commonParent");
var rareParent = serializedObject.FindProperty("rareParent");
var legendaryParent = serializedObject.FindProperty("legendaryParent");
var achievementPreset = serializedObject.FindProperty("achievementPreset");
var totalUnlockedObj = serializedObject.FindProperty("totalUnlockedObj");
var totalValueObj = serializedObject.FindProperty("totalValueObj");
var commonUnlockedObj = serializedObject.FindProperty("commonUnlockedObj");
var commonlTotalObj = serializedObject.FindProperty("commonlTotalObj");
var rareUnlockedObj = serializedObject.FindProperty("rareUnlockedObj");
var rareTotalObj = serializedObject.FindProperty("rareTotalObj");
var legendaryUnlockedObj = serializedObject.FindProperty("legendaryUnlockedObj");
var legendaryTotalObj = serializedObject.FindProperty("legendaryTotalObj");
var useLocalization = serializedObject.FindProperty("useLocalization");
var useAlphabeticalOrder = serializedObject.FindProperty("useAlphabeticalOrder");
HeatUIEditorHandler.DrawHeader(customSkin, "Content Header", 6);
HeatUIEditorHandler.DrawProperty(UIManagerAsset, customSkin, "UI Manager");
if (amTarget.UIManagerAsset != null)
{
GUILayout.BeginHorizontal(EditorStyles.helpBox);
EditorGUILayout.LabelField(new GUIContent("Library Preset"), customSkin.FindStyle("Text"), GUILayout.Width(120));
GUI.enabled = false;
amTarget.UIManagerAsset.achievementLibrary = EditorGUILayout.ObjectField(amTarget.UIManagerAsset.achievementLibrary, typeof(AchievementLibrary), true) as AchievementLibrary;
GUI.enabled = true;
GUILayout.EndHorizontal();
}
HeatUIEditorHandler.DrawHeader(customSkin, "Core Header", 10);
HeatUIEditorHandler.DrawProperty(achievementPreset, customSkin, "Achievement Preset");
HeatUIEditorHandler.DrawProperty(allParent, customSkin, "All Parent");
HeatUIEditorHandler.DrawProperty(commonParent, customSkin, "Common Parent");
HeatUIEditorHandler.DrawProperty(rareParent, customSkin, "Rare Parent");
HeatUIEditorHandler.DrawProperty(legendaryParent, customSkin, "Legendary Parent");
HeatUIEditorHandler.DrawProperty(totalUnlockedObj, customSkin, "Total Unlocked");
HeatUIEditorHandler.DrawProperty(totalValueObj, customSkin, "Total Value");
HeatUIEditorHandler.DrawProperty(commonUnlockedObj, customSkin, "Common Unlocked");
HeatUIEditorHandler.DrawProperty(commonlTotalObj, customSkin, "Commonl Total");
HeatUIEditorHandler.DrawProperty(rareUnlockedObj, customSkin, "Rare Unlocked");
HeatUIEditorHandler.DrawProperty(rareTotalObj, customSkin, "Rare Total");
HeatUIEditorHandler.DrawProperty(legendaryUnlockedObj, customSkin, "Legendary Unlocked");
HeatUIEditorHandler.DrawProperty(legendaryTotalObj, customSkin, "Legendary Total");
HeatUIEditorHandler.DrawHeader(customSkin, "Options Header", 10);
useLocalization.boolValue = HeatUIEditorHandler.DrawToggle(useLocalization.boolValue, customSkin, "Use Localization", "Bypasses localization functions when disabled.");
useAlphabeticalOrder.boolValue = HeatUIEditorHandler.DrawToggle(useAlphabeticalOrder.boolValue, customSkin, "Use Alphabetical Order");
serializedObject.ApplyModifiedProperties();
if (Application.isPlaying == false) { Repaint(); }
}
}
}
#endif

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 27d855c7900f9254ca7e7e366c5fb246
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 264857
packageName: Heat - Complete Modern UI
packageVersion: 1.0.4
assetPath: Assets/Heat - Complete Modern UI/Scripts/Achievements/AchievementManagerEditor.cs
uploadId: 629893