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,207 @@
using System.Collections;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.UI;
namespace Michsky.UI.Heat
{
[RequireComponent(typeof(CanvasGroup))]
public class CreditsManager : MonoBehaviour
{
// Content
[SerializeField] private CreditsPreset creditsPreset;
// Resources
[SerializeField] private CanvasGroup canvasGroup;
[SerializeField] private Image backgroundImage;
[SerializeField] private VerticalLayoutGroup creditsListParent;
[SerializeField] private Scrollbar scrollHelper;
[SerializeField] private GameObject creditsSectionPreset;
[SerializeField] private GameObject creditsMentionPreset;
// Settings
[SerializeField] private bool closeAutomatically = true;
[SerializeField] [Range(1, 15)] private float fadingMultiplier = 4;
[SerializeField] [Range(0, 10)] private float scrollDelay = 1.25f;
[Range(0, 0.5f)] public float scrollSpeed = 0.05f;
[Range(1.1f, 15)] public float boostValue = 3f;
[SerializeField] private InputAction boostHotkey;
// Events
public UnityEvent onOpen = new UnityEvent();
public UnityEvent onClose = new UnityEvent();
public UnityEvent onCreditsEnd = new UnityEvent();
bool isOpen = false;
bool enableScrolling;
bool invokedEndEvents;
void Awake()
{
InitCredits();
boostHotkey.Enable();
if (closeAutomatically == true) { onCreditsEnd.AddListener(() => ClosePanel()); }
}
void OnEnable()
{
StartScrolling();
}
void OnDisable()
{
invokedEndEvents = false;
enableScrolling = false;
}
void Update()
{
if (enableScrolling == false)
return;
if (boostHotkey.IsInProgress()) { scrollHelper.value -= (scrollSpeed * boostValue) * Time.deltaTime; }
else { scrollHelper.value -= scrollSpeed * Time.deltaTime; }
if (scrollHelper.value <= 0.005f && invokedEndEvents == false) { onCreditsEnd.Invoke(); invokedEndEvents = true; }
if (scrollHelper.value <= 0) { enableScrolling = false; onCreditsEnd.Invoke(); }
}
void InitCredits()
{
if (creditsPreset == null)
{
Debug.LogWarning("'Credits Preset' is missing.", this);
return;
}
backgroundImage.sprite = creditsPreset.backgroundSprite;
foreach (Transform child in creditsListParent.transform)
{
if (child.GetComponent<CreditsSectionItem>() != null || child.GetComponent<CreditsMentionItem>() != null)
Destroy(child.gameObject);
}
for (int i = 0; i < creditsPreset.credits.Count; ++i)
{
GameObject go = Instantiate(creditsSectionPreset, new Vector3(0, 0, 0), Quaternion.identity) as GameObject;
go.transform.SetParent(creditsListParent.transform, false);
go.name = creditsPreset.credits[i].headerTitle;
CreditsSectionItem csi = go.GetComponent<CreditsSectionItem>();
csi.preset = creditsPreset;
csi.SetHeader(creditsPreset.credits[i].headerTitle);
if (creditsPreset.credits[i].items.Count < 2) { csi.headerLayout.padding.bottom = 0; }
if (!string.IsNullOrEmpty(creditsPreset.credits[i].headerTitleKey)) { csi.CheckForLocalization(creditsPreset.credits[i].headerTitleKey); }
foreach (string txt in creditsPreset.credits[i].items) { csi.AddNameToList(txt); }
Destroy(csi.namePreset);
csi.UpdateLayout();
}
for (int i = 0; i < creditsPreset.mentions.Count; ++i)
{
GameObject go = Instantiate(creditsMentionPreset, new Vector3(0, 0, 0), Quaternion.identity) as GameObject;
go.transform.SetParent(creditsListParent.transform, false);
go.name = creditsPreset.mentions[i].ID;
CreditsMentionItem cmi = go.GetComponent<CreditsMentionItem>();
cmi.preset = creditsPreset;
cmi.UpdateLayout(creditsPreset.mentions[i].layoutSpacing, creditsPreset.mentions[i].descriptionSpacing);
if (i == 0) { cmi.listLayout.padding.top = cmi.listLayout.padding.top * 2; }
cmi.SetIcon(creditsPreset.mentions[i].icon);
cmi.SetDescription(creditsPreset.mentions[i].description);
if (!string.IsNullOrEmpty(creditsPreset.mentions[i].descriptionKey)) { cmi.CheckForLocalization(creditsPreset.mentions[i].descriptionKey); }
}
creditsListParent.padding.bottom = (int)(Screen.currentResolution.height / 1.26f);
StartCoroutine("FixListLayout");
}
void StartScrolling()
{
if (enableScrolling == true)
return;
StopCoroutine("StartTimer");
enableScrolling = false;
scrollHelper.value = 1;
if (scrollDelay != 0) { StartCoroutine("StartTimer"); }
else { enableScrolling = true; }
}
public void OpenPanel()
{
if (isOpen == true)
return;
canvasGroup.alpha = 0;
gameObject.SetActive(true);
isOpen = true;
onOpen.Invoke();
StopCoroutine("SetInvisible");
StartCoroutine("SetVisible");
}
public void ClosePanel()
{
if (isOpen == false)
return;
onClose.Invoke();
isOpen = false;
StopCoroutine("SetVisible");
StartCoroutine("SetInvisible");
}
public void EnableScrolling(bool state)
{
if (state == false) { enableScrolling = false; }
else { enableScrolling = true; }
}
IEnumerator StartTimer()
{
yield return new WaitForSeconds(scrollDelay);
enableScrolling = true;
}
IEnumerator FixListLayout()
{
yield return new WaitForSecondsRealtime(0.025f);
LayoutRebuilder.ForceRebuildLayoutImmediate(creditsListParent.GetComponent<RectTransform>());
}
IEnumerator SetVisible()
{
StopCoroutine("SetInvisible");
while (canvasGroup.alpha < 0.99f)
{
canvasGroup.alpha += Time.unscaledDeltaTime * fadingMultiplier;
yield return null;
}
canvasGroup.alpha = 1;
}
IEnumerator SetInvisible()
{
StopCoroutine("SetVisible");
while (canvasGroup.alpha > 0.01f)
{
canvasGroup.alpha -= Time.unscaledDeltaTime * fadingMultiplier;
yield return null;
}
canvasGroup.alpha = 0;
scrollHelper.value = 1;
gameObject.SetActive(false);
}
}
}

