Imported UI Assets
This commit is contained in:
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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
|
@ -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
|
@ -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
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
@ -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
|
@ -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
|
@ -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
|
Reference in New Issue
Block a user