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,8 @@
fileFormatVersion: 2
guid: bfa6b422c3ba3b94d966cdfbc3368317
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

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

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1d7b8c8b6ef2ce14ebbb7553ca0c967a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,66 @@
using System.Collections;
using UnityEngine;
namespace Michsky.UI.Heat
{
[RequireComponent(typeof(Animator))]
public class ButtonFrame : MonoBehaviour
{
// Resources
[SerializeField] private Animator animator;
[SerializeField] private ButtonManager buttonManager;
[SerializeField] private PanelButton panelButton;
// Settings
[SerializeField] private ButtonType buttonType = ButtonType.ButtonManager;
public enum ButtonType { ButtonManager, PanelButton }
void Start()
{
if ((buttonType == ButtonType.ButtonManager && buttonManager == null) || (buttonType == ButtonType.PanelButton && panelButton == null)) { return; }
if (animator == null) { animator = GetComponent<Animator>(); }
if (buttonType == ButtonType.ButtonManager)
{
buttonManager.onHover.AddListener(delegate { DoIn(); });
buttonManager.onLeave.AddListener(delegate { DoOut(); });
buttonManager.onSelect.AddListener(delegate { DoIn(); });
buttonManager.onDeselect.AddListener(delegate { DoOut(); });
}
else if (buttonType == ButtonType.PanelButton)
{
panelButton.onHover.AddListener(delegate { DoIn(); });
panelButton.onLeave.AddListener(delegate { DoOut(); });
panelButton.onSelect.AddListener(delegate { DoOut(); });
}
animator.enabled = false;
}
public void DoIn()
{
animator.enabled = true;
animator.CrossFade("In", 0.15f);
StopCoroutine("DisableAnimator");
StartCoroutine("DisableAnimator");
}
public void DoOut()
{
animator.enabled = true;
animator.CrossFade("Out", 0.15f);
StopCoroutine("DisableAnimator");
StartCoroutine("DisableAnimator");
}
IEnumerator DisableAnimator()
{
yield return new WaitForSecondsRealtime(HeatUIInternalTools.GetAnimatorClipLength(animator, "ButtonFrame_In"));
animator.enabled = false;
}
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 39c56966751bb904197e746678f1cfb2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: b633d2f960ff9e74a901c2047b5e76ea, 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/Animation/ButtonFrame.cs
uploadId: 629893

View File

@ -0,0 +1,43 @@
#if UNITY_EDITOR
using UnityEngine;
using UnityEditor;
namespace Michsky.UI.Heat
{
[CanEditMultipleObjects]
[CustomEditor(typeof(ButtonFrame))]
public class ButtonFrameEditor : Editor
{
private ButtonFrame bfTarget;
private GUISkin customSkin;
private void OnEnable()
{
bfTarget = (ButtonFrame)target;
if (EditorGUIUtility.isProSkin == true) { customSkin = HeatUIEditorHandler.GetDarkEditor(customSkin); }
else { customSkin = HeatUIEditorHandler.GetLightEditor(customSkin); }
}
public override void OnInspectorGUI()
{
var animator = serializedObject.FindProperty("animator");
var buttonManager = serializedObject.FindProperty("buttonManager");
var panelButton = serializedObject.FindProperty("panelButton");
var buttonType = serializedObject.FindProperty("buttonType");
HeatUIEditorHandler.DrawHeader(customSkin, "Core Header", 6);
HeatUIEditorHandler.DrawProperty(animator, customSkin, "Animator");
HeatUIEditorHandler.DrawHeader(customSkin, "Options Header", 10);
GUILayout.BeginVertical(EditorStyles.helpBox);
HeatUIEditorHandler.DrawPropertyPlain(buttonType, customSkin, "Animator");
if (buttonType.enumValueIndex == 0) { HeatUIEditorHandler.DrawProperty(buttonManager, customSkin, "Button Manager"); }
else if (buttonType.enumValueIndex == 1) { HeatUIEditorHandler.DrawProperty(panelButton, customSkin, "Panel Button"); }
GUILayout.EndVertical();
serializedObject.ApplyModifiedProperties();
}
}
}
#endif

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: ff92d25caab9bb5479aac96469e03b2c
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/Animation/ButtonFrameEditor.cs
uploadId: 629893

View File

@ -0,0 +1,95 @@
using System.Collections;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Events;
namespace Michsky.UI.Heat
{
[RequireComponent(typeof(Image))]
[AddComponentMenu("Heat UI/Animation/Image Fading")]
public class ImageFading : MonoBehaviour
{
[Header("Settings")]
[SerializeField] private bool doPingPong = false;
[SerializeField] [Range(0.5f, 12)] private float fadeSpeed = 2f;
[SerializeField] private AnimationCurve fadeCurve = new AnimationCurve(new Keyframe(0.0f, 0.0f), new Keyframe(1.0f, 1.0f));
[SerializeField] private EnableBehaviour enableBehaviour;
[Header("Events")]
public UnityEvent onFadeIn;
public UnityEvent onFadeInEnd;
public UnityEvent onFadeOut;
public UnityEvent onFadeOutEnd;
// Helpers
Image targetImg;
public enum EnableBehaviour { None, FadeIn, FadeOut }
void OnEnable()
{
if (enableBehaviour == EnableBehaviour.FadeIn) { FadeIn(); }
else if (enableBehaviour == EnableBehaviour.FadeOut) { FadeOut(); }
}
public void FadeIn()
{
if (gameObject.activeSelf == false) { gameObject.SetActive(true); }
if (targetImg == null) { targetImg = GetComponent<Image>(); }
targetImg.color = new Color(targetImg.color.r, targetImg.color.g, targetImg.color.b, 0);
onFadeIn.Invoke();
StopCoroutine("DoFadeIn");
StopCoroutine("DoFadeOut");
StartCoroutine("DoFadeIn");
}
public void FadeOut()
{
if (gameObject.activeSelf == false) { gameObject.SetActive(true); }
if (targetImg == null) { targetImg = GetComponent<Image>(); }
targetImg.color = new Color(targetImg.color.r, targetImg.color.g, targetImg.color.b, 1);
onFadeOut.Invoke();
StopCoroutine("DoFadeIn");
StopCoroutine("DoFadeOut");
StartCoroutine("DoFadeOut");
}
IEnumerator DoFadeIn()
{
Color startingPoint = new Color(targetImg.color.r, targetImg.color.g, targetImg.color.b, 0);
float elapsedTime = 0;
while (targetImg.color.a < 0.99f)
{
elapsedTime += Time.unscaledDeltaTime;
targetImg.color = Color.Lerp(startingPoint, new Color(startingPoint.r, startingPoint.g, startingPoint.b, 1), fadeCurve.Evaluate(elapsedTime * fadeSpeed)); ;
yield return null;
}
targetImg.color = new Color(targetImg.color.r, targetImg.color.g, targetImg.color.b, 1);
onFadeInEnd.Invoke();
if (doPingPong == true) { StartCoroutine("DoFadeOut"); }
}
IEnumerator DoFadeOut()
{
Color startingPoint = targetImg.color;
float elapsedTime = 0;
while (targetImg.color.a > 0.01f)
{
elapsedTime += Time.unscaledDeltaTime;
targetImg.color = Color.Lerp(startingPoint, new Color(startingPoint.r, startingPoint.g, startingPoint.b, 0), fadeCurve.Evaluate(elapsedTime * fadeSpeed)); ;
yield return null;
}
targetImg.color = new Color(targetImg.color.r, targetImg.color.g, targetImg.color.b, 0);
onFadeOutEnd.Invoke();
gameObject.SetActive(false);
}
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: a40819193417bd641b0c711d515cbfa6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: b633d2f960ff9e74a901c2047b5e76ea, 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/Animation/ImageFading.cs
uploadId: 629893

View File

@ -0,0 +1,70 @@
using System.Collections;
using UnityEngine;
using UnityEngine.UI;
namespace Michsky.UI.Heat
{
[AddComponentMenu("Heat UI/Animation/Image Pulse")]
public class ImagePulse : MonoBehaviour
{
[Header("Resources")]
[SerializeField] private Image targetImage;
[Header("Color")]
[Range(0, 1)] public float minAlpha = 0.25f;
[Range(0, 1)] public float maxAlpha = 1;
[Header("Animation")]
[Range(0.5f, 10)] public float pulseSpeed = 1;
[SerializeField] private AnimationCurve pulseCurve = new AnimationCurve(new Keyframe(0.0f, 0.0f), new Keyframe(1.0f, 1.0f));
void OnEnable()
{
StartPulse();
}
public void StartPulse()
{
if (gameObject.activeSelf == false) { gameObject.SetActive(true); }
if (targetImage == null) { targetImage = GetComponent<Image>(); }
targetImage.color = new Color(targetImage.color.r, targetImage.color.g, targetImage.color.b, minAlpha);
StopCoroutine("PulseInAnimation");
StopCoroutine("PulseOutAnimation");
StartCoroutine("PulseInAnimation");
}
IEnumerator PulseInAnimation()
{
float elapsedTime = 0;
targetImage.color = new Color(targetImage.color.r, targetImage.color.g, targetImage.color.b, minAlpha);
while (targetImage.color.a < maxAlpha)
{
elapsedTime += Time.unscaledDeltaTime;
targetImage.color = new Color(targetImage.color.r, targetImage.color.g, targetImage.color.b, Mathf.Lerp(minAlpha, maxAlpha, pulseCurve.Evaluate(elapsedTime * pulseSpeed)));
yield return null;
}
targetImage.color = new Color(targetImage.color.r, targetImage.color.g, targetImage.color.b, maxAlpha);
StartCoroutine("PulseOutAnimation");
}
IEnumerator PulseOutAnimation()
{
float elapsedTime = 0;
targetImage.color = new Color(targetImage.color.r, targetImage.color.g, targetImage.color.b, maxAlpha);
while (targetImage.color.a > minAlpha)
{
elapsedTime += Time.unscaledDeltaTime;
targetImage.color = new Color(targetImage.color.r, targetImage.color.g, targetImage.color.b, Mathf.Lerp(maxAlpha, minAlpha, pulseCurve.Evaluate(elapsedTime * pulseSpeed)));
yield return null;
}
targetImage.color = new Color(targetImage.color.r, targetImage.color.g, targetImage.color.b, minAlpha);
StartCoroutine("PulseInAnimation");
}
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: e493d5e4e9119a943904d5d8255bafba
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: b633d2f960ff9e74a901c2047b5e76ea, 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/Animation/ImagePulse.cs
uploadId: 629893

View File

@ -0,0 +1,110 @@
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using UnityEngine;
namespace Michsky.UI.Heat
{
[RequireComponent(typeof(Animator))]
[RequireComponent(typeof(CanvasGroup))]
public class NavigationBar : MonoBehaviour
{
// Resources
[SerializeField] private Animator animator;
[SerializeField] private CanvasGroup canvasGroup;
// Settings
[SerializeField] private UpdateMode updateMode = UpdateMode.DeltaTime;
[SerializeField] private BarDirection barDirection = BarDirection.Top;
[SerializeField] private bool fadeButtons = false;
[SerializeField] private Transform buttonParent;
// Helpers
float cachedStateLength = 0.4f;
List<PanelButton> buttons = new List<PanelButton>();
public enum UpdateMode { DeltaTime, UnscaledTime }
public enum BarDirection { Top, Bottom }
void Awake()
{
if (animator == null) { GetComponent<Animator>(); }
if (canvasGroup == null) { GetComponent<CanvasGroup>(); }
if (fadeButtons && buttonParent != null) { FetchButtons(); }
cachedStateLength = HeatUIInternalTools.GetAnimatorClipLength(animator, "NavigationBar_TopShow") + 0.02f;
}
void OnEnable()
{
Show();
}
public void FetchButtons()
{
buttons.Clear();
foreach (Transform child in buttonParent)
{
if (child.GetComponent<PanelButton>() != null)
{
PanelButton btn = child.GetComponent<PanelButton>();
btn.navbar = this;
buttons.Add(btn);
}
}
}
public void LitButtons(PanelButton source = null)
{
foreach (PanelButton btn in buttons)
{
if (btn.isSelected || (source != null && btn == source))
continue;
btn.IsInteractable(true);
}
}
public void DimButtons(PanelButton source)
{
foreach (PanelButton btn in buttons)
{
if (btn.isSelected || btn == source)
continue;
btn.IsInteractable(false);
}
}
public void Show()
{
animator.enabled = true;
StopCoroutine("DisableAnimator");
StartCoroutine("DisableAnimator");
if (barDirection == BarDirection.Top) { animator.Play("Top Show"); }
else if (barDirection == BarDirection.Bottom) { animator.Play("Bottom Show"); }
}
public void Hide()
{
animator.enabled = true;
StopCoroutine("DisableAnimator");
StartCoroutine("DisableAnimator");
if (barDirection == BarDirection.Top) { animator.Play("Top Hide"); }
else if (barDirection == BarDirection.Bottom) { animator.Play("Bottom Hide"); }
}
IEnumerator DisableAnimator()
{
if (updateMode == UpdateMode.DeltaTime) { yield return new WaitForSeconds(cachedStateLength); }
else { yield return new WaitForSecondsRealtime(cachedStateLength); }
animator.enabled = false;
}
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 2b212167ae6cb6d42afd331401af0d53
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: b633d2f960ff9e74a901c2047b5e76ea, 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/Animation/NavigationBar.cs
uploadId: 629893

View File

@ -0,0 +1,50 @@
#if UNITY_EDITOR
using UnityEngine;
using UnityEditor;
namespace Michsky.UI.Heat
{
[CanEditMultipleObjects]
[CustomEditor(typeof(NavigationBar))]
public class NavigationBarEditor : Editor
{
private NavigationBar navTarget;
private GUISkin customSkin;
private void OnEnable()
{
navTarget = (NavigationBar)target;
if (EditorGUIUtility.isProSkin == true) { customSkin = HeatUIEditorHandler.GetDarkEditor(customSkin); }
else { customSkin = HeatUIEditorHandler.GetLightEditor(customSkin); }
}
public override void OnInspectorGUI()
{
var animator = serializedObject.FindProperty("animator");
var canvasGroup = serializedObject.FindProperty("canvasGroup");
var updateMode = serializedObject.FindProperty("updateMode");
var barDirection = serializedObject.FindProperty("barDirection");
var fadeButtons = serializedObject.FindProperty("fadeButtons");
var buttonParent = serializedObject.FindProperty("buttonParent");
HeatUIEditorHandler.DrawHeader(customSkin, "Core Header", 6);
HeatUIEditorHandler.DrawProperty(animator, customSkin, "Animator");
HeatUIEditorHandler.DrawProperty(canvasGroup, customSkin, "Canvas Group");
HeatUIEditorHandler.DrawHeader(customSkin, "Options Header", 10);
GUILayout.BeginVertical(EditorStyles.helpBox);
GUILayout.Space(-3);
fadeButtons.boolValue = HeatUIEditorHandler.DrawTogglePlain(fadeButtons.boolValue, customSkin, "Fade Panel Buttons");
GUILayout.Space(4);
if (fadeButtons.boolValue == true) { HeatUIEditorHandler.DrawProperty(buttonParent, customSkin, "Button Parent"); }
GUILayout.EndVertical();
HeatUIEditorHandler.DrawProperty(updateMode, customSkin, "Update Mode");
HeatUIEditorHandler.DrawProperty(barDirection, customSkin, "Bar Direction");
serializedObject.ApplyModifiedProperties();
}
}
}
#endif

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 004e7221dd8ff2e48836b109bbd46839
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/Animation/NavigationBarEditor.cs
uploadId: 629893

View File

@ -0,0 +1,42 @@
using UnityEngine;
using UnityEngine.InputSystem;
namespace Michsky.UI.Heat
{
[RequireComponent(typeof(RectTransform))]
[AddComponentMenu("Heat UI/Animation/Rect Depth")]
public class RectDepth : MonoBehaviour
{
[Header("Settings")]
[SerializeField] [Range(0.05f, 1)] private float smoothness = 0.25f;
[SerializeField] [Range(0.5f, 10)] private float multiplier = 2;
[SerializeField] [Range(1, 2)] private float maxRectScale = 1;
[Header("Resources")]
[SerializeField] private RectTransform targetRect;
[SerializeField] private Canvas targetCanvas;
[SerializeField] private Camera targetCamera;
private Vector2 mousePos;
void Awake()
{
if (targetRect == null) { targetRect = GetComponent<RectTransform>(); }
if (targetCanvas == null) { targetCanvas = GetComponentInParent<Canvas>(); }
if (targetCamera == null) { targetCamera = Camera.main; }
targetRect.transform.localScale = new Vector3(maxRectScale, maxRectScale, maxRectScale);
}
void OnEnable()
{
targetRect.anchoredPosition = new Vector2(0, 0);
}
void Update()
{
RectTransformUtility.ScreenPointToLocalPointInRectangle(targetCanvas.transform as RectTransform, Mouse.current.position.ReadValue(), targetCamera, out mousePos);
targetRect.anchoredPosition = Vector2.Lerp(targetRect.anchoredPosition, targetCanvas.transform.TransformPoint(mousePos) * multiplier, smoothness / (multiplier * 4f));
}
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: ce3649032ad7fd34fae6acf8bf789c90
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: b633d2f960ff9e74a901c2047b5e76ea, 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/Animation/RectDepth.cs
uploadId: 629893

View File

@ -0,0 +1,59 @@
using System.Collections;
using UnityEngine;
namespace Michsky.UI.Heat
{
[AddComponentMenu("Heat UI/Animation/Shiny Image")]
public class ShinyImage : MonoBehaviour
{
[Header("Resources")]
[SerializeField] private RectTransform targetRect;
[SerializeField] private RectTransform parentRect;
[Header("Animation")]
[SerializeField][Range(0, 4)] private float delay = 0.25f;
[SerializeField] [Range(0.25f, 4)] private float animationSpeed = 1;
[SerializeField] private AnimationCurve animationCurve = new AnimationCurve(new Keyframe(0.0f, 0.0f), new Keyframe(1.0f, 1.0f));
void OnEnable()
{
StartShiny();
}
public void StartShiny()
{
gameObject.SetActive(true);
if (targetRect == null) { targetRect = GetComponent<RectTransform>(); }
if (parentRect == null) { parentRect = transform.parent.GetComponent<RectTransform>(); }
StopCoroutine("ShinyAnimation");
StartCoroutine("ShinyAnimation");
}
IEnumerator ShinyAnimation()
{
float elapsedTime = 0;
Vector2 startPos = new Vector2(-parentRect.sizeDelta.x, targetRect.anchoredPosition.y);
Vector2 endPos = new Vector2(+parentRect.sizeDelta.x, targetRect.anchoredPosition.y);
targetRect.anchoredPosition = startPos;
while (targetRect.anchoredPosition.x < endPos.x - 0.1f)
{
elapsedTime += Time.unscaledDeltaTime;
targetRect.anchoredPosition = new Vector2(Mathf.Lerp(startPos.x, endPos.x, animationCurve.Evaluate(elapsedTime * animationSpeed)), targetRect.anchoredPosition.y);
yield return null;
}
targetRect.anchoredPosition = endPos;
if (delay == 0) { StartCoroutine("ShinyAnimation"); }
else { StartCoroutine("ShinyAnimationDelay"); }
}
IEnumerator ShinyAnimationDelay()
{
yield return new WaitForSecondsRealtime(delay);
StartCoroutine("ShinyAnimation");
}
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: fbd7f24c06b40d34c94a6e79b58382c6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: b633d2f960ff9e74a901c2047b5e76ea, 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/Animation/ShinyImage.cs
uploadId: 629893

View File

@ -0,0 +1,41 @@
using UnityEngine;
namespace Michsky.UI.Heat
{
[AddComponentMenu("Heat UI/Animation/Spinner")]
public class Spinner : MonoBehaviour
{
[Header("Resources")]
[SerializeField] private RectTransform objectToSpin;
[Header("Settings")]
[SerializeField] [Range(0.1f, 50)] private float speed = 10;
[SerializeField] private Direction direction;
float currentPos;
public enum Direction { Clockwise, CounterClockwise }
void Awake()
{
if (objectToSpin == null)
this.enabled = false;
}
void Update()
{
if (direction == Direction.Clockwise)
{
currentPos -= speed * 100 * Time.unscaledDeltaTime;
if (currentPos >= 360) { currentPos = 0; }
}
else if (direction == Direction.CounterClockwise)
{
currentPos += speed * 100 * Time.unscaledDeltaTime;
if (currentPos <= -360) { currentPos = 0; }
}
objectToSpin.localRotation = Quaternion.Euler(0, 0, currentPos);
}
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 59113c108d68d6e4dae023185341cb2f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: 15c8d78db352ebe41959a2ea952c3ab0, 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/Animation/Spinner.cs
uploadId: 629893

View File

@ -0,0 +1,321 @@
using System.Collections;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
namespace Michsky.UI.Heat
{
[RequireComponent(typeof(CanvasGroup))]
[RequireComponent(typeof(RectTransform))]
[AddComponentMenu("Heat UI/Animation/UI Popup")]
public class UIPopup : MonoBehaviour
{
[Header("Settings")]
[SerializeField] private bool playOnEnable = true;
[SerializeField] private bool closeOnDisable = false;
[SerializeField] private bool instantOut = false;
[Tooltip("Enables content size fitter mode.")]
[SerializeField] private bool fitterMode = false;
[SerializeField] private StartBehaviour startBehaviour;
[Header("Animation")]
[SerializeField] private AnimationMode animationMode;
[SerializeField] private AnimationCurve animationCurve = new AnimationCurve(new Keyframe(0.0f, 0.0f), new Keyframe(1.0f, 1.0f));
[Range(0.5f, 10)] public float curveSpeed = 4f;
[Header("Events")]
public UnityEvent onEnable = new UnityEvent();
public UnityEvent onVisible = new UnityEvent();
public UnityEvent onDisable = new UnityEvent();
// Helpers
RectTransform rect;
CanvasGroup cg;
Vector2 rectHelper;
bool isInitialized = false;
bool isFitterInitialized = false;
[HideInInspector] public bool isOn = false;
public enum AnimationMode { Scale, Horizontal, Vertical }
public enum StartBehaviour { Default, Disabled, Static }
void Start()
{
if (startBehaviour == StartBehaviour.Disabled)
{
gameObject.SetActive(false);
}
}
void OnEnable()
{
if (!isInitialized) { Initialize(); }
if (playOnEnable) { PlayIn(); }
}
void OnDisable()
{
if (closeOnDisable)
{
gameObject.SetActive(false);
isOn = false;
}
}
private void Initialize()
{
if (rect == null) { rect = GetComponent<RectTransform>(); }
if (cg == null) { cg = GetComponent<CanvasGroup>(); }
if (startBehaviour == StartBehaviour.Disabled || startBehaviour == StartBehaviour.Static) { rectHelper = rect.sizeDelta; }
isInitialized = true;
}
public void ResetFitterData()
{
isFitterInitialized = false;
}
public void Animate()
{
if (isOn) { PlayOut(); }
else { PlayIn(); }
}
public void PlayIn()
{
gameObject.SetActive(true);
if (fitterMode && !isFitterInitialized)
{
cg.alpha = 0;
StartCoroutine("InitFitter");
return;
}
if (animationMode == AnimationMode.Scale && cg != null)
{
if (gameObject.activeInHierarchy) { StartCoroutine("ScaleIn"); }
else { cg.alpha = 1; rect.localScale = new Vector3(1, 1, 1); }
}
else if (animationMode == AnimationMode.Horizontal && cg != null)
{
if (gameObject.activeInHierarchy) { StartCoroutine("HorizontalIn"); }
else { cg.alpha = 1; }
}
else if (animationMode == AnimationMode.Vertical && cg != null)
{
if (gameObject.activeInHierarchy) { StartCoroutine("VerticalIn"); }
else { cg.alpha = 1; }
}
isOn = true;
onEnable.Invoke();
}
public void PlayOut()
{
if (instantOut)
{
gameObject.SetActive(false);
isOn = false;
return;
}
if (animationMode == AnimationMode.Scale && cg != null)
{
if (gameObject.activeInHierarchy) { StartCoroutine("ScaleOut"); }
else { cg.alpha = 0; rect.localScale = new Vector3(0, 0, 0); gameObject.SetActive(false); }
}
else if (animationMode == AnimationMode.Horizontal && cg != null)
{
if (gameObject.activeInHierarchy) { StartCoroutine("HorizontalOut"); }
else { cg.alpha = 0; gameObject.SetActive(false); }
}
else if (animationMode == AnimationMode.Vertical && cg != null)
{
if (gameObject.activeInHierarchy) { StartCoroutine("VerticalOut"); }
else { cg.alpha = 0; gameObject.SetActive(false); }
}
isOn = false;
onDisable.Invoke();
}
IEnumerator InitFitter()
{
yield return new WaitForSecondsRealtime(0.04f);
ContentSizeFitter csf = GetComponent<ContentSizeFitter>();
csf.enabled = false;
rectHelper = rect.sizeDelta;
isFitterInitialized = true;
PlayIn();
}
IEnumerator ScaleIn()
{
StopCoroutine("ScaleOut");
float elapsedTime = 0;
float startingPoint = 0;
float smoothValue = 0;
rect.localScale = new Vector3(0, 0, 0);
cg.alpha = 0;
while (rect.localScale.x < 0.99)
{
elapsedTime += Time.unscaledDeltaTime;
smoothValue = Mathf.Lerp(startingPoint, 1, animationCurve.Evaluate(elapsedTime * curveSpeed));
rect.localScale = new Vector3(smoothValue, smoothValue, smoothValue);
cg.alpha = smoothValue;
yield return null;
}
cg.alpha = 1;
rect.localScale = new Vector3(1, 1, 1);
onVisible.Invoke();
}
IEnumerator ScaleOut()
{
StopCoroutine("ScaleIn");
float elapsedTime = 0;
float startingPoint = 1;
float smoothValue = 0;
rect.localScale = new Vector3(1, 1, 1);
cg.alpha = 1;
while (rect.localScale.x > 0.01)
{
elapsedTime += Time.unscaledDeltaTime;
smoothValue = Mathf.Lerp(startingPoint, 0, animationCurve.Evaluate(elapsedTime * curveSpeed));
rect.localScale = new Vector3(smoothValue, smoothValue, smoothValue);
cg.alpha = smoothValue;
yield return null;
}
cg.alpha = 0;
rect.localScale = new Vector3(0, 0, 0);
gameObject.SetActive(false);
}
IEnumerator HorizontalIn()
{
StopCoroutine("HorizontalOut");
float elapsedTime = 0;
Vector2 startPos = new Vector2(0, rect.sizeDelta.y);
Vector2 endPos = rectHelper;
if (!fitterMode && startBehaviour == StartBehaviour.Default) { endPos = rect.sizeDelta; }
else if (fitterMode && startBehaviour == StartBehaviour.Default) { endPos = rectHelper; }
rect.sizeDelta = startPos;
while (rect.sizeDelta.x <= endPos.x - 0.1f)
{
elapsedTime += Time.unscaledDeltaTime;
cg.alpha += Time.unscaledDeltaTime * (curveSpeed * 2);
rect.sizeDelta = Vector2.Lerp(startPos, endPos, animationCurve.Evaluate(elapsedTime * curveSpeed));
yield return null;
}
cg.alpha = 1;
rect.sizeDelta = endPos;
onVisible.Invoke();
}
IEnumerator HorizontalOut()
{
StopCoroutine("HorizontalIn");
float elapsedTime = 0;
Vector2 startPos = rect.sizeDelta;
Vector2 endPos = new Vector2(0, rect.sizeDelta.y);
while (rect.sizeDelta.x >= 0.1f)
{
elapsedTime += Time.unscaledDeltaTime;
cg.alpha -= Time.unscaledDeltaTime * (curveSpeed * 2);
rect.sizeDelta = Vector2.Lerp(startPos, endPos, animationCurve.Evaluate(elapsedTime * curveSpeed));
yield return null;
}
cg.alpha = 0;
rect.sizeDelta = endPos;
rect.gameObject.SetActive(false);
}
IEnumerator VerticalIn()
{
StopCoroutine("VerticalOut");
float elapsedTime = 0;
Vector2 startPos = new Vector2(rect.sizeDelta.x, 0);
Vector2 endPos = rectHelper;
if (!fitterMode && startBehaviour == StartBehaviour.Default) { endPos = rect.sizeDelta; }
else if (fitterMode && startBehaviour == StartBehaviour.Default) { endPos = rectHelper; }
rect.sizeDelta = startPos;
while (rect.sizeDelta.y <= endPos.y - 0.1f)
{
elapsedTime += Time.unscaledDeltaTime;
cg.alpha += Time.unscaledDeltaTime * (curveSpeed * 2);
rect.sizeDelta = Vector2.Lerp(startPos, endPos, animationCurve.Evaluate(elapsedTime * curveSpeed));
yield return null;
}
cg.alpha = 1;
rect.sizeDelta = endPos;
onVisible.Invoke();
}
IEnumerator VerticalOut()
{
StopCoroutine("VerticalIn");
float elapsedTime = 0;
Vector2 startPos = rect.sizeDelta;
Vector2 endPos = new Vector2(rect.sizeDelta.x, 0);
while (rect.sizeDelta.y >= 0.1f)
{
elapsedTime += Time.unscaledDeltaTime;
cg.alpha -= Time.unscaledDeltaTime * (curveSpeed * 2);
rect.sizeDelta = Vector2.Lerp(startPos, endPos, animationCurve.Evaluate(elapsedTime * curveSpeed));
yield return null;
}
cg.alpha = 0;
rect.sizeDelta = endPos;
rect.gameObject.SetActive(false);
}
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: b802ad4a4b7423d4dad4fbd75775e08f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: b633d2f960ff9e74a901c2047b5e76ea, 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/Animation/UIPopup.cs
uploadId: 629893

View File

@ -0,0 +1,57 @@
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.InputSystem;
namespace Michsky.UI.Heat
{
public class UISway : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
{
[Header("Resources")]
[SerializeField] private Canvas mainCanvas;
[SerializeField] private Camera mainCamera;
[SerializeField] private RectTransform swayObject;
[Header("Settings")]
[SerializeField] [Range(1, 20)] private float smoothness = 10;
[SerializeField] private InputType inputType = InputType.Mouse;
bool allowSway;
Vector3 cursorPos;
Vector2 defaultPos;
public enum InputType { Mouse, Touchscreen }
void Start()
{
defaultPos = swayObject.anchoredPosition;
if (mainCamera == null) { mainCamera = Camera.main; }
if (mainCanvas == null) { mainCanvas = GetComponentInParent<Canvas>(); }
if (swayObject == null) { swayObject = GetComponent<RectTransform>(); }
}
void Update()
{
if (allowSway == true && inputType == InputType.Mouse) { cursorPos = Mouse.current.position.ReadValue(); }
else if (allowSway == true && inputType == InputType.Touchscreen) { cursorPos = Touchscreen.current.position.ReadValue(); }
if (mainCanvas.renderMode == RenderMode.ScreenSpaceOverlay) { ProcessOverlay(); }
else if (mainCanvas.renderMode == RenderMode.ScreenSpaceCamera) { ProcessSSC(); }
}
void ProcessOverlay()
{
if (allowSway == true) { swayObject.position = Vector2.Lerp(swayObject.position, cursorPos, Time.unscaledDeltaTime * smoothness); }
else { swayObject.localPosition = Vector2.Lerp(swayObject.localPosition, defaultPos, Time.unscaledDeltaTime * smoothness); }
}
void ProcessSSC()
{
if (allowSway == true) { swayObject.position = Vector2.Lerp(swayObject.position, mainCamera.ScreenToWorldPoint(cursorPos), Time.unscaledDeltaTime * smoothness); }
else { swayObject.localPosition = Vector2.Lerp(swayObject.localPosition, defaultPos, Time.unscaledDeltaTime * smoothness); }
}
public void OnPointerEnter(PointerEventData data) { allowSway = true; }
public void OnPointerExit(PointerEventData data) { allowSway = false; }
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 21efdb94c15fff540a26f74d885ef3a5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: b633d2f960ff9e74a901c2047b5e76ea, 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/Animation/UISway.cs
uploadId: 629893

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 22368d28ecc9dd54c8edee507847ecf8
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,24 @@
using UnityEngine;
namespace Michsky.UI.Heat
{
public class HeatUIInternalTools : MonoBehaviour
{
public static float GetAnimatorClipLength(Animator _animator, string _clipName)
{
float _lengthValue = -1;
RuntimeAnimatorController _rac = _animator.runtimeAnimatorController;
for (int i = 0; i < _rac.animationClips.Length; i++)
{
if (_rac.animationClips[i].name == _clipName)
{
_lengthValue = _rac.animationClips[i].length;
break;
}
}
return _lengthValue;
}
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 09a474342020a0144bfa8fe19e57e741
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: ee083492dcf46e24daded170502f8f55, 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/Core/HeatUIInternalTools.cs
uploadId: 629893

View File

@ -0,0 +1,136 @@
using System.Collections;
using UnityEngine;
using UnityEngine.EventSystems;
namespace Michsky.UI.Heat
{
[DisallowMultipleComponent]
public class MenuManager : MonoBehaviour
{
// Resources
public UIManager UIManagerAsset;
public Animator splashScreen;
[SerializeField] private GameObject mainContent;
[SerializeField] private ImageFading initPanel;
// Helpers
float splashInTime;
float splashOutTime;
void Awake()
{
Time.timeScale = 1;
if (initPanel != null) { initPanel.gameObject.SetActive(true); }
if (splashScreen != null) { splashScreen.gameObject.SetActive(false); }
}
void Start()
{
StartCoroutine("StartInitialize");
}
public void DisableSplashScreen()
{
StopCoroutine("DisableSplashScreenAnimator");
StartCoroutine("FinalizeSplashScreen");
splashScreen.enabled = true;
splashScreen.Play("Out");
}
void Initialize()
{
if (UIManagerAsset == null || mainContent == null)
{
Debug.LogError("<b>[Heat UI]</b> Cannot initialize the resources due to missing resources.", this);
return;
}
mainContent.gameObject.SetActive(false);
bool enableSplashAfter = false;
if (UIManagerAsset.enableSplashScreen && UIManagerAsset.showSplashScreenOnce && GameObject.Find("[Heat UI - Splash Screen Helper]") != null)
{
UIManagerAsset.enableSplashScreen = false;
enableSplashAfter = true;
}
if (UIManagerAsset.enableSplashScreen)
{
if (splashScreen == null)
{
Debug.LogError("<b>[Heat UI]</b> Splash Screen is enabled but its resource is missing. Please assign the correct variable for 'Splash Screen'.", this);
return;
}
// Getting in and out animation length
AnimationClip[] clips = splashScreen.runtimeAnimatorController.animationClips;
splashInTime = clips[0].length;
splashOutTime = clips[1].length;
splashScreen.enabled = true;
splashScreen.gameObject.SetActive(true);
StartCoroutine("DisableSplashScreenAnimator");
if (UIManagerAsset.showSplashScreenOnce)
{
GameObject tempHelper = new GameObject();
tempHelper.name = "[Heat UI - Splash Screen Helper]";
DontDestroyOnLoad(tempHelper);
}
}
else
{
if (mainContent == null)
{
Debug.LogError("<b>[Heat UI]</b> 'Main Panels' is missing. Please assign the correct variable for 'Main Panels'.", this);
return;
}
if (splashScreen != null) { splashScreen.gameObject.SetActive(false); }
mainContent.gameObject.SetActive(false);
StartCoroutine("FinalizeSplashScreen");
}
if (enableSplashAfter && UIManagerAsset.showSplashScreenOnce)
{
UIManagerAsset.enableSplashScreen = true;
}
}
IEnumerator StartInitialize()
{
yield return new WaitForSeconds(0.5f);
if (initPanel != null) { initPanel.FadeOut(); }
Initialize();
}
IEnumerator DisableSplashScreenAnimator()
{
yield return new WaitForSeconds(splashInTime + 0.1f);
splashScreen.enabled = false;
}
IEnumerator FinalizeSplashScreen()
{
yield return new WaitForSeconds(splashOutTime + 0.1f);
if (UIManagerAsset != null && UIManagerAsset.enableSplashScreen)
{
splashScreen.gameObject.SetActive(false);
}
mainContent.gameObject.SetActive(true);
if (ControllerManager.instance != null
&& ControllerManager.instance.gamepadEnabled
&& ControllerManager.instance.firstSelected != null
&& ControllerManager.instance.firstSelected.activeInHierarchy)
{
EventSystem.current.SetSelectedGameObject(ControllerManager.instance.firstSelected);
}
}
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: a361a3179177dcd43a32bf89f6e8f310
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: fd3012dcfab95cb469aa3dd70c6af50b, 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/Core/MenuManager.cs
uploadId: 629893

View File

@ -0,0 +1,72 @@
#if UNITY_EDITOR
using UnityEngine;
using UnityEditor;
using UnityEditor.SceneManagement;
namespace Michsky.UI.Heat
{
[CanEditMultipleObjects]
[CustomEditor(typeof(MenuManager))]
public class MenuManagerEditor : Editor
{
private MenuManager mmTarget;
private GUISkin customSkin;
private void OnEnable()
{
mmTarget = (MenuManager)target;
if (EditorGUIUtility.isProSkin == true) { customSkin = HeatUIEditorHandler.GetDarkEditor(customSkin); }
else { customSkin = HeatUIEditorHandler.GetLightEditor(customSkin); }
}
public override void OnInspectorGUI()
{
var UIManagerAsset = serializedObject.FindProperty("UIManagerAsset");
var splashScreen = serializedObject.FindProperty("splashScreen");
var mainContent = serializedObject.FindProperty("mainContent");
var initPanel = serializedObject.FindProperty("initPanel");
HeatUIEditorHandler.DrawHeader(customSkin, "Core Header", 6);
HeatUIEditorHandler.DrawProperty(UIManagerAsset, customSkin, "UI Manager");
HeatUIEditorHandler.DrawProperty(splashScreen, customSkin, "Splash Screen");
HeatUIEditorHandler.DrawProperty(mainContent, customSkin, "Main Content");
HeatUIEditorHandler.DrawProperty(initPanel, customSkin, "Init Screen");
if (mmTarget.UIManagerAsset != null)
{
HeatUIEditorHandler.DrawHeader(customSkin, "Options Header", 10);
GUILayout.BeginHorizontal(EditorStyles.helpBox);
mmTarget.UIManagerAsset.enableSplashScreen = GUILayout.Toggle(mmTarget.UIManagerAsset.enableSplashScreen, "Enable Splash Screen", customSkin.FindStyle("Toggle"));
mmTarget.UIManagerAsset.enableSplashScreen = GUILayout.Toggle(mmTarget.UIManagerAsset.enableSplashScreen, new GUIContent(""), customSkin.FindStyle("Toggle Helper"));
GUILayout.EndHorizontal();
if (mmTarget.splashScreen != null)
{
GUILayout.BeginHorizontal();
if (Application.isPlaying == false)
{
if (mmTarget.splashScreen.gameObject.activeSelf == false && GUILayout.Button("Show Splash Screen", customSkin.button))
{
mmTarget.splashScreen.gameObject.SetActive(true);
EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
}
else if (mmTarget.splashScreen.gameObject.activeSelf == true && GUILayout.Button("Hide Splash Screen", customSkin.button))
{
mmTarget.splashScreen.gameObject.SetActive(false);
EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
}
}
if (GUILayout.Button("Select Splash Screen", customSkin.button)) { Selection.activeObject = mmTarget.splashScreen; }
GUILayout.EndHorizontal();
}
}
serializedObject.ApplyModifiedProperties();
}
}
}
#endif

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 9e0da5054d9e84642abe2f729dbed1b6
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/Core/MenuManagerEditor.cs
uploadId: 629893

View File

@ -0,0 +1,142 @@
using System.Collections;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.EventSystems;
using UnityEngine.InputSystem;
namespace Michsky.UI.Heat
{
public class PauseMenuManager : MonoBehaviour
{
// Resources
public GameObject pauseMenuCanvas;
[SerializeField] private ButtonManager continueButton;
[SerializeField] private PanelManager panelManager;
[SerializeField] private ImageFading background;
// Settings
[SerializeField] private bool setTimeScale = true;
[Range(0, 1)] public float inputBlockDuration = 0.2f;
public CursorLockMode menuCursorState = CursorLockMode.None;
public CursorLockMode gameCursorState = CursorLockMode.Locked;
[SerializeField] private InputAction hotkey;
// Events
public UnityEvent onOpen;
public UnityEvent onClose;
// Helpers
bool isOn = false;
bool allowClosing = true;
float disableAfter = 0.6f;
public enum CursorVisibility { Invisible, Visible }
void Awake()
{
if (pauseMenuCanvas == null)
{
Debug.LogError("<b>[Pause Menu Manager]</b> Pause Menu Canvas is missing!", this);
this.enabled = false;
return;
}
pauseMenuCanvas.SetActive(true);
}
void Start()
{
if (panelManager != null) { disableAfter = HeatUIInternalTools.GetAnimatorClipLength(panelManager.panels[panelManager.currentPanelIndex].panelObject, "MainPanel_Out"); }
if (continueButton != null) { continueButton.onClick.AddListener(ClosePauseMenu); }
pauseMenuCanvas.SetActive(false);
hotkey.Enable();
}
void Update()
{
if (hotkey.triggered) { AnimatePauseMenu(); }
}
public void AnimatePauseMenu()
{
if (isOn == false) { OpenPauseMenu(); }
else { ClosePauseMenu(); }
}
public void OpenPauseMenu()
{
if (isOn == true) { return; }
if (setTimeScale == true) { Time.timeScale = 0; }
if (inputBlockDuration > 0)
{
AllowClosing(false);
StopCoroutine("InputBlockProcess");
StartCoroutine("InputBlockProcess");
}
StopCoroutine("DisablePauseCanvas");
isOn = true;
pauseMenuCanvas.SetActive(false);
pauseMenuCanvas.SetActive(true);
onOpen.Invoke();
FadeInBackground();
Cursor.lockState = menuCursorState;
if (continueButton != null && Gamepad.current != null)
{
EventSystem.current.SetSelectedGameObject(null);
EventSystem.current.SetSelectedGameObject(continueButton.gameObject);
}
}
public void ClosePauseMenu()
{
if (isOn == false || allowClosing == false) { return; }
if (setTimeScale == true) { Time.timeScale = 1; }
if (panelManager != null) { panelManager.HideCurrentPanel(); }
StopCoroutine("DisablePauseCanvas");
StartCoroutine("DisablePauseCanvas");
isOn = false;
onClose.Invoke();
FadeOutBackground();
Cursor.lockState = gameCursorState;
}
public void FadeInBackground()
{
if (background == null)
return;
background.FadeIn();
}
public void FadeOutBackground()
{
if (background == null)
return;
background.FadeOut();
}
public void AllowClosing(bool value)
{
allowClosing = value;
}
IEnumerator DisablePauseCanvas()
{
yield return new WaitForSecondsRealtime(disableAfter);
pauseMenuCanvas.SetActive(false);
}
IEnumerator InputBlockProcess()
{
yield return new WaitForSecondsRealtime(inputBlockDuration);
AllowClosing(true);
}
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: acd5405ad257ceb49986ab821a76b0ae
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: fd3012dcfab95cb469aa3dd70c6af50b, 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/Core/PauseMenuManager.cs
uploadId: 629893

View File

@ -0,0 +1,84 @@
#if UNITY_EDITOR
using UnityEngine;
using UnityEditor;
using UnityEditor.SceneManagement;
namespace Michsky.UI.Heat
{
[CanEditMultipleObjects]
[CustomEditor(typeof(PauseMenuManager))]
public class PauseMenuManagerEditor : Editor
{
private PauseMenuManager pmmTarget;
private GUISkin customSkin;
private void OnEnable()
{
pmmTarget = (PauseMenuManager)target;
if (EditorGUIUtility.isProSkin == true) { customSkin = HeatUIEditorHandler.GetDarkEditor(customSkin); }
else { customSkin = HeatUIEditorHandler.GetLightEditor(customSkin); }
}
public override void OnInspectorGUI()
{
var pauseMenuCanvas = serializedObject.FindProperty("pauseMenuCanvas");
var continueButton = serializedObject.FindProperty("continueButton");
var panelManager = serializedObject.FindProperty("panelManager");
var background = serializedObject.FindProperty("background");
var setTimeScale = serializedObject.FindProperty("setTimeScale");
var inputBlockDuration = serializedObject.FindProperty("inputBlockDuration");
var menuCursorState = serializedObject.FindProperty("menuCursorState");
var gameCursorState = serializedObject.FindProperty("gameCursorState");
var hotkey = serializedObject.FindProperty("hotkey");
var onOpen = serializedObject.FindProperty("onOpen");
var onClose = serializedObject.FindProperty("onClose");
if (pmmTarget.pauseMenuCanvas != null)
{
HeatUIEditorHandler.DrawHeader(customSkin, "Content Header", 6);
GUILayout.BeginHorizontal();
if (Application.isPlaying == false)
{
if (pmmTarget.pauseMenuCanvas.gameObject.activeSelf == false && GUILayout.Button("Show Pause Menu", customSkin.button))
{
pmmTarget.pauseMenuCanvas.gameObject.SetActive(true);
EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
}
else if (pmmTarget.pauseMenuCanvas.gameObject.activeSelf == true && GUILayout.Button("Hide Pause Menu", customSkin.button))
{
pmmTarget.pauseMenuCanvas.gameObject.SetActive(false);
EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
}
}
if (GUILayout.Button("Select Object", customSkin.button)) { Selection.activeObject = pmmTarget.pauseMenuCanvas; }
GUILayout.EndHorizontal();
}
HeatUIEditorHandler.DrawHeader(customSkin, "Core Header", 10);
HeatUIEditorHandler.DrawProperty(pauseMenuCanvas, customSkin, "Pause Canvas");
HeatUIEditorHandler.DrawProperty(continueButton, customSkin, "Continue Button");
HeatUIEditorHandler.DrawProperty(panelManager, customSkin, "Panel Manager");
HeatUIEditorHandler.DrawProperty(background, customSkin, "Background");
HeatUIEditorHandler.DrawHeader(customSkin, "Options Header", 10);
setTimeScale.boolValue = HeatUIEditorHandler.DrawToggle(setTimeScale.boolValue, customSkin, "Set Time Scale", "Sets the time scale depending on the pause menu state.");
HeatUIEditorHandler.DrawProperty(inputBlockDuration, customSkin, "Input Block Duration", "Block input in specific amount of time to provide smooth visuals.");
HeatUIEditorHandler.DrawProperty(menuCursorState, customSkin, "Menu Cursor State");
HeatUIEditorHandler.DrawProperty(gameCursorState, customSkin, "Game Cursor State");
EditorGUILayout.PropertyField(hotkey, new GUIContent("Hotkey"), true);
HeatUIEditorHandler.DrawHeader(customSkin, "Events Header", 10);
EditorGUILayout.PropertyField(onOpen, new GUIContent("On Open"), true);
EditorGUILayout.PropertyField(onClose, new GUIContent("On Close"), true);
serializedObject.ApplyModifiedProperties();
}
}
}
#endif

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 855e8e244f547d64db36223f5020e342
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/Core/PauseMenuManagerEditor.cs
uploadId: 629893

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 361b7bc408661384c9b115e5f01fc16d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

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

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: aba7003a35bb26a47a1663828abc6cc8
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,201 @@
#if UNITY_EDITOR
using UnityEngine;
using UnityEditor;
namespace Michsky.UI.Heat
{
public class HeatUIEditorHandler : Editor
{
public static GUISkin GetDarkEditor(GUISkin tempSkin)
{
tempSkin = (GUISkin)Resources.Load("HeatUIEditor-Dark");
return tempSkin;
}
public static GUISkin GetLightEditor(GUISkin tempSkin)
{
tempSkin = (GUISkin)Resources.Load("HeatUIEditor-Light");
return tempSkin;
}
public static void DrawProperty(SerializedProperty property, GUISkin skin, string content)
{
GUILayout.BeginHorizontal(EditorStyles.helpBox);
EditorGUILayout.LabelField(new GUIContent(content), skin.FindStyle("Text"), GUILayout.Width(120));
EditorGUILayout.PropertyField(property, new GUIContent(""));
GUILayout.EndHorizontal();
}
public static void DrawProperty(SerializedProperty property, GUISkin skin, string content, string tooltip)
{
GUILayout.BeginHorizontal(EditorStyles.helpBox);
EditorGUILayout.LabelField(new GUIContent(content, tooltip), skin.FindStyle("Text"), GUILayout.Width(120));
EditorGUILayout.PropertyField(property, new GUIContent("", tooltip));
GUILayout.EndHorizontal();
}
public static void DrawPropertyPlain(SerializedProperty property, GUISkin skin, string content)
{
GUILayout.BeginHorizontal();
EditorGUILayout.LabelField(new GUIContent(content), skin.FindStyle("Text"), GUILayout.Width(120));
EditorGUILayout.PropertyField(property, new GUIContent(""));
GUILayout.EndHorizontal();
}
public static void DrawPropertyPlain(SerializedProperty property, GUISkin skin, string content, string tooltip)
{
GUILayout.BeginHorizontal();
EditorGUILayout.LabelField(new GUIContent(content, tooltip), skin.FindStyle("Text"), GUILayout.Width(120));
EditorGUILayout.PropertyField(property, new GUIContent("", tooltip));
GUILayout.EndHorizontal();
}
public static void DrawPropertyCW(SerializedProperty property, GUISkin skin, string content, float width)
{
GUILayout.BeginHorizontal(EditorStyles.helpBox);
EditorGUILayout.LabelField(new GUIContent(content), skin.FindStyle("Text"), GUILayout.Width(width));
EditorGUILayout.PropertyField(property, new GUIContent(""));
GUILayout.EndHorizontal();
}
public static void DrawPropertyCW(SerializedProperty property, GUISkin skin, string content, string tooltip, float width)
{
GUILayout.BeginHorizontal(EditorStyles.helpBox);
EditorGUILayout.LabelField(new GUIContent(content, tooltip), skin.FindStyle("Text"), GUILayout.Width(width));
EditorGUILayout.PropertyField(property, new GUIContent("", tooltip));
GUILayout.EndHorizontal();
}
public static void DrawPropertyPlainCW(SerializedProperty property, GUISkin skin, string content, float width)
{
GUILayout.BeginHorizontal();
EditorGUILayout.LabelField(new GUIContent(content), skin.FindStyle("Text"), GUILayout.Width(width));
EditorGUILayout.PropertyField(property, new GUIContent(""));
GUILayout.EndHorizontal();
}
public static int DrawTabs(int tabIndex, GUIContent[] tabs, GUISkin skin)
{
GUILayout.BeginHorizontal();
GUILayout.Space(17);
tabIndex = GUILayout.Toolbar(tabIndex, tabs, skin.FindStyle("Tab Indicator"));
GUILayout.EndHorizontal();
GUILayout.Space(-40);
GUILayout.BeginHorizontal();
GUILayout.Space(17);
return tabIndex;
}
public static void DrawComponentHeader(GUISkin skin, string content)
{
GUILayout.BeginHorizontal();
GUILayout.Box(new GUIContent(""), skin.FindStyle(content));
GUILayout.EndHorizontal();
GUILayout.Space(-42);
}
public static void DrawHeader(GUISkin skin, string content, int space)
{
GUILayout.Space(space);
GUILayout.Box(new GUIContent(""), skin.FindStyle(content));
}
public static bool DrawToggle(bool value, GUISkin skin, string content)
{
GUILayout.BeginHorizontal(EditorStyles.helpBox);
value = GUILayout.Toggle(value, new GUIContent(content, "Current state: " + value.ToString()), skin.FindStyle("Toggle"));
value = GUILayout.Toggle(value, new GUIContent("", "Current state: " + value.ToString()), skin.FindStyle("Toggle Helper"));
GUILayout.EndHorizontal();
return value;
}
public static bool DrawToggle(bool value, GUISkin skin, string content, string tooltip)
{
GUILayout.BeginHorizontal(EditorStyles.helpBox);
value = GUILayout.Toggle(value, new GUIContent(content, tooltip), skin.FindStyle("Toggle"));
value = GUILayout.Toggle(value, new GUIContent("", tooltip), skin.FindStyle("Toggle Helper"));
GUILayout.EndHorizontal();
return value;
}
public static bool DrawTogglePlain(bool value, GUISkin skin, string content)
{
GUILayout.BeginHorizontal();
value = GUILayout.Toggle(value, new GUIContent(content, "Current state: " + value.ToString()), skin.FindStyle("Toggle"));
value = GUILayout.Toggle(value, new GUIContent("", "Current state: " + value.ToString()), skin.FindStyle("Toggle Helper"));
GUILayout.EndHorizontal();
return value;
}
public static bool DrawTogglePlain(bool value, GUISkin skin, string content, string tooltip)
{
GUILayout.BeginHorizontal();
value = GUILayout.Toggle(value, new GUIContent(content, tooltip), skin.FindStyle("Toggle"));
value = GUILayout.Toggle(value, new GUIContent("", tooltip), skin.FindStyle("Toggle Helper"));
GUILayout.EndHorizontal();
return value;
}
public static void DrawUIManagerConnectedHeader()
{
EditorGUILayout.HelpBox("This object is connected with the UI Manager. Some parameters (such as colors, " +
"fonts or booleans) are managed by the manager.", MessageType.Info);
}
public static void DrawUIManagerPresetHeader()
{
EditorGUILayout.HelpBox("This object is subject to a preset and cannot be used with the UI Manager. " +
"You can use the standard object for UI Manager connection.", MessageType.Info);
}
public static void DrawUIManagerDisconnectedHeader()
{
EditorGUILayout.HelpBox("This object does not have any connection with the UI Manager.", MessageType.Info);
}
public static Texture2D TextureFromSprite(Sprite sprite)
{
if (sprite == null) { return null; }
if (sprite.rect.width != sprite.texture.width)
{
Texture2D newText = new Texture2D((int)sprite.rect.width, (int)sprite.rect.height);
Color[] newColors = sprite.texture.GetPixels((int)sprite.textureRect.x,
(int)sprite.textureRect.y,
(int)sprite.textureRect.width,
(int)sprite.textureRect.height);
newText.SetPixels(newColors);
newText.Apply();
return newText;
}
else { return sprite.texture; }
}
}
}
#endif

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 2bd996be016e5324cb8feab821d3e1eb
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/Editor Handlers/HeatUIEditorHandler.cs
uploadId: 629893

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: da6662818dd88244d8349a654f8f973e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,276 @@
using System.Collections;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
using UnityEngine.EventSystems;
using UnityEngine.InputSystem;
using TMPro;
namespace Michsky.UI.Heat
{
[ExecuteInEditMode]
[AddComponentMenu("Heat UI/Input/Hotkey Event")]
public class HotkeyEvent : MonoBehaviour, IPointerClickHandler, IPointerEnterHandler, IPointerExitHandler
{
// Content
public HotkeyType hotkeyType = HotkeyType.Custom;
public ControllerPreset controllerPreset;
public InputAction hotkey;
public string keyID = "Escape";
public string hotkeyLabel = "Exit";
// Resources
[SerializeField] private GameObject iconParent;
[SerializeField] private GameObject textParent;
[SerializeField] private Image iconObj;
[SerializeField] private TextMeshProUGUI labelObj;
[SerializeField] private TextMeshProUGUI textObj;
[SerializeField] private CanvasGroup normalCG;
[SerializeField] private CanvasGroup highlightCG;
// Settings
public bool useSounds = false;
public bool useLocalization = true;
[Range(1, 15)] public float fadingMultiplier = 8;
// Events
public UnityEvent onHotkeyPress = new UnityEvent();
// Helpers
bool isInitialized = false;
LocalizedObject localizedObject;
#if UNITY_EDITOR
public bool showOutputOnEditor = true;
#endif
public enum HotkeyType { Dynamic, Custom }
void OnEnable()
{
#if UNITY_EDITOR
if (!Application.isPlaying && controllerPreset != null && hotkeyType == HotkeyType.Dynamic) { UpdateVisual(); }
if (!Application.isPlaying) { return; }
#endif
if (!isInitialized) { Initialize(); }
if (ControllerManager.instance != null && hotkeyType == HotkeyType.Dynamic)
{
ControllerManager.instance.hotkeyObjects.Add(this);
controllerPreset = ControllerManager.instance.currentControllerPreset;
}
UpdateUI();
}
void Update()
{
if (hotkey.triggered)
{
onHotkeyPress.Invoke();
}
}
void Initialize()
{
#if UNITY_EDITOR
if (!Application.isPlaying) { return; }
#endif
hotkey.Enable();
if (hotkeyType == HotkeyType.Dynamic && gameObject.GetComponent<Image>() == null)
{
Image raycastImg = gameObject.AddComponent<Image>();
raycastImg.color = new Color(0, 0, 0, 0);
raycastImg.raycastTarget = true;
}
if (UIManagerAudio.instance == null) { useSounds = false; }
if (useLocalization)
{
localizedObject = gameObject.GetComponent<LocalizedObject>();
if (localizedObject == null || !localizedObject.CheckLocalizationStatus()) { useLocalization = false; }
else if (localizedObject != null && !string.IsNullOrEmpty(localizedObject.localizationKey))
{
// Forcing object to take the localized output on awake
hotkeyLabel = localizedObject.GetKeyOutput(localizedObject.localizationKey);
// Change label text on language change
localizedObject.onLanguageChanged.AddListener(delegate
{
hotkeyLabel = localizedObject.GetKeyOutput(localizedObject.localizationKey);
SetLabel(hotkeyLabel);
});
}
}
if (useSounds)
{
onHotkeyPress.AddListener(delegate { UIManagerAudio.instance.audioSource.PlayOneShot(UIManagerAudio.instance.UIManagerAsset.clickSound); });
}
isInitialized = true;
}
public void UpdateUI()
{
if (hotkeyType == HotkeyType.Custom)
return;
if (hotkeyType == HotkeyType.Dynamic)
{
if (controllerPreset == null) { return; }
if (highlightCG != null) { highlightCG.alpha = 0; }
bool keyFound = false;
for (int i = 0; i < controllerPreset.items.Count; i++)
{
if (controllerPreset.items[i].itemID == keyID)
{
keyFound = true;
gameObject.SetActive(true);
if (labelObj != null) { labelObj.text = hotkeyLabel; }
if (controllerPreset.items[i].itemType == ControllerPreset.ItemType.Icon)
{
if (iconParent != null) { iconParent.SetActive(true); }
if (textParent != null) { textParent.SetActive(false); }
if (iconObj != null) { iconObj.sprite = controllerPreset.items[i].itemIcon; }
}
else if (controllerPreset.items[i].itemType == ControllerPreset.ItemType.Text)
{
if (iconParent != null) { iconParent.SetActive(false); }
if (textParent != null) { textParent.SetActive(true); }
if (textObj != null) { textObj.text = controllerPreset.items[i].itemText; }
}
break;
}
}
if (keyFound == false)
{
// gameObject.SetActive(false);
return;
}
}
if (gameObject.activeInHierarchy == true && Application.isPlaying) { StartCoroutine("LayoutFix"); }
else
{
LayoutRebuilder.ForceRebuildLayoutImmediate(GetComponent<RectTransform>());
if (normalCG != null) { LayoutRebuilder.ForceRebuildLayoutImmediate(normalCG.GetComponent<RectTransform>()); }
}
}
#if UNITY_EDITOR
public void UpdateVisual()
{
if (controllerPreset == null) { return; }
if (highlightCG != null) { highlightCG.alpha = 0; }
for (int i = 0; i < controllerPreset.items.Count; i++)
{
if (controllerPreset.items[i].itemID == keyID)
{
if (controllerPreset.items[i].itemType == ControllerPreset.ItemType.Icon)
{
if (iconParent != null) { iconParent.SetActive(true); }
if (textParent != null) { textParent.SetActive(false); }
if (iconObj != null) { iconObj.sprite = controllerPreset.items[i].itemIcon; }
}
else if (controllerPreset.items[i].itemType == ControllerPreset.ItemType.Text)
{
if (iconParent != null) { iconParent.SetActive(false); }
if (textParent != null) { textParent.SetActive(true); }
if (textObj != null) { textObj.text = controllerPreset.items[i].itemText; }
}
if (labelObj != null) { labelObj.text = hotkeyLabel; }
break;
}
}
LayoutRebuilder.ForceRebuildLayoutImmediate(GetComponent<RectTransform>());
if (normalCG != null) { LayoutRebuilder.ForceRebuildLayoutImmediate(normalCG.GetComponent<RectTransform>()); }
}
#endif
public void SetLabel(string value)
{
if (labelObj == null)
return;
labelObj.text = value;
if (gameObject.activeInHierarchy == true) { StartCoroutine("LayoutFix"); }
else
{
if (normalCG != null) { LayoutRebuilder.ForceRebuildLayoutImmediate(normalCG.GetComponent<RectTransform>()); }
LayoutRebuilder.ForceRebuildLayoutImmediate(GetComponent<RectTransform>());
LayoutRebuilder.ForceRebuildLayoutImmediate(transform.parent.GetComponent<RectTransform>());
}
}
public void OnPointerClick(PointerEventData eventData)
{
onHotkeyPress.Invoke();
if (useSounds) { UIManagerAudio.instance.audioSource.PlayOneShot(UIManagerAudio.instance.UIManagerAsset.clickSound); }
if (normalCG == null || highlightCG == null || gameObject.activeInHierarchy == false) { return; }
StopCoroutine("SetHighlight");
StartCoroutine("SetNormal");
}
public void OnPointerEnter(PointerEventData eventData)
{
if (useSounds) { UIManagerAudio.instance.audioSource.PlayOneShot(UIManagerAudio.instance.UIManagerAsset.hoverSound); }
if (normalCG == null || highlightCG == null) { return; }
StopCoroutine("SetNormal");
StartCoroutine("SetHighlight");
}
public void OnPointerExit(PointerEventData eventData)
{
if (normalCG == null || highlightCG == null)
return;
StopCoroutine("SetHighlight");
StartCoroutine("SetNormal");
}
IEnumerator LayoutFix()
{
yield return new WaitForSecondsRealtime(0.025f);
if (normalCG != null) { LayoutRebuilder.ForceRebuildLayoutImmediate(normalCG.GetComponent<RectTransform>()); }
LayoutRebuilder.ForceRebuildLayoutImmediate(GetComponent<RectTransform>());
LayoutRebuilder.ForceRebuildLayoutImmediate(transform.parent.GetComponent<RectTransform>());
}
IEnumerator SetNormal()
{
while (highlightCG.alpha > 0.01f)
{
highlightCG.alpha -= Time.unscaledDeltaTime * fadingMultiplier;
yield return null;
}
highlightCG.alpha = 0;
}
IEnumerator SetHighlight()
{
while (highlightCG.alpha < 0.99f)
{
highlightCG.alpha += Time.unscaledDeltaTime * fadingMultiplier;
yield return null;
}
highlightCG.alpha = 1;
}
}
}

View File

@ -0,0 +1,22 @@
fileFormatVersion: 2
guid: c9972513674083a4e8366856a6a50999
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences:
- controllerIcons: {fileID: 11400000, guid: 6cb65bb6d668729438f86d7c7c1f4522, type: 2}
- textPreset: {instanceID: 0}
- iconPreset: {fileID: 2393741490227731184, guid: a58adb5252f8b5447ace87508e27b7d3,
type: 3}
executionOrder: 0
icon: {fileID: 2800000, guid: f4007fbdb43231c4c8a13871706d7c46, 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/Events/HotkeyEvent.cs
uploadId: 629893

View File

@ -0,0 +1,196 @@
#if UNITY_EDITOR
using UnityEngine;
using UnityEditor;
using UnityEditor.SceneManagement;
namespace Michsky.UI.Heat
{
[CanEditMultipleObjects]
[CustomEditor(typeof(HotkeyEvent))]
public class HotkeyEventEditor : Editor
{
private HotkeyEvent heTarget;
private GUISkin customSkin;
private int latestTabIndex;
private string searchString;
Vector2 scrollPosition = Vector2.zero;
private void OnEnable()
{
heTarget = (HotkeyEvent)target;
if (EditorGUIUtility.isProSkin == true) { customSkin = HeatUIEditorHandler.GetDarkEditor(customSkin); }
else { customSkin = HeatUIEditorHandler.GetLightEditor(customSkin); }
if (!Application.isPlaying && heTarget.hotkeyType == HotkeyEvent.HotkeyType.Dynamic) { heTarget.UpdateVisual(); }
}
public override void OnInspectorGUI()
{
HeatUIEditorHandler.DrawComponentHeader(customSkin, "Hotkey Event 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 hotkeyType = serializedObject.FindProperty("hotkeyType");
var controllerPreset = serializedObject.FindProperty("controllerPreset");
var hotkey = serializedObject.FindProperty("hotkey");
var keyID = serializedObject.FindProperty("keyID");
var hotkeyLabel = serializedObject.FindProperty("hotkeyLabel");
var iconParent = serializedObject.FindProperty("iconParent");
var textParent = serializedObject.FindProperty("textParent");
var iconObj = serializedObject.FindProperty("iconObj");
var labelObj = serializedObject.FindProperty("labelObj");
var textObj = serializedObject.FindProperty("textObj");
var normalCG = serializedObject.FindProperty("normalCG");
var highlightCG = serializedObject.FindProperty("highlightCG");
var useSounds = serializedObject.FindProperty("useSounds");
var useLocalization = serializedObject.FindProperty("useLocalization");
var fadingMultiplier = serializedObject.FindProperty("fadingMultiplier");
var onHotkeyPress = serializedObject.FindProperty("onHotkeyPress");
switch (latestTabIndex)
{
case 0:
HeatUIEditorHandler.DrawHeader(customSkin, "Content Header", 6);
GUILayout.BeginVertical(EditorStyles.helpBox);
HeatUIEditorHandler.DrawPropertyPlainCW(hotkeyType, customSkin, "Hotkey Type", 82);
if (heTarget.hotkeyType == HotkeyEvent.HotkeyType.Dynamic)
{
EditorGUILayout.HelpBox("Dynamic: UI will adapt itself to the current controller scheme (if available). Recommended if you want to specify the hotkey in UI.", MessageType.Info);
HeatUIEditorHandler.DrawProperty(controllerPreset, customSkin, "Default Preset");
if (labelObj.objectReferenceValue != null) { HeatUIEditorHandler.DrawProperty(hotkeyLabel, customSkin, "Hotkey Label"); }
GUILayout.BeginHorizontal(EditorStyles.helpBox);
EditorGUILayout.LabelField(new GUIContent("Key ID"), customSkin.FindStyle("Text"), GUILayout.Width(120));
EditorGUILayout.PropertyField(keyID, new GUIContent(""));
heTarget.showOutputOnEditor = GUILayout.Toggle(heTarget.showOutputOnEditor, new GUIContent("", "See output"), GUILayout.Width(15), GUILayout.Height(18));
GUILayout.EndHorizontal();
// Search for keys
if (heTarget.controllerPreset != null)
{
GUILayout.BeginVertical(EditorStyles.helpBox);
EditorGUILayout.LabelField(new GUIContent("Search for keys in " + heTarget.controllerPreset.name), customSkin.FindStyle("Text"));
GUILayout.BeginHorizontal();
searchString = GUILayout.TextField(searchString, GUI.skin.FindStyle("ToolbarSearchTextField"));
if (!string.IsNullOrEmpty(searchString) && GUILayout.Button(new GUIContent("", "Clear search bar"), GUI.skin.FindStyle("ToolbarSearchCancelButton"))) { searchString = ""; GUI.FocusControl(null); }
GUILayout.EndHorizontal();
if (!string.IsNullOrEmpty(searchString))
{
scrollPosition = GUILayout.BeginScrollView(scrollPosition, false, true, GUIStyle.none, GUI.skin.verticalScrollbar, GUILayout.Height(132));
GUILayout.BeginVertical();
for (int i = 0; i < heTarget.controllerPreset.items.Count; i++)
{
if (heTarget.controllerPreset.items[i].itemID.ToLower().Contains(searchString.ToLower()))
{
if (GUILayout.Button(new GUIContent(heTarget.controllerPreset.items[i].itemID), customSkin.button))
{
heTarget.keyID = heTarget.controllerPreset.items[i].itemID;
searchString = "";
GUI.FocusControl(null);
EditorUtility.SetDirty(heTarget);
}
}
}
GUILayout.EndVertical();
GUILayout.EndScrollView();
}
GUILayout.EndVertical();
if (heTarget.showOutputOnEditor == true)
{
GUI.enabled = false;
for (int i = 0; i < heTarget.controllerPreset.items.Count; i++)
{
if (heTarget.controllerPreset.items[i].itemID == heTarget.keyID)
{
EditorGUILayout.LabelField(new GUIContent("Output for " + heTarget.controllerPreset.items[i].itemID), customSkin.FindStyle("Text"));
EditorGUILayout.LabelField(new GUIContent("[Type] " + heTarget.controllerPreset.items[i].itemType.ToString()), customSkin.FindStyle("Text"));
if (heTarget.controllerPreset.items[i].itemType == ControllerPreset.ItemType.Text) { EditorGUILayout.LabelField(new GUIContent("[Text] " + heTarget.controllerPreset.items[i].itemText), customSkin.FindStyle("Text")); }
else if (heTarget.controllerPreset.items[i].itemIcon != null) { GUILayout.Box(HeatUIEditorHandler.TextureFromSprite(heTarget.controllerPreset.items[i].itemIcon), GUILayout.Width(32), GUILayout.Height(32)); }
}
}
GUI.enabled = true;
}
}
if (Application.isPlaying == false && GUILayout.Button(new GUIContent("Update Visual UI"), customSkin.button))
{
heTarget.UpdateVisual();
EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
}
}
else
{
EditorGUILayout.HelpBox("Custom: You can manually change the content, but UI will not automatically adapt to the current controller scheme. " +
"Recommended if you don't need to specify the hotkey in UI.", MessageType.Info);
}
GUILayout.EndVertical();
HeatUIEditorHandler.DrawHeader(customSkin, "Customization Header", 10);
EditorGUILayout.PropertyField(hotkey, new GUIContent("Hotkey"), true);
HeatUIEditorHandler.DrawHeader(customSkin, "Events Header", 10);
EditorGUILayout.PropertyField(onHotkeyPress, new GUIContent("On Hotkey Press"), true);
break;
case 1:
HeatUIEditorHandler.DrawHeader(customSkin, "Core Header", 6);
if (heTarget.hotkeyType == HotkeyEvent.HotkeyType.Dynamic)
{
HeatUIEditorHandler.DrawProperty(iconParent, customSkin, "Icon Parent");
HeatUIEditorHandler.DrawProperty(textParent, customSkin, "Text Parent");
HeatUIEditorHandler.DrawProperty(iconObj, customSkin, "Icon Object");
HeatUIEditorHandler.DrawProperty(labelObj, customSkin, "Label Object");
HeatUIEditorHandler.DrawProperty(textObj, customSkin, "Text Object");
HeatUIEditorHandler.DrawProperty(normalCG, customSkin, "Normal CG");
HeatUIEditorHandler.DrawProperty(highlightCG, customSkin, "Highlight CG");
}
else
{
EditorGUILayout.HelpBox("Hotkey Type is set to Custom.", MessageType.Info);
}
break;
case 2:
HeatUIEditorHandler.DrawHeader(customSkin, "Options Header", 6);
useSounds.boolValue = HeatUIEditorHandler.DrawToggle(useSounds.boolValue, customSkin, "Use Sounds");
useLocalization.boolValue = HeatUIEditorHandler.DrawToggle(useLocalization.boolValue, customSkin, "Use Localization", "Bypasses localization functions when disabled.");
HeatUIEditorHandler.DrawProperty(fadingMultiplier, customSkin, "Fading Multiplier", "Set the animation fade multiplier.");
break;
}
serializedObject.ApplyModifiedProperties();
if (Application.isPlaying == false) { Repaint(); }
}
}
}
#endif

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 2cb311946f158964caf1293a25610dbf
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/Events/HotkeyEventEditor.cs
uploadId: 629893

View File

@ -0,0 +1,22 @@
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.EventSystems;
namespace Michsky.UI.Heat
{
public class PointerEvent : MonoBehaviour, IPointerClickHandler, IPointerEnterHandler, IPointerExitHandler
{
[Header("Settings")]
public bool addEventTrigger = true;
[Header("Events")]
[SerializeField] private UnityEvent onClick = new UnityEvent();
[SerializeField] private UnityEvent onEnter = new UnityEvent();
[SerializeField] private UnityEvent onExit = new UnityEvent();
void Awake() { if (addEventTrigger == true) { gameObject.AddComponent<EventTrigger>(); } }
public void OnPointerClick(PointerEventData eventData) { onClick.Invoke(); }
public void OnPointerEnter(PointerEventData eventData) { onEnter.Invoke(); }
public void OnPointerExit(PointerEventData eventData) { onExit.Invoke(); }
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: cc0e0c4cc7eed094c9c7fdbe2e06b5b1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: f4007fbdb43231c4c8a13871706d7c46, 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/Events/PointerEvent.cs
uploadId: 629893

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f8ae835d3c3f66d4087012089d92737b
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,91 @@
using System.Collections;
using UnityEngine;
using UnityEngine.Events;
namespace Michsky.UI.Heat
{
public class HUDManager : MonoBehaviour
{
// Resources
public GameObject HUDPanel;
private CanvasGroup cg;
// Settings
[Range(1, 20)] public float fadeSpeed = 8;
public DefaultBehaviour defaultBehaviour = DefaultBehaviour.Visible;
// Events
public UnityEvent onSetVisible;
public UnityEvent onSetInvisible;
// Helpers
private bool isOn;
public enum DefaultBehaviour { Visible, Invisible }
void Awake()
{
if (HUDPanel == null)
return;
cg = HUDPanel.AddComponent<CanvasGroup>();
if (defaultBehaviour == DefaultBehaviour.Visible) { cg.alpha = 1; isOn = true; onSetVisible.Invoke(); }
else if (defaultBehaviour == DefaultBehaviour.Invisible) { cg.alpha = 0; isOn = false; onSetInvisible.Invoke(); }
}
public void SetVisible()
{
if (isOn == true) { SetVisible(false); }
else { SetVisible(true); }
}
public void SetVisible(bool value)
{
if (HUDPanel == null)
return;
if (value == true)
{
isOn = true;
onSetVisible.Invoke();
StopCoroutine("DoFadeIn");
StopCoroutine("DoFadeOut");
StartCoroutine("DoFadeIn");
}
else
{
isOn = false;
onSetInvisible.Invoke();
StopCoroutine("DoFadeIn");
StopCoroutine("DoFadeOut");
StartCoroutine("DoFadeOut");
}
}
IEnumerator DoFadeIn()
{
while (cg.alpha < 0.99f)
{
cg.alpha += Time.unscaledDeltaTime * fadeSpeed;
yield return null;
}
cg.alpha = 1;
}
IEnumerator DoFadeOut()
{
while (cg.alpha > 0.01f)
{
cg.alpha -= Time.unscaledDeltaTime * fadeSpeed;
yield return null;
}
cg.alpha = 0;
}
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 28a8d350b32d3074a97a4660d9f47d36
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: fd3012dcfab95cb469aa3dd70c6af50b, 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/HUD/HUDManager.cs
uploadId: 629893

View File

@ -0,0 +1,47 @@
#if UNITY_EDITOR
using UnityEngine;
using UnityEditor;
namespace Michsky.UI.Heat
{
[CanEditMultipleObjects]
[CustomEditor(typeof(HUDManager))]
public class HUDManagerEditor : Editor
{
private HUDManager hmTarget;
private GUISkin customSkin;
private void OnEnable()
{
hmTarget = (HUDManager)target;
if (EditorGUIUtility.isProSkin == true) { customSkin = HeatUIEditorHandler.GetDarkEditor(customSkin); }
else { customSkin = HeatUIEditorHandler.GetLightEditor(customSkin); }
}
public override void OnInspectorGUI()
{
var HUDPanel = serializedObject.FindProperty("HUDPanel");
var fadeSpeed = serializedObject.FindProperty("fadeSpeed");
var defaultBehaviour = serializedObject.FindProperty("defaultBehaviour");
var onSetVisible = serializedObject.FindProperty("onSetVisible");
var onSetInvisible = serializedObject.FindProperty("onSetInvisible");
HeatUIEditorHandler.DrawHeader(customSkin, "Core Header", 6);
HeatUIEditorHandler.DrawProperty(HUDPanel, customSkin, "HUD Panel");
HeatUIEditorHandler.DrawHeader(customSkin, "Options Header", 10);
HeatUIEditorHandler.DrawProperty(fadeSpeed, customSkin, "Fade Speed", "Sets the fade animation speed.");
HeatUIEditorHandler.DrawProperty(defaultBehaviour, customSkin, "Default Behaviour");
HeatUIEditorHandler.DrawHeader(customSkin, "Events Header", 10);
EditorGUILayout.PropertyField(onSetVisible, new GUIContent("On Set Visible"), true);
EditorGUILayout.PropertyField(onSetInvisible, new GUIContent("On Set Invisible"), true);
serializedObject.ApplyModifiedProperties();
}
}
}
#endif

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 17d8c14a01f1e9d408f07e4f1902b16b
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/HUD/HUDManagerEditor.cs
uploadId: 629893

View File

@ -0,0 +1,150 @@
using System.Collections;
using UnityEngine;
using UnityEngine.Events;
using TMPro;
namespace Michsky.UI.Heat
{
[RequireComponent(typeof(Animator))]
public class QuestItem : MonoBehaviour
{
// Content
[TextArea] public string questText = "Quest text here";
public string localizationKey;
// Resources
[SerializeField] private Animator questAnimator;
[SerializeField] private TextMeshProUGUI questTextObj;
// Settings
public bool useLocalization = true;
[SerializeField] private bool updateOnAnimate = true;
[Range(0, 10)] public float minimizeAfter = 3;
public DefaultState defaultState = DefaultState.Minimized;
public AfterMinimize afterMinimize = AfterMinimize.Disable;
// Events
public UnityEvent onDestroy;
// Helpers
bool isOn;
LocalizedObject localizedObject;
public enum DefaultState { Minimized, Expanded }
public enum AfterMinimize { Disable, Destroy }
void Start()
{
if (questAnimator == null) { questAnimator = GetComponent<Animator>(); }
if (useLocalization == true)
{
localizedObject = questTextObj.GetComponent<LocalizedObject>();
if (localizedObject == null || localizedObject.CheckLocalizationStatus() == false) { useLocalization = false; }
else if (localizedObject != null && !string.IsNullOrEmpty(localizationKey))
{
// Forcing component to take the localized output on awake
questText = localizedObject.GetKeyOutput(localizationKey);
// Change text on language change
localizedObject.onLanguageChanged.AddListener(delegate
{
questText = localizedObject.GetKeyOutput(localizationKey);
UpdateUI();
});
}
}
if (defaultState == DefaultState.Minimized) { gameObject.SetActive(false); }
else if (defaultState == DefaultState.Expanded) { ExpandQuest(); }
UpdateUI();
}
public void UpdateUI()
{
questTextObj.text = questText;
}
public void AnimateQuest()
{
ExpandQuest();
}
public void ExpandQuest()
{
if (isOn == true)
{
StopCoroutine("DisableAnimator");
StartCoroutine("DisableAnimator");
if (minimizeAfter != 0)
{
StopCoroutine("MinimizeItem");
StartCoroutine("MinimizeItem");
}
return;
}
isOn = true;
gameObject.SetActive(true);
questAnimator.enabled = true;
questAnimator.Play("In");
if (updateOnAnimate == true) { UpdateUI(); }
if (minimizeAfter != 0) { StopCoroutine("MinimizeItem"); StartCoroutine("MinimizeItem"); }
StopCoroutine("DisableAnimator");
StartCoroutine("DisableAnimator");
}
public void MinimizeQuest()
{
if (isOn == false)
return;
StopCoroutine("DisableAnimator");
questAnimator.enabled = true;
questAnimator.Play("Out");
StopCoroutine("DisableItem");
StartCoroutine("DisableItem");
}
public void CompleteQuest()
{
afterMinimize = AfterMinimize.Destroy;
MinimizeQuest();
}
public void DestroyQuest()
{
onDestroy.Invoke();
Destroy(gameObject);
}
IEnumerator DisableAnimator()
{
yield return new WaitForSeconds(HeatUIInternalTools.GetAnimatorClipLength(questAnimator, "QuestItem_In"));
questAnimator.enabled = false;
}
IEnumerator DisableItem()
{
yield return new WaitForSeconds(HeatUIInternalTools.GetAnimatorClipLength(questAnimator, "QuestItem_Out"));
isOn = false;
if (afterMinimize == AfterMinimize.Disable) { gameObject.SetActive(false); }
else if (afterMinimize == AfterMinimize.Destroy) { DestroyQuest(); }
}
IEnumerator MinimizeItem()
{
yield return new WaitForSeconds(minimizeAfter);
MinimizeQuest();
}
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: b785238617c9389419a59f9cc5b41084
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: 36b1e55d1fc76fe4591bacc35a62aba4, 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/HUD/QuestItem.cs
uploadId: 629893

View File

@ -0,0 +1,63 @@
#if UNITY_EDITOR
using UnityEngine;
using UnityEditor;
namespace Michsky.UI.Heat
{
[CanEditMultipleObjects]
[CustomEditor(typeof(QuestItem))]
public class QuestItemEditor : Editor
{
private QuestItem qiTarget;
private GUISkin customSkin;
private void OnEnable()
{
qiTarget = (QuestItem)target;
if (EditorGUIUtility.isProSkin == true) { customSkin = HeatUIEditorHandler.GetDarkEditor(customSkin); }
else { customSkin = HeatUIEditorHandler.GetLightEditor(customSkin); }
}
public override void OnInspectorGUI()
{
var questText = serializedObject.FindProperty("questText");
var localizationKey = serializedObject.FindProperty("localizationKey");
var questAnimator = serializedObject.FindProperty("questAnimator");
var questTextObj = serializedObject.FindProperty("questTextObj");
var useLocalization = serializedObject.FindProperty("useLocalization");
var updateOnAnimate = serializedObject.FindProperty("updateOnAnimate");
var minimizeAfter = serializedObject.FindProperty("minimizeAfter");
var defaultState = serializedObject.FindProperty("defaultState");
var afterMinimize = serializedObject.FindProperty("afterMinimize");
var onDestroy = serializedObject.FindProperty("onDestroy");
HeatUIEditorHandler.DrawHeader(customSkin, "Content Header", 6);
GUILayout.BeginHorizontal(EditorStyles.helpBox);
EditorGUILayout.LabelField(new GUIContent("Quest Text"), customSkin.FindStyle("Text"), GUILayout.Width(-3));
EditorGUILayout.PropertyField(questText, new GUIContent(""), GUILayout.Height(70));
GUILayout.EndHorizontal();
HeatUIEditorHandler.DrawProperty(localizationKey, customSkin, "Localization Key");
HeatUIEditorHandler.DrawHeader(customSkin, "Core Header", 10);
HeatUIEditorHandler.DrawProperty(questAnimator, customSkin, "Quest Animator");
HeatUIEditorHandler.DrawProperty(questTextObj, customSkin, "Quest Text Object");
HeatUIEditorHandler.DrawHeader(customSkin, "Options Header", 10);
useLocalization.boolValue = HeatUIEditorHandler.DrawToggle(useLocalization.boolValue, customSkin, "Use Localization", "Bypasses localization functions when disabled.");
updateOnAnimate.boolValue = HeatUIEditorHandler.DrawToggle(updateOnAnimate.boolValue, customSkin, "Update On Animate");
HeatUIEditorHandler.DrawProperty(minimizeAfter, customSkin, "Minimize After");
HeatUIEditorHandler.DrawProperty(defaultState, customSkin, "Default State");
HeatUIEditorHandler.DrawProperty(afterMinimize, customSkin, "After Minimize");
HeatUIEditorHandler.DrawHeader(customSkin, "Events Header", 10);
EditorGUILayout.PropertyField(onDestroy, new GUIContent("On Destroy"), true);
serializedObject.ApplyModifiedProperties();
}
}
}
#endif

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 38eeabc7df774114aa8fb970f77eb9f9
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/HUD/QuestItemEditor.cs
uploadId: 629893

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 275dfbc520fcf504c9cd52006633f4b6
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,237 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.DualShock;
using UnityEngine.InputSystem.XInput;
namespace Michsky.UI.Heat
{
[DefaultExecutionOrder(-100)]
[DisallowMultipleComponent]
public class ControllerManager : MonoBehaviour
{
// Static Instance
public static ControllerManager instance;
// Resources
public ControllerPresetManager presetManager;
public GameObject firstSelected;
public List<PanelManager> panels = new List<PanelManager>();
public List<ButtonManager> buttons = new List<ButtonManager>();
public List<BoxButtonManager> boxButtons = new List<BoxButtonManager>();
public List<ShopButtonManager> shopButtons = new List<ShopButtonManager>();
public List<SettingsElement> settingsElements = new List<SettingsElement>();
[Tooltip("Objects in this list will be enabled when the gamepad is un-plugged.")]
public List<GameObject> keyboardObjects = new List<GameObject>();
[Tooltip("Objects in this list will be enabled when the gamepad is plugged.")]
public List<GameObject> gamepadObjects = new List<GameObject>();
public List<HotkeyEvent> hotkeyObjects = new List<HotkeyEvent>();
// Settings
[Tooltip("Checks for input changes each frame.")]
public bool alwaysUpdate = true;
public bool affectCursor = true;
public InputAction gamepadHotkey;
// Helpers
Vector3 cursorPos;
Vector3 lastCursorPos;
Navigation customNav = new Navigation();
[HideInInspector] public int currentManagerIndex;
[HideInInspector] public bool gamepadConnected;
[HideInInspector] public bool gamepadEnabled;
[HideInInspector] public bool keyboardEnabled;
[HideInInspector] public float hAxis;
[HideInInspector] public float vAxis;
[HideInInspector] public string currentController;
[HideInInspector] public ControllerPreset currentControllerPreset;
void Awake()
{
instance = this;
}
void Start()
{
InitInput();
}
void Update()
{
if (!alwaysUpdate)
return;
CheckForController();
CheckForEmptyObject();
}
void InitInput()
{
gamepadHotkey.Enable();
if (Gamepad.current == null) { gamepadConnected = false; SwitchToKeyboard(); }
else { gamepadConnected = true; SwitchToGamepad(); }
}
void CheckForEmptyObject()
{
if (!gamepadEnabled) { return; }
else if (EventSystem.current.currentSelectedGameObject != null && EventSystem.current.currentSelectedGameObject.gameObject.activeInHierarchy) { return; }
if (gamepadHotkey.triggered && panels.Count != 0 && panels[currentManagerIndex].panels[panels[currentManagerIndex].currentPanelIndex].firstSelected != null)
{
SelectUIObject(panels[currentManagerIndex].panels[panels[currentManagerIndex].currentPanelIndex].firstSelected);
}
}
public void CheckForController()
{
if (Gamepad.current == null) { gamepadConnected = false; }
else
{
gamepadConnected = true;
hAxis = Gamepad.current.rightStick.x.ReadValue();
vAxis = Gamepad.current.rightStick.y.ReadValue();
}
cursorPos = Mouse.current.position.ReadValue();
if (gamepadConnected && gamepadEnabled && !keyboardEnabled && cursorPos != lastCursorPos) { SwitchToKeyboard(); }
else if (gamepadConnected && !gamepadEnabled && keyboardEnabled && gamepadHotkey.triggered) { SwitchToGamepad(); }
else if (!gamepadConnected && !keyboardEnabled) { SwitchToKeyboard(); }
}
void CheckForCurrentObject()
{
if ((EventSystem.current.currentSelectedGameObject == null || !EventSystem.current.currentSelectedGameObject.activeInHierarchy) && panels.Count != 0)
{
SelectUIObject(panels[currentManagerIndex].panels[panels[currentManagerIndex].currentPanelIndex].firstSelected);
}
}
public void SwitchToGamepad()
{
if (affectCursor) { Cursor.visible = false; }
for (int i = 0; i < keyboardObjects.Count; i++)
{
if (keyboardObjects[i] == null)
continue;
keyboardObjects[i].SetActive(false);
}
for (int i = 0; i < gamepadObjects.Count; i++)
{
if (gamepadObjects[i] == null)
continue;
gamepadObjects[i].SetActive(true);
LayoutRebuilder.ForceRebuildLayoutImmediate(gamepadObjects[i].GetComponentInParent<RectTransform>());
}
customNav.mode = Navigation.Mode.Automatic;
for (int i = 0; i < buttons.Count; i++) { if (buttons[i] != null && !buttons[i].useUINavigation) { buttons[i].AddUINavigation(); } }
for (int i = 0; i < boxButtons.Count; i++) { if (boxButtons[i] != null && !boxButtons[i].useUINavigation) { boxButtons[i].AddUINavigation(); } }
for (int i = 0; i < shopButtons.Count; i++) { if (shopButtons[i] != null && !shopButtons[i].useUINavigation) { shopButtons[i].AddUINavigation(); } }
for (int i = 0; i < settingsElements.Count; i++) { if (settingsElements[i] != null && !settingsElements[i].useUINavigation) { settingsElements[i].AddUINavigation(); } }
gamepadEnabled = true;
keyboardEnabled = false;
lastCursorPos = Mouse.current.position.ReadValue();
CheckForGamepadType();
CheckForCurrentObject();
}
void CheckForGamepadType()
{
currentController = Gamepad.current.displayName;
// Search for main and custom gameapds
if (Gamepad.current is XInputController && presetManager != null && presetManager.xboxPreset != null) { currentControllerPreset = presetManager.xboxPreset; }
#if !UNITY_WEBGL && !UNITY_IOS && !UNITY_ANDROID && !UNITY_STANDALONE_LINUX
else if (Gamepad.current is DualSenseGamepadHID && presetManager != null && presetManager.dualsensePreset != null) { currentControllerPreset = presetManager.dualsensePreset; }
#endif
else
{
for (int i = 0; i < presetManager.customPresets.Count; i++)
{
if (currentController == presetManager.customPresets[i].controllerName)
{
currentControllerPreset = presetManager.customPresets[i];
break;
}
}
}
foreach (HotkeyEvent he in hotkeyObjects)
{
if (he == null)
continue;
he.controllerPreset = currentControllerPreset;
he.UpdateUI();
}
}
public void SwitchToKeyboard()
{
if (affectCursor) { Cursor.visible = true; }
if (presetManager != null && presetManager.keyboardPreset != null)
{
currentControllerPreset = presetManager.keyboardPreset;
foreach (HotkeyEvent he in hotkeyObjects)
{
if (he == null)
continue;
he.controllerPreset = currentControllerPreset;
he.UpdateUI();
}
}
for (int i = 0; i < gamepadObjects.Count; i++)
{
if (gamepadObjects[i] == null)
continue;
gamepadObjects[i].SetActive(false);
}
for (int i = 0; i < keyboardObjects.Count; i++)
{
if (keyboardObjects[i] == null)
continue;
keyboardObjects[i].SetActive(true);
LayoutRebuilder.ForceRebuildLayoutImmediate(keyboardObjects[i].GetComponentInParent<RectTransform>());
}
customNav.mode = Navigation.Mode.None;
for (int i = 0; i < buttons.Count; i++) { if (buttons[i] != null && !buttons[i].useUINavigation) { buttons[i].DisableUINavigation(); } }
for (int i = 0; i < boxButtons.Count; i++) { if (boxButtons[i] != null && !boxButtons[i].useUINavigation) { boxButtons[i].DisableUINavigation(); } }
for (int i = 0; i < shopButtons.Count; i++) { if (shopButtons[i] != null && !shopButtons[i].useUINavigation) { shopButtons[i].DisableUINavigation(); } }
for (int i = 0; i < settingsElements.Count; i++) { if (settingsElements[i] != null && !settingsElements[i].useUINavigation) { settingsElements[i].DisableUINavigation(); } }
gamepadEnabled = false;
keyboardEnabled = true;
}
public void SelectUIObject(GameObject tempObj)
{
if (!gamepadEnabled)
return;
EventSystem.current.SetSelectedGameObject(tempObj.gameObject);
}
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 38730517d0a0b2f4f9935f5b526ee7d6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: 70b6ed493cdde1b4a911df2d89e1694f, 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/Input/ControllerManager.cs
uploadId: 629893

View File

@ -0,0 +1,59 @@
#if UNITY_EDITOR
using UnityEngine;
using UnityEditor;
using UnityEngine.UIElements;
namespace Michsky.UI.Heat
{
[CanEditMultipleObjects]
[CustomEditor(typeof(ControllerManager))]
public class ControllerManagerEditor : Editor
{
private ControllerManager cmTarget;
private GUISkin customSkin;
private void OnEnable()
{
cmTarget = (ControllerManager)target;
if (EditorGUIUtility.isProSkin == true) { customSkin = HeatUIEditorHandler.GetDarkEditor(customSkin); }
else { customSkin = HeatUIEditorHandler.GetLightEditor(customSkin); }
}
public override void OnInspectorGUI()
{
var presetManager = serializedObject.FindProperty("presetManager");
var firstSelected = serializedObject.FindProperty("firstSelected");
var gamepadObjects = serializedObject.FindProperty("gamepadObjects");
var keyboardObjects = serializedObject.FindProperty("keyboardObjects");
var alwaysUpdate = serializedObject.FindProperty("alwaysUpdate");
var affectCursor = serializedObject.FindProperty("affectCursor");
var gamepadHotkey = serializedObject.FindProperty("gamepadHotkey");
HeatUIEditorHandler.DrawHeader(customSkin, "Core Header", 6);
HeatUIEditorHandler.DrawProperty(presetManager, customSkin, "Preset Manager");
HeatUIEditorHandler.DrawProperty(firstSelected, customSkin, "First Selected", "UI element to be selected first in the home panel (e.g. Play button).");
GUILayout.BeginVertical();
EditorGUI.indentLevel = 1;
EditorGUILayout.PropertyField(gamepadObjects, new GUIContent("Gamepad Objects"), true);
EditorGUI.indentLevel = 0;
GUILayout.EndVertical();
GUILayout.BeginVertical();
EditorGUI.indentLevel = 1;
EditorGUILayout.PropertyField(keyboardObjects, new GUIContent("Keyboard Objects"), true);
EditorGUI.indentLevel = 0;
GUILayout.EndVertical();
HeatUIEditorHandler.DrawHeader(customSkin, "Options Header", 10);
alwaysUpdate.boolValue = HeatUIEditorHandler.DrawToggle(alwaysUpdate.boolValue, customSkin, "Always Update");
affectCursor.boolValue = HeatUIEditorHandler.DrawToggle(affectCursor.boolValue, customSkin, "Affect Cursor", "Changes the cursor state depending on the controller state.");
EditorGUILayout.PropertyField(gamepadHotkey, new GUIContent("Gamepad Hotkey", "Triggers to switch to gamepad when pressed."), true);
serializedObject.ApplyModifiedProperties();
}
}
}
#endif

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: bd49ec269b8d3fa44a95b6a6ca3a603b
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/Input/ControllerManagerEditor.cs
uploadId: 629893

View File

@ -0,0 +1,26 @@
using System.Collections.Generic;
using UnityEngine;
namespace Michsky.UI.Heat
{
[CreateAssetMenu(fileName = "New Controller Preset", menuName = "Heat UI/Controller/New Controller Preset")]
public class ControllerPreset : ScriptableObject
{
[Header("Settings")]
public string controllerName = "Controller Name";
[Space(10)]
public List<ControllerItem> items = new List<ControllerItem>();
public enum ItemType { Icon, Text }
[System.Serializable]
public class ControllerItem
{
public string itemID;
public ItemType itemType;
public Sprite itemIcon;
public string itemText;
}
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 42ee925c372713347a6a28631564a3f0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: 70b6ed493cdde1b4a911df2d89e1694f, 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/Input/ControllerPreset.cs
uploadId: 629893

View File

@ -0,0 +1,14 @@
using System.Collections.Generic;
using UnityEngine;
namespace Michsky.UI.Heat
{
[CreateAssetMenu(fileName = "New Controller Preset Manager", menuName = "Heat UI/Controller/New Controller Preset Manager")]
public class ControllerPresetManager : ScriptableObject
{
public ControllerPreset keyboardPreset;
public ControllerPreset xboxPreset;
public ControllerPreset dualsensePreset;
public List<ControllerPreset> customPresets = new List<ControllerPreset>();
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: d0363e7a7841d294a97aee9fd222febe
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: 70b6ed493cdde1b4a911df2d89e1694f, 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/Input/ControllerPresetManager.cs
uploadId: 629893

View File

@ -0,0 +1,65 @@
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.InputSystem;
namespace Michsky.UI.Heat
{
[RequireComponent(typeof(Scrollbar))]
public class ScrollbarInputHandler : MonoBehaviour
{
[Header("Resources")]
[SerializeField] private Scrollbar scrollbarObject;
[SerializeField] private GameObject indicator;
[Header("Settings")]
[SerializeField] private ScrollbarDirection direction = ScrollbarDirection.Vertical;
[Range(0.1f, 50)] public float scrollSpeed = 3;
[SerializeField] [Range(0.01f, 1)] private float deadzone = 0.1f;
[SerializeField] private bool optimizeUpdates = true;
public bool allowInputs = true;
[SerializeField] private bool reversePosition;
// Helpers
float divideValue = 1000;
public enum ScrollbarDirection { Horizontal, Vertical }
void OnEnable()
{
if (scrollbarObject == null) { scrollbarObject = gameObject.GetComponent<Scrollbar>(); }
if (ControllerManager.instance == null) { Destroy(this); }
if (indicator == null)
{
indicator = new GameObject();
indicator.name = "[Generated Indicator]";
indicator.transform.SetParent(transform);
}
indicator.SetActive(false);
}
void Update()
{
if (Gamepad.current == null || ControllerManager.instance == null || !allowInputs) { indicator.SetActive(false); return; }
else if (optimizeUpdates && ControllerManager.instance != null && !ControllerManager.instance.gamepadEnabled) { indicator.SetActive(false); return; }
indicator.SetActive(true);
if (direction == ScrollbarDirection.Vertical)
{
if (reversePosition && ControllerManager.instance.vAxis >= 0.1f) { scrollbarObject.value -= (scrollSpeed / divideValue) * ControllerManager.instance.vAxis; }
else if (!reversePosition && ControllerManager.instance.vAxis >= 0.1f) { scrollbarObject.value += (scrollSpeed / divideValue) * ControllerManager.instance.vAxis; }
else if (reversePosition && ControllerManager.instance.vAxis <= -0.1f) { scrollbarObject.value += (scrollSpeed / divideValue) * Mathf.Abs(ControllerManager.instance.vAxis); }
else if (!reversePosition && ControllerManager.instance.vAxis <= -0.1f) { scrollbarObject.value -= (scrollSpeed / divideValue) * Mathf.Abs(ControllerManager.instance.vAxis); }
}
else if (direction == ScrollbarDirection.Horizontal)
{
if (reversePosition && ControllerManager.instance.hAxis >= deadzone) { scrollbarObject.value -= (scrollSpeed / divideValue) * ControllerManager.instance.hAxis; }
else if (!reversePosition && ControllerManager.instance.hAxis >= deadzone) { scrollbarObject.value += (scrollSpeed / divideValue) * ControllerManager.instance.hAxis; }
else if (reversePosition && ControllerManager.instance.hAxis <= -deadzone) { scrollbarObject.value += (scrollSpeed / divideValue) * Mathf.Abs(ControllerManager.instance.hAxis); }
else if (!reversePosition && ControllerManager.instance.hAxis <= -deadzone) { scrollbarObject.value -= (scrollSpeed / divideValue) * Mathf.Abs(ControllerManager.instance.hAxis); }
}
}
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 73a37c87ce93433428156c9813812c30
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: f4007fbdb43231c4c8a13871706d7c46, 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/Input/ScrollbarInputHandler.cs
uploadId: 629893

View File

@ -0,0 +1,69 @@
using System.Collections;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.InputSystem;
namespace Michsky.UI.Heat
{
public class SelectorInputHandler : MonoBehaviour
{
[Header("Resources")]
[SerializeField] private HorizontalSelector selectorObject;
[SerializeField] private GameObject indicator;
[Header("Settings")]
public float selectorCooldown = 0.4f;
[SerializeField] private bool optimizeUpdates = true;
public bool requireSelecting = true;
// Helpers
bool isInCooldown = false;
void OnEnable()
{
if (ControllerManager.instance == null || selectorObject == null) { Destroy(this); }
if (indicator == null)
{
indicator = new GameObject();
indicator.name = "[Generated Indicator]";
indicator.transform.SetParent(transform);
}
indicator.SetActive(false);
}
void Update()
{
if (Gamepad.current == null || ControllerManager.instance == null) { indicator.SetActive(false); return; }
else if (requireSelecting && EventSystem.current.currentSelectedGameObject != gameObject) { indicator.SetActive(false); return; }
else if (optimizeUpdates && ControllerManager.instance != null && !ControllerManager.instance.gamepadEnabled) { indicator.SetActive(false); return; }
else if (isInCooldown) { return; }
indicator.SetActive(true);
if (ControllerManager.instance.hAxis >= 0.75)
{
selectorObject.NextItem();
isInCooldown = true;
StopCoroutine("CooldownTimer");
StartCoroutine("CooldownTimer");
}
else if (ControllerManager.instance.hAxis <= -0.75)
{
selectorObject.PreviousItem();
isInCooldown = true;
StopCoroutine("CooldownTimer");
StartCoroutine("CooldownTimer");
}
}
IEnumerator CooldownTimer()
{
yield return new WaitForSecondsRealtime(selectorCooldown);
isInCooldown = false;
}
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: d4b1a0f691a9bf843b60feec050fd352
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: f4007fbdb43231c4c8a13871706d7c46, 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/Input/SelectorInputHandler.cs
uploadId: 629893

View File

@ -0,0 +1,57 @@
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
using UnityEngine.InputSystem;
namespace Michsky.UI.Heat
{
public class SliderInputHandler : MonoBehaviour
{
[Header("Resources")]
[SerializeField] private Slider sliderObject;
[SerializeField] private GameObject indicator;
[Header("Settings")]
[Range(0.1f, 50)] public float valueMultiplier = 1;
[SerializeField] [Range(0.01f, 1)] private float deadzone = 0.1f;
[SerializeField] private bool optimizeUpdates = true;
public bool requireSelecting = true;
[SerializeField] private bool reversePosition;
[SerializeField] private bool divideByMaxValue;
// Helpers
float divideValue = 1000;
void OnEnable()
{
if (ControllerManager.instance == null || sliderObject == null) { Destroy(this); }
if (indicator == null)
{
indicator = new GameObject();
indicator.name = "[Generated Indicator]";
indicator.transform.SetParent(transform);
}
indicator.SetActive(false);
if (divideByMaxValue)
{
divideValue = sliderObject.maxValue;
}
}
void Update()
{
if (Gamepad.current == null || ControllerManager.instance == null) { indicator.SetActive(false); return; }
else if (requireSelecting && EventSystem.current.currentSelectedGameObject != gameObject) { indicator.SetActive(false); return; }
else if (optimizeUpdates && ControllerManager.instance != null && !ControllerManager.instance.gamepadEnabled) { indicator.SetActive(false); return; }
indicator.SetActive(true);
if (reversePosition && ControllerManager.instance.hAxis >= deadzone) { sliderObject.value -= (valueMultiplier / divideValue) * ControllerManager.instance.hAxis; }
else if (!reversePosition && ControllerManager.instance.hAxis >= deadzone) { sliderObject.value += (valueMultiplier / divideValue) * ControllerManager.instance.hAxis; }
else if (reversePosition && ControllerManager.instance.hAxis <= -deadzone) { sliderObject.value += (valueMultiplier / divideValue) * Mathf.Abs(ControllerManager.instance.hAxis); }
else if (!reversePosition && ControllerManager.instance.hAxis <= -deadzone) { sliderObject.value -= (valueMultiplier / divideValue) * Mathf.Abs(ControllerManager.instance.hAxis); }
}
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: eb371ec4e1984f640867ff04efd1612e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: f4007fbdb43231c4c8a13871706d7c46, 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/Input/SliderInputHandler.cs
uploadId: 629893

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: a571bb2dff0e7af488e1b3cb7c3afdde
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,31 @@
using System.Collections.Generic;
using UnityEngine;
namespace Michsky.UI.Heat
{
[CreateAssetMenu(fileName = "New Localization Table", menuName = "Heat UI/Localization/New Language")]
public class LocalizationLanguage : ScriptableObject
{
public LocalizationSettings localizationSettings;
public string languageID;
public string languageName;
public string localizedName;
public List<TableList> tableList = new List<TableList>();
[System.Serializable]
public class TableList
{
public LocalizationTable table;
public List<TableContent> tableContent = new List<TableContent>();
}
[System.Serializable]
public class TableContent
{
public string key;
[TextArea] public string value;
public AudioClip audioValue;
public Sprite spriteValue;
}
}
}

View File

@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: b70abea511859e248a1cf2c44035e321
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences:
- localizationSettings: {instanceID: 0}
executionOrder: 0
icon: {fileID: 2800000, guid: d5cd25c6d1180024295fa5919baf502a, 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/Localization/LocalizationLanguage.cs
uploadId: 629893

View File

@ -0,0 +1,233 @@
#if UNITY_EDITOR
using UnityEngine;
using UnityEditor;
using System.IO;
using System.Collections.Generic;
namespace Michsky.UI.Heat
{
[CustomEditor(typeof(LocalizationLanguage))]
[System.Serializable]
public class LocalizationLanguageEditor : Editor
{
private LocalizationLanguage lTarget;
private GUISkin customSkin;
private LocalizationLanguage.TableList tempTable;
private void OnEnable()
{
lTarget = (LocalizationLanguage)target;
if (EditorGUIUtility.isProSkin == true) { customSkin = HeatUIEditorHandler.GetDarkEditor(customSkin); }
else { customSkin = HeatUIEditorHandler.GetLightEditor(customSkin); }
}
public override void OnInspectorGUI()
{
if (customSkin == null)
{
EditorGUILayout.HelpBox("Editor variables are missing. You can manually fix this by deleting " +
"Heat UI > Resources folder and then re-import the package. \n\nIf you're still seeing this " +
"dialog even after the re-import, contact me with this ID: " + UIManager.buildID, MessageType.Error);
return;
}
// Info Header
HeatUIEditorHandler.DrawHeader(customSkin, "Content Header", 8);
var localizationSettings = serializedObject.FindProperty("localizationSettings");
var languageID = serializedObject.FindProperty("languageID");
var languageName = serializedObject.FindProperty("languageName");
var localizedName = serializedObject.FindProperty("localizedName");
var tableList = serializedObject.FindProperty("tableList");
GUI.enabled = false;
HeatUIEditorHandler.DrawProperty(languageID, customSkin, "Language ID");
HeatUIEditorHandler.DrawProperty(languageName, customSkin, "Language Name");
HeatUIEditorHandler.DrawProperty(localizedName, customSkin, "Localized Name");
GUI.enabled = true;
// Settings Header
HeatUIEditorHandler.DrawHeader(customSkin, "Options Header", 14);
HeatUIEditorHandler.DrawPropertyCW(localizationSettings, customSkin, "Localization Settings", 130);
if (localizationSettings != null && GUILayout.Button("Show Localization Settings", customSkin.button))
{
Selection.activeObject = localizationSettings.objectReferenceValue;
}
// Content Header
HeatUIEditorHandler.DrawHeader(customSkin, "Tables Header", 14);
GUILayout.BeginHorizontal();
if (GUILayout.Button("Import Table", customSkin.button)) { Import(); return; }
if (GUILayout.Button("Export Table(s)", customSkin.button)) { Export(); return; }
GUILayout.EndHorizontal();
GUI.enabled = false;
EditorGUILayout.PropertyField(tableList, new GUIContent("Table List (Debug Only)"), true);
serializedObject.ApplyModifiedProperties();
}
void Import()
{
string path = EditorUtility.OpenFilePanel("Select a file to import", "", "");
if (path.Length != 0)
{
string tempKey = null;
bool checkForValue = false;
bool processNewEntry = false;
LocalizationTable targetTable = null;
List<LocalizationLanguage.TableContent> keysToBeAdded = new List<LocalizationLanguage.TableContent>();
foreach (string option in File.ReadLines(path))
{
if (option.Contains("[LanguageID] "))
{
string tempLangID = option.Replace("[LanguageID] ", "");
checkForValue = false;
if (tempLangID != lTarget.languageID)
{
Debug.LogError("The language ID does not match with the language asset.");
break;
}
}
if (option.Contains("[TableID] "))
{
string tempTableID = option.Replace("[TableID] ", "");
checkForValue = false;
for (int i = 0; i < lTarget.tableList.Count; i++)
{
if (lTarget.tableList[i].table.tableID == tempTableID)
{
targetTable = lTarget.tableList[i].table;
tempTable = lTarget.tableList[i];
break;
}
}
}
else if (option.Contains("[StringKey] "))
{
tempKey = option.Replace("[StringKey] ", "");
checkForValue = false;
processNewEntry = false;
}
else if (option.Contains("[Value] "))
{
if (tempTable == null)
{
Debug.LogError("Can't find the given table ID.");
break;
}
processNewEntry = true;
for (int i = 0; i < tempTable.tableContent.Count; i++)
{
if (tempTable.tableContent[i].key == tempKey)
{
processNewEntry = false;
string tempValue = option.Replace("[Value] ", "");
tempTable.tableContent[i].value = tempValue;
continue;
}
}
if (processNewEntry)
{
LocalizationLanguage.TableContent tempEntry = new LocalizationLanguage.TableContent();
tempEntry.key = tempKey;
tempEntry.value = option.Replace("[Value] ", "");
keysToBeAdded.Add(tempEntry);
}
checkForValue = true;
}
else if (checkForValue == true && !option.Contains("[Value] ") && !string.IsNullOrEmpty(option))
{
if (tempTable == null)
{
Debug.LogError("Can't find the given table ID.");
break;
}
if (processNewEntry) { keysToBeAdded[keysToBeAdded.Count - 1].value = keysToBeAdded[keysToBeAdded.Count - 1].value + "\n" + option; }
else
{
for (int i = 0; i < tempTable.tableContent.Count; i++)
{
if (tempTable.tableContent[i].key == tempKey)
{
tempTable.tableContent[i].value = tempTable.tableContent[i].value + "\n" + option;
break;
}
}
}
}
}
if (!string.IsNullOrEmpty(tempKey) && tempTable != null)
{
for (int i = 0; i < keysToBeAdded.Count; i++)
{
LocalizationTable.TableContent newTableEntry = new LocalizationTable.TableContent();
newTableEntry.key = keysToBeAdded[i].key;
targetTable.tableContent.Add(newTableEntry);
for (int x = 0; x < lTarget.localizationSettings.languages.Count; x++)
{
foreach (LocalizationLanguage.TableList list in lTarget.localizationSettings.languages[x].localizationLanguage.tableList)
{
if (list.table.tableID == tempTable.table.tableID)
{
list.tableContent.Add(keysToBeAdded[i]);
break;
}
}
EditorUtility.SetDirty(lTarget.localizationSettings.languages[x].localizationLanguage);
}
}
Debug.Log(keysToBeAdded.Count.ToString() + " new localization entries has been added.");
Debug.Log(tempTable.table.tableID + " (table) has been successfully imported to " + lTarget.languageID);
EditorUtility.SetDirty(lTarget);
}
}
}
void Export()
{
for (int i = 0; i < lTarget.tableList.Count; i++)
{
string path = EditorUtility.SaveFilePanel("Export: " + lTarget.tableList[i].table.tableID, "", "Exported_" + lTarget.tableList[i].table.tableID + "(" + lTarget.languageID + ")", "txt");
if (path.Length != 0)
{
TextWriter tw = new StreamWriter(path, false);
tw.WriteLine("[LanguageID] " + lTarget.languageID);
tw.WriteLine("[TableID] " + lTarget.tableList[i].table.tableID);
tw.WriteLine("\n------------------------------");
for (int x = 0; x < lTarget.tableList[i].table.tableContent.Count; x++)
{
tw.WriteLine("\n[StringKey] " + lTarget.tableList[i].table.tableContent[x].key);
tw.Write("[Value] " + lTarget.tableList[i].tableContent[x].value + "\n");
}
tw.Close();
Debug.Log(lTarget.tableList[i].table.tableID + " has been exported to: " + path);
}
}
}
}
}
#endif

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 6dedc906d85868e44b8f315819172167
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/Localization/LocalizationLanguageEditor.cs
uploadId: 629893

View File

@ -0,0 +1,115 @@
using System.Collections.Generic;
using UnityEngine;
namespace Michsky.UI.Heat
{
[DefaultExecutionOrder(-100)]
[DisallowMultipleComponent]
public class LocalizationManager : MonoBehaviour
{
// Static Instance
public static LocalizationManager instance;
// Resources
public UIManager UIManagerAsset;
public HorizontalSelector languageSelector;
// Settings
public bool setLanguageOnAwake = true;
public bool updateItemsOnSet = true;
public bool saveLanguageChanges = true;
public static bool enableLogs = true;
// Helpers
public string currentLanguage;
public LocalizationLanguage currentLanguageAsset;
public List<LocalizedObject> localizedItems = new List<LocalizedObject>();
void Awake()
{
instance = this;
if (UIManagerAsset == null) { UIManagerAsset = (UIManager)Resources.FindObjectsOfTypeAll(typeof(UIManager))[0]; }
if (UIManagerAsset == null || !UIManagerAsset.enableLocalization) { return; }
if (setLanguageOnAwake) { InitializeLanguage(); }
// Populate language selector
if (languageSelector != null)
{
languageSelector.items.Clear();
for (int i = 0; i < UIManagerAsset.localizationSettings.languages.Count; i++)
{
languageSelector.CreateNewItem(UIManagerAsset.localizationSettings.languages[i].localizedName);
string tempID = UIManagerAsset.localizationSettings.languages[i].languageID;
languageSelector.items[i].onItemSelect.AddListener(() => SetLanguage(tempID));
if (UIManagerAsset.localizationSettings.languages[i].localizationLanguage == currentLanguageAsset)
{
languageSelector.index = i;
languageSelector.defaultIndex = i;
}
}
languageSelector.UpdateUI();
}
}
public void InitializeLanguage()
{
if (PlayerPrefs.HasKey(UIManager.localizationSaveKey)) { currentLanguage = PlayerPrefs.GetString(UIManager.localizationSaveKey); }
else { currentLanguage = UIManagerAsset.localizationSettings.defaultLanguageID; }
SetLanguage(currentLanguage);
}
public void SetLanguageByIndex(int index)
{
SetLanguage(UIManagerAsset.localizationSettings.languages[index].languageID);
}
public void SetLanguage(string langID)
{
if (UIManagerAsset == null || !UIManagerAsset.enableLocalization)
{
UIManager.isLocalizationEnabled = false;
return;
}
currentLanguageAsset = null;
for (int i = 0; i < UIManagerAsset.localizationSettings.languages.Count; i++)
{
if (UIManagerAsset.localizationSettings.languages[i].languageID == langID) { currentLanguageAsset = UIManagerAsset.localizationSettings.languages[i].localizationLanguage; break; }
else if (UIManagerAsset.localizationSettings.languages[i].languageName + " (" + UIManagerAsset.localizationSettings.languages[i].languageID + ")" == langID) { currentLanguageAsset = UIManagerAsset.localizationSettings.languages[i].localizationLanguage; break; }
else if (UIManagerAsset.localizationSettings.languages[i].languageName == langID + ")") { currentLanguageAsset = UIManagerAsset.localizationSettings.languages[i].localizationLanguage; break; }
}
if (currentLanguageAsset == null) { Debug.Log("<b>[Localization Manager]</b> No language named <b>" + langID + "</b> found.", this); return; }
else { currentLanguage = currentLanguageAsset.languageName + " (" + currentLanguageAsset.languageID + ")"; }
if (updateItemsOnSet)
{
for (int i = 0; i < localizedItems.Count; i++)
{
if (localizedItems[i] == null) { localizedItems.RemoveAt(i); }
else if (localizedItems[i].gameObject.activeInHierarchy && localizedItems[i].updateMode != LocalizedObject.UpdateMode.OnDemand) { localizedItems[i].UpdateItem(); }
}
}
if (saveLanguageChanges)
{
PlayerPrefs.SetString(UIManager.localizationSaveKey, currentLanguageAsset.languageID);
}
UIManagerAsset.currentLanguage = currentLanguageAsset;
UIManager.isLocalizationEnabled = true;
}
public static void SetLanguageWithoutNotify(string langID)
{
PlayerPrefs.SetString(UIManager.localizationSaveKey, langID);
}
}
}

View File

@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 8709296e96cff814f90f27b8b791504c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences:
- UIManagerAsset: {fileID: 11400000, guid: 98972d851a944df4a9402eac62a896e7, type: 2}
executionOrder: 0
icon: {fileID: 2800000, guid: b9f229d37449a7e4a9d5466e48f8a6e2, 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/Localization/LocalizationManager.cs
uploadId: 629893

View File

@ -0,0 +1,46 @@
#if UNITY_EDITOR
using UnityEngine;
using UnityEditor;
namespace Michsky.UI.Heat
{
[CanEditMultipleObjects]
[CustomEditor(typeof(LocalizationManager))]
public class LocalizationManagerEditor : Editor
{
private LocalizationManager lmTarget;
private GUISkin customSkin;
private void OnEnable()
{
lmTarget = (LocalizationManager)target;
if (EditorGUIUtility.isProSkin == true) { customSkin = HeatUIEditorHandler.GetDarkEditor(customSkin); }
else { customSkin = HeatUIEditorHandler.GetLightEditor(customSkin); }
}
public override void OnInspectorGUI()
{
var UIManagerAsset = serializedObject.FindProperty("UIManagerAsset");
var languageSelector = serializedObject.FindProperty("languageSelector");
var setLanguageOnAwake = serializedObject.FindProperty("setLanguageOnAwake");
var updateItemsOnSet = serializedObject.FindProperty("updateItemsOnSet");
var saveLanguageChanges = serializedObject.FindProperty("saveLanguageChanges");
HeatUIEditorHandler.DrawHeader(customSkin, "Core Header", 6);
HeatUIEditorHandler.DrawProperty(UIManagerAsset, customSkin, "UI Manager");
HeatUIEditorHandler.DrawProperty(languageSelector, customSkin, "Language Selector");
HeatUIEditorHandler.DrawHeader(customSkin, "Options Header", 10);
setLanguageOnAwake.boolValue = HeatUIEditorHandler.DrawToggle(setLanguageOnAwake.boolValue, customSkin, "Set Language On Awake");
updateItemsOnSet.boolValue = HeatUIEditorHandler.DrawToggle(updateItemsOnSet.boolValue, customSkin, "Update Items On Language Set");
saveLanguageChanges.boolValue = HeatUIEditorHandler.DrawToggle(saveLanguageChanges.boolValue, customSkin, "Save Language Changes");
LocalizationManager.enableLogs = HeatUIEditorHandler.DrawToggle(LocalizationManager.enableLogs, customSkin, "Enable Logs");
serializedObject.ApplyModifiedProperties();
if (Application.isPlaying == false) { Repaint(); }
}
}
}
#endif

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 88ca311fe1d389c47b9d31f121dd9e12
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/Localization/LocalizationManagerEditor.cs
uploadId: 629893

View File

@ -0,0 +1,40 @@
using System.Collections.Generic;
using UnityEngine;
namespace Michsky.UI.Heat
{
[CreateAssetMenu(fileName = "New Localization Settings", menuName = "Heat UI/Localization/New Localization Settings")]
public class LocalizationSettings : ScriptableObject
{
public List<Language> languages = new List<Language>();
public List<Table> tables = new List<Table>();
public string defaultLanguageID;
public int defaultLanguageIndex;
public bool enableExperimental = false;
// Global Variables
public static string notInitializedText = "NOT_INITIALIZED";
[System.Serializable]
public class Language
{
public string languageID = "en-US";
public string languageName = "English";
public string localizedName = "English (US)";
public LocalizationLanguage localizationLanguage;
#if UNITY_EDITOR
[HideInInspector] public bool isExpanded;
#endif
}
[System.Serializable]
public class Table
{
public string tableID;
public LocalizationTable localizationTable;
#if UNITY_EDITOR
[HideInInspector] public bool isExpanded;
#endif
}
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 6c100adba1f0bea4bb29ed7154d77640
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: b9f229d37449a7e4a9d5466e48f8a6e2, 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/Localization/LocalizationSettings.cs
uploadId: 629893

View File

@ -0,0 +1,400 @@
#if UNITY_EDITOR
using System.IO;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
namespace Michsky.UI.Heat
{
[CustomEditor(typeof(LocalizationSettings))]
[System.Serializable]
public class LocalizationSettingsEditor : Editor
{
private GUISkin customSkin;
private LocalizationSettings lsTarget;
private int defaultLanguageIndex;
private List<string> languageList = new List<string>();
protected static float foldoutItemSpace = 2;
protected static float foldoutTopSpace = 5;
protected static float foldoutBottomSpace = 2;
private void OnEnable()
{
lsTarget = (LocalizationSettings)target;
if (EditorGUIUtility.isProSkin == true) { customSkin = HeatUIEditorHandler.GetDarkEditor(customSkin); }
else { customSkin = HeatUIEditorHandler.GetLightEditor(customSkin); }
// Sort by language name
lsTarget.languages.Sort(SortByName);
// Refresh language dropdown
RefreshLanguageDropdown();
}
public override void OnInspectorGUI()
{
if (customSkin == null)
{
EditorGUILayout.HelpBox("Editor variables are missing. You can manually fix this by deleting " +
"Reach UI > Resources folder and then re-import the package. \n\nIf you're still seeing this " +
"dialog even after the re-import, contact me with this ID: " + UIManager.buildID, MessageType.Error);
return;
}
// Foldout style
GUIStyle foldoutStyle = customSkin.FindStyle("UIM Foldout");
// Settings Header
HeatUIEditorHandler.DrawHeader(customSkin, "Options Header", 8);
GUILayout.BeginVertical(EditorStyles.helpBox);
EditorGUILayout.LabelField(new GUIContent("Default Language"), customSkin.FindStyle("Text"), GUILayout.Width(120));
if (languageList.Count != 0)
{
var defaultLanguageIndex = serializedObject.FindProperty("defaultLanguageIndex");
var defaultLanguageID = serializedObject.FindProperty("defaultLanguageID");
defaultLanguageIndex.intValue = EditorGUILayout.Popup(defaultLanguageIndex.intValue, languageList.ToArray());
defaultLanguageID.stringValue = languageList[defaultLanguageIndex.intValue];
}
else { EditorGUILayout.HelpBox("There are no available languages.", MessageType.Info); }
if (GUILayout.Button("Refresh List", customSkin.button)) { RefreshLanguageDropdown(); }
GUILayout.Space(1);
GUILayout.EndVertical();
#region Available Languages
// Available Languages Header
HeatUIEditorHandler.DrawHeader(customSkin, "Languages Header", 14);
GUILayout.Space(-3);
// Draw languages
for (int i = 0; i < lsTarget.languages.Count; i++)
{
// Draw Action Buttons
GUILayout.Space(6);
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
if (GUILayout.Button("Delete", customSkin.button, GUILayout.Width(50)))
{
if (EditorUtility.DisplayDialog("Delete Language", "Are you sure you want to delete the following language: " + lsTarget.languages[i].languageName + " (" + lsTarget.languages[i].languageID + ")"
+ "\n\nThis action deletes the specified language resources and cannot be undone.", "Yes", "Cancel"))
{
if (lsTarget.languages[i].localizationLanguage != null) { AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(lsTarget.languages[i].localizationLanguage)); }
lsTarget.languages.Remove(lsTarget.languages[i]);
RefreshLanguageDropdown();
EditorUtility.SetDirty(lsTarget);
return;
}
}
GUILayout.Space(5);
GUILayout.EndHorizontal();
// Start language item
GUILayout.Space(-29);
GUILayout.BeginVertical(EditorStyles.helpBox);
GUILayout.Space(4);
GUILayout.BeginHorizontal();
if (string.IsNullOrEmpty(lsTarget.languages[i].languageName) == true) { lsTarget.languages[i].isExpanded = EditorGUILayout.Foldout(lsTarget.languages[i].isExpanded, "Language #" + i.ToString(), true, foldoutStyle); }
else { lsTarget.languages[i].isExpanded = EditorGUILayout.Foldout(lsTarget.languages[i].isExpanded, lsTarget.languages[i].languageName + " (" + lsTarget.languages[i].languageID + ")", true, foldoutStyle); }
lsTarget.languages[i].isExpanded = GUILayout.Toggle(lsTarget.languages[i].isExpanded, new GUIContent(""), customSkin.FindStyle("Toggle Helper"));
GUILayout.EndHorizontal();
// Start language content
if (lsTarget.languages[i].isExpanded)
{
lsTarget.languages[i].languageID = EditorGUILayout.TextField("Language ID", lsTarget.languages[i].languageID);
lsTarget.languages[i].languageName = EditorGUILayout.TextField("Language Name", lsTarget.languages[i].languageName);
lsTarget.languages[i].localizedName = EditorGUILayout.TextField("Localized Name", lsTarget.languages[i].localizedName);
lsTarget.languages[i].localizationLanguage = EditorGUILayout.ObjectField("Language Asset", lsTarget.languages[i].localizationLanguage, typeof(LocalizationLanguage), true) as LocalizationLanguage;
if (lsTarget.languages[i].localizationLanguage == null && GUILayout.Button("Create Language Asset", customSkin.button))
{
LocalizationLanguage newLocale = ScriptableObject.CreateInstance<LocalizationLanguage>();
// Check for the path
string path = AssetDatabase.GetAssetPath(lsTarget);
path = path.Replace("/" + lsTarget.name + ".asset", "").Trim();
string fullPath = path.Replace("/" + lsTarget.name + ".asset", "").Trim() + "/Languages/";
if (!Directory.Exists(fullPath)) { AssetDatabase.CreateFolder(path, "Languages"); }
// Create the new asset
AssetDatabase.CreateAsset(newLocale, fullPath + lsTarget.languages[i].languageName + ".asset");
AssetDatabase.SaveAssets();
newLocale.localizationSettings = lsTarget;
newLocale.languageID = lsTarget.languages[i].languageID;
newLocale.name = lsTarget.languages[i].languageName;
newLocale.localizedName = lsTarget.languages[i].localizedName;
lsTarget.languages[i].localizationLanguage = newLocale;
// Add all available tables
for (int x = 0; x < lsTarget.tables.Count; x++)
{
LocalizationLanguage.TableList newList = new LocalizationLanguage.TableList();
newList.table = lsTarget.tables[x].localizationTable;
lsTarget.languages[i].localizationLanguage.tableList.Add(newList);
EditorUtility.SetDirty(lsTarget.languages[i].localizationLanguage);
for (int y = 0; y < lsTarget.tables[x].localizationTable.tableContent.Count; y++)
{
LocalizationLanguage.TableContent newContent = new LocalizationLanguage.TableContent();
newContent.key = "Key #" + y;
newList.tableContent.Add(newContent);
}
}
// Change the s.o. file name
AssetDatabase.RenameAsset(AssetDatabase.GetAssetPath(newLocale), lsTarget.languages[i].languageName + " (" + lsTarget.languages[i].languageID + ")");
newLocale.name = lsTarget.languages[i].languageName + " (" + lsTarget.languages[i].languageID + ")";
AssetDatabase.Refresh();
// Set dirty
EditorUtility.FocusProjectWindow();
EditorUtility.SetDirty(lsTarget);
}
else if (lsTarget.languages[i].localizationLanguage != null && GUILayout.Button("Show Language Asset", customSkin.button))
{
Selection.activeObject = lsTarget.languages[i].localizationLanguage;
}
}
// Set localization settings for the items
if (lsTarget.languages[i].localizationLanguage != null)
{
lsTarget.languages[i].localizationLanguage.localizationSettings = lsTarget;
lsTarget.languages[i].localizationLanguage.languageID = lsTarget.languages[i].localizationLanguage.localizationSettings.languages[i].languageID;
lsTarget.languages[i].localizationLanguage.languageName = lsTarget.languages[i].localizationLanguage.localizationSettings.languages[i].languageName;
lsTarget.languages[i].localizationLanguage.localizedName = lsTarget.languages[i].localizationLanguage.localizationSettings.languages[i].localizedName;
}
// End language item
GUILayout.EndVertical();
GUILayout.Space(-3);
}
GUILayout.Space(2);
if (GUILayout.Button("+ New Language", customSkin.button))
{
LocalizationSettings.Language language = new LocalizationSettings.Language();
language.languageID = "null";
language.languageName = "New Language";
language.isExpanded = false;
lsTarget.languages.Add(language);
// Refresh language list
RefreshLanguageDropdown();
EditorUtility.SetDirty(lsTarget);
}
#endregion
#region Available Tables
// Available Tables Header
HeatUIEditorHandler.DrawHeader(customSkin, "Tables Header", 14);
GUILayout.Space(-3);
// Draw tables
for (int i = 0; i < lsTarget.tables.Count; i++)
{
// Draw Action Buttons
GUILayout.Space(6);
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
if (lsTarget.tables[i].localizationTable != null && GUILayout.Button("Edit", customSkin.button, GUILayout.Width(34)))
{
LocalizationTableWindow.ShowWindow(lsTarget, lsTarget.tables[i].localizationTable, i);
}
if (GUILayout.Button("Delete", customSkin.button, GUILayout.Width(50)))
{
if (EditorUtility.DisplayDialog("Delete Table", "Are you sure you want to delete the following table: " + lsTarget.tables[i].tableID
+ "\n\nThis action deletes the specified table resources and cannot be undone.", "Yes", "Cancel"))
{
// Clear empty languages first
for (int x = 0; x < lsTarget.languages.Count; x++)
{
for (int y = 0; y < lsTarget.languages[x].localizationLanguage.tableList.Count; y++)
{
if (lsTarget.languages[x].localizationLanguage.tableList[y].table == null)
{
lsTarget.languages[x].localizationLanguage.tableList.RemoveAt(y);
}
}
}
// Delete from all existing langs if available
if (lsTarget.tables[i].localizationTable != null)
{
for (int x = 0; x < lsTarget.languages.Count; x++)
{
if (lsTarget.languages[x].localizationLanguage == null)
continue;
for (int y = 0; y < lsTarget.languages[x].localizationLanguage.tableList.Count; y++)
{
if (lsTarget.languages[x].localizationLanguage.tableList[y].table == lsTarget.tables[i].localizationTable)
{
lsTarget.languages[x].localizationLanguage.tableList.RemoveAt(y);
EditorUtility.SetDirty(lsTarget.languages[x].localizationLanguage);
}
}
}
}
if (lsTarget.tables[i].localizationTable != null) { AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(lsTarget.tables[i].localizationTable)); }
lsTarget.tables.Remove(lsTarget.tables[i]);
EditorUtility.SetDirty(lsTarget);
return;
}
}
GUILayout.Space(5);
GUILayout.EndHorizontal();
// Start table item
GUILayout.Space(-29);
GUILayout.BeginVertical(EditorStyles.helpBox);
GUILayout.Space(4);
GUILayout.BeginHorizontal();
if (string.IsNullOrEmpty(lsTarget.tables[i].tableID) == true) { lsTarget.tables[i].isExpanded = EditorGUILayout.Foldout(lsTarget.tables[i].isExpanded, "Table #" + i.ToString(), true, foldoutStyle); }
else { lsTarget.tables[i].isExpanded = EditorGUILayout.Foldout(lsTarget.tables[i].isExpanded, lsTarget.tables[i].tableID, true, foldoutStyle); }
lsTarget.tables[i].isExpanded = GUILayout.Toggle(lsTarget.tables[i].isExpanded, new GUIContent(""), customSkin.FindStyle("Toggle Helper"));
GUILayout.EndHorizontal();
// Start table content
if (lsTarget.tables[i].isExpanded)
{
lsTarget.tables[i].tableID = EditorGUILayout.TextField("Table ID", lsTarget.tables[i].tableID);
lsTarget.tables[i].localizationTable = EditorGUILayout.ObjectField("Localization Table", lsTarget.tables[i].localizationTable, typeof(LocalizationTable), true) as LocalizationTable;
if (lsTarget.tables[i].localizationTable != null) { lsTarget.tables[i].localizationTable.tableID = lsTarget.tables[i].tableID; }
if (lsTarget.tables[i].localizationTable == null && GUILayout.Button("+ Create Table Asset", customSkin.button))
{
LocalizationTable newTable = ScriptableObject.CreateInstance<LocalizationTable>();
// Check for the path
string path = AssetDatabase.GetAssetPath(lsTarget);
path = path.Replace("/" + lsTarget.name + ".asset", "").Trim();
string fullPath = path.Replace("/" + lsTarget.name + ".asset", "").Trim() + "/Tables/";
if (!Directory.Exists(fullPath)) { AssetDatabase.CreateFolder(path, "Tables"); }
// Create the new asset
AssetDatabase.CreateAsset(newTable, fullPath + lsTarget.tables[i].tableID + ".asset");
AssetDatabase.SaveAssets();
// Change the s.o. values
AssetDatabase.RenameAsset(AssetDatabase.GetAssetPath(newTable), lsTarget.tables[i].tableID);
newTable.name = lsTarget.tables[i].tableID;
newTable.tableID = lsTarget.tables[i].tableID;
newTable.localizationSettings = lsTarget;
lsTarget.tables[i].localizationTable = newTable;
AssetDatabase.Refresh();
// Add table to all available languages
for (int x = 0; x < lsTarget.languages.Count; x++)
{
if (lsTarget.languages[x].localizationLanguage == null)
continue;
LocalizationLanguage.TableList newList = new LocalizationLanguage.TableList();
newList.table = newTable;
lsTarget.languages[x].localizationLanguage.tableList.Add(newList);
EditorUtility.SetDirty(lsTarget.languages[x].localizationLanguage);
}
// Set dirty
EditorUtility.FocusProjectWindow();
EditorUtility.SetDirty(lsTarget);
EditorUtility.SetDirty(newTable);
}
else if (lsTarget.tables[i].localizationTable != null && GUILayout.Button("Show Table Asset", customSkin.button))
{
if (lsTarget.tables[i].localizationTable.localizationSettings == null) { lsTarget.tables[i].localizationTable.localizationSettings = lsTarget; }
Selection.activeObject = lsTarget.tables[i].localizationTable;
}
}
// End table item
GUILayout.EndVertical();
GUILayout.Space(-3);
}
GUILayout.Space(2);
if (lsTarget.tables.Count == 0)
{
EditorGUILayout.HelpBox("There are no localization tables to show.", MessageType.Info);
if (GUILayout.Button("+ New Table", customSkin.button))
{
LocalizationSettings.Table table = new LocalizationSettings.Table();
table.tableID = "Table #" + lsTarget.tables.Count.ToString();
lsTarget.tables.Add(table);
EditorUtility.SetDirty(lsTarget);
}
}
else if (lsTarget.tables[lsTarget.tables.Count - 1].localizationTable != null && GUILayout.Button("+ New Table", customSkin.button))
{
LocalizationSettings.Table table = new LocalizationSettings.Table();
table.tableID = "Table #" + lsTarget.tables.Count.ToString();
lsTarget.tables.Add(table);
EditorUtility.SetDirty(lsTarget);
}
else if (lsTarget.tables[lsTarget.tables.Count - 1].localizationTable == null)
{
EditorGUILayout.HelpBox("In order to create a new table, you must first create a table asset for " + lsTarget.tables[lsTarget.tables.Count - 1].tableID + ".", MessageType.Warning);
}
#endregion
#region Settings
HeatUIEditorHandler.DrawHeader(customSkin, "Options Header", 14);
var enableExperimental = serializedObject.FindProperty("enableExperimental");
enableExperimental.boolValue = HeatUIEditorHandler.DrawToggle(enableExperimental.boolValue, customSkin, "Enable Experimental Features");
#endregion
#region Support
HeatUIEditorHandler.DrawHeader(customSkin, "Support Header", 14);
EditorGUILayout.HelpBox("Stuck or just getting started? You can check out the documentation page.", MessageType.Info);
if (GUILayout.Button("Documentation", customSkin.button)) { Docs(); }
#endregion
serializedObject.ApplyModifiedProperties();
if (Application.isPlaying == false) { Repaint(); }
}
private static int SortByName(LocalizationSettings.Language o1, LocalizationSettings.Language o2)
{
// Compare the names and sort by A to Z
return o1.languageName.CompareTo(o2.languageName);
}
private void RefreshLanguageDropdown()
{
for (int i = 0; i < lsTarget.languages.Count; i++)
{
languageList.Add(lsTarget.languages[i].languageName + " (" + lsTarget.languages[i].languageID + ")");
if (string.IsNullOrEmpty(lsTarget.defaultLanguageID) == false && languageList[i] == lsTarget.defaultLanguageID) { defaultLanguageIndex = i; }
}
if (string.IsNullOrEmpty(lsTarget.defaultLanguageID) == true && languageList.Count != 0) { lsTarget.defaultLanguageID = languageList[0]; }
}
void Docs() { Application.OpenURL("https://docs.michsky.com/docs/heat-ui/localization"); }
}
}
#endif

Some files were not shown because too many files have changed in this diff Show More