View File

@ -0,0 +1,26 @@
fileFormatVersion: 2
guid: 367326c893a48a940923d6fc44237e0b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences:
- creditsPreset: {fileID: 11400000, guid: 2d7bb0866052d774390db7996956e0ef, type: 2}
- canvasGroup: {instanceID: 0}
- creditsListParent: {instanceID: 0}
- listScrollbar: {instanceID: 0}
- creditsSectionPreset: {fileID: 1420959260360356443, guid: c5667b5cb0b39ee40ab75326a4242e0e,
type: 3}
- creditsMentionPreset: {fileID: 1336403521818845296, guid: d5408780e8a557a419faa33ec93e0f7c,
type: 3}
executionOrder: 0
icon: {fileID: 2800000, guid: 59deb41d54b5d8745aab5f6369a24361, 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/Credits/CreditsManager.cs
uploadId: 629893

View File

@ -0,0 +1,100 @@
#if UNITY_EDITOR
using UnityEngine;
using UnityEditor;
namespace Michsky.UI.Heat
{
[CustomEditor(typeof(CreditsManager))]
public class CreditsManagerEditor : Editor
{
private CreditsManager cmTarget;
private GUISkin customSkin;
private int latestTabIndex;
private void OnEnable()
{
cmTarget = (CreditsManager)target;
if (EditorGUIUtility.isProSkin == true) { customSkin = HeatUIEditorHandler.GetDarkEditor(customSkin); }
else { customSkin = HeatUIEditorHandler.GetLightEditor(customSkin); }
}
public override void OnInspectorGUI()
{
HeatUIEditorHandler.DrawComponentHeader(customSkin, "Credits Top Header");
GUIContent[] toolbarTabs = new GUIContent[3];
toolbarTabs[0] = new GUIContent("Content");
toolbarTabs[1] = new GUIContent("Resources");
toolbarTabs[2] = new GUIContent("Settings");
latestTabIndex = HeatUIEditorHandler.DrawTabs(latestTabIndex, toolbarTabs, customSkin);
if (GUILayout.Button(new GUIContent("Content", "Content"), customSkin.FindStyle("Tab Content")))
latestTabIndex = 0;
if (GUILayout.Button(new GUIContent("Resources", "Resources"), customSkin.FindStyle("Tab Resources")))
latestTabIndex = 1;
if (GUILayout.Button(new GUIContent("Settings", "Settings"), customSkin.FindStyle("Tab Settings")))
latestTabIndex = 2;
GUILayout.EndHorizontal();
var creditsPreset = serializedObject.FindProperty("creditsPreset");
var canvasGroup = serializedObject.FindProperty("canvasGroup");
var backgroundImage = serializedObject.FindProperty("backgroundImage");
var creditsListParent = serializedObject.FindProperty("creditsListParent");
var scrollHelper = serializedObject.FindProperty("scrollHelper");
var creditsSectionPreset = serializedObject.FindProperty("creditsSectionPreset");
var creditsMentionPreset = serializedObject.FindProperty("creditsMentionPreset");
var closeAutomatically = serializedObject.FindProperty("closeAutomatically");
var fadingMultiplier = serializedObject.FindProperty("fadingMultiplier");
var scrollDelay = serializedObject.FindProperty("scrollDelay");
var scrollSpeed = serializedObject.FindProperty("scrollSpeed");
var boostValue = serializedObject.FindProperty("boostValue");
var boostHotkey = serializedObject.FindProperty("boostHotkey");
var onOpen = serializedObject.FindProperty("onOpen");
var onClose = serializedObject.FindProperty("onClose");
var onCreditsEnd = serializedObject.FindProperty("onCreditsEnd");
switch (latestTabIndex)
{
case 0:
HeatUIEditorHandler.DrawHeader(customSkin, "Content Header", 6);
HeatUIEditorHandler.DrawProperty(creditsPreset, customSkin, "Credits Preset");
HeatUIEditorHandler.DrawHeader(customSkin, "Events Header", 10);
EditorGUILayout.PropertyField(onOpen, new GUIContent("On Open"), true);
EditorGUILayout.PropertyField(onClose, new GUIContent("On Close"), true);
EditorGUILayout.PropertyField(onCreditsEnd, new GUIContent("On Credits End"), true);
break;
case 1:
HeatUIEditorHandler.DrawHeader(customSkin, "Core Header", 6);
HeatUIEditorHandler.DrawProperty(canvasGroup, customSkin, "Canvas Group");
HeatUIEditorHandler.DrawProperty(backgroundImage, customSkin, "BG Image");
HeatUIEditorHandler.DrawProperty(creditsListParent, customSkin, "List Parent");
HeatUIEditorHandler.DrawProperty(scrollHelper, customSkin, "Scroll Helper");
HeatUIEditorHandler.DrawProperty(creditsSectionPreset, customSkin, "Section Preset");
HeatUIEditorHandler.DrawProperty(creditsMentionPreset, customSkin, "Mention Preset");
break;
case 2:
HeatUIEditorHandler.DrawHeader(customSkin, "Options Header", 6);
closeAutomatically.boolValue = HeatUIEditorHandler.DrawToggle(closeAutomatically.boolValue, customSkin, "Close Automatically");
HeatUIEditorHandler.DrawProperty(fadingMultiplier, customSkin, "Fading Multiplier", "Set the animation fade multiplier.");
HeatUIEditorHandler.DrawProperty(scrollDelay, customSkin, "Scroll Delay");
HeatUIEditorHandler.DrawProperty(scrollSpeed, customSkin, "Scroll Speed");
HeatUIEditorHandler.DrawProperty(boostValue, customSkin, "Boost Value");
EditorGUILayout.PropertyField(boostHotkey, new GUIContent("Boost Hotkey"), true);
break;
}
serializedObject.ApplyModifiedProperties();
if (Application.isPlaying == false) { Repaint(); }
}
}
}
#endif

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: d3d8b7c76c688b5418b2d53a34eaf733
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/Credits/CreditsManagerEditor.cs
uploadId: 629893

View File

@ -0,0 +1,66 @@
using UnityEngine;
using UnityEngine.UI;
using TMPro;
namespace Michsky.UI.Heat
{
public class CreditsMentionItem : MonoBehaviour
{
[Header("Resources")]
[SerializeField] private Image iconImage;
[SerializeField] private TextMeshProUGUI descriptionText;
public VerticalLayoutGroup listLayout;
// Helpers
[HideInInspector] public CreditsPreset preset;
[HideInInspector] public LocalizedObject localizedObject;
void OnEnable()
{
if (localizedObject != null && !string.IsNullOrEmpty(localizedObject.localizationKey))
{
SetDescription(localizedObject.GetKeyOutput(localizedObject.localizationKey));
}
}
public void UpdateLayout(int paddingValue, int spacingValue)
{
listLayout.padding.top = paddingValue / 2;
listLayout.padding.bottom = paddingValue / 2;
listLayout.spacing = spacingValue;
}
public void SetIcon(Sprite icon)
{
if (icon == null)
{
iconImage.gameObject.SetActive(false);
return;
}
iconImage.sprite = icon;
}
public void SetDescription(string text)
{
if (string.IsNullOrEmpty(text))
{
descriptionText.gameObject.SetActive(false);
return;
}
descriptionText.text = text;
}
public void CheckForLocalization(string key)
{
localizedObject = descriptionText.GetComponent<LocalizedObject>();
if (localizedObject == null || (LocalizationManager.instance != null && !LocalizationManager.instance.UIManagerAsset.enableLocalization)) { localizedObject = null; }
else if (!string.IsNullOrEmpty(key))
{
localizedObject.localizationKey = key;
SetDescription(localizedObject.GetKeyOutput(localizedObject.localizationKey));
}
}
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 83aca5d55e487f44994e1cce070062b1
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/Credits/CreditsMentionItem.cs
uploadId: 629893

View File

@ -0,0 +1,38 @@
using System.Collections.Generic;
using UnityEngine;
namespace Michsky.UI.Heat
{
[CreateAssetMenu(fileName = "New Credits Preset", menuName = "Heat UI/Panel/New Credits Preset")]
public class CreditsPreset : ScriptableObject
{
[Header("Settings")]
public Sprite backgroundSprite;
public int sectionSpacing = 70;
public int headerSpacing = 30;
public int nameListSpacing = 50;
[Space(10)]
public List<CreditsSection> credits = new List<CreditsSection>();
public List<MentionSection> mentions = new List<MentionSection>();
[System.Serializable]
public class CreditsSection
{
public string headerTitle = "Header";
public string headerTitleKey = "Localization Key";
public List<string> items = new List<string>();
}
[System.Serializable]
public class MentionSection
{
public string ID = "ID";
public Sprite icon;
[TextArea] public string description = "Description";
public string descriptionKey = "Localization Key";
[Range(0, 100)] public int descriptionSpacing = 30;
[Range(0, 400)] public int layoutSpacing = 160;
}
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: bc81008149a763b468f830783c72c0e9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: 59deb41d54b5d8745aab5f6369a24361, 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/Credits/CreditsPreset.cs
uploadId: 629893

View File

@ -0,0 +1,59 @@
using TMPro;
using UnityEngine;
using UnityEngine.UI;
namespace Michsky.UI.Heat
{
public class CreditsSectionItem : MonoBehaviour
{
[Header("Resources")]
public HorizontalLayoutGroup headerLayout;
public VerticalLayoutGroup listLayout;
[SerializeField] private TextMeshProUGUI headerText;
public GameObject namePreset;
[HideInInspector] public CreditsPreset preset;
[HideInInspector] public LocalizedObject localizedObject;
void OnEnable()
{
if (localizedObject != null && !string.IsNullOrEmpty(localizedObject.localizationKey))
{
SetHeader(localizedObject.GetKeyOutput(localizedObject.localizationKey));
}
}
public void UpdateLayout()
{
headerLayout.spacing = preset.headerSpacing;
listLayout.spacing = preset.nameListSpacing;
}
public void AddNameToList(string name)
{
GameObject go = Instantiate(namePreset, new Vector3(0, 0, 0), Quaternion.identity) as GameObject;
go.transform.SetParent(listLayout.transform, false);
go.name = name;
TextMeshProUGUI goText = go.GetComponent<TextMeshProUGUI>();
goText.text = name;
}
public void SetHeader(string text)
{
headerText.text = text;
}
public void CheckForLocalization(string key)
{
localizedObject = headerText.GetComponent<LocalizedObject>();
if (localizedObject == null || localizedObject.CheckLocalizationStatus() == false) { localizedObject = null; }
else if (!string.IsNullOrEmpty(key))
{
localizedObject.localizationKey = key;
SetHeader(localizedObject.GetKeyOutput(localizedObject.localizationKey));
}
}
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 3210f972da6729c4b8fba218c9830a37
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/Credits/CreditsSectionItem.cs
uploadId: 629893