Insanely huge initial commit

This commit is contained in:
2026-02-21 17:04:05 -08:00
parent 9cdd36191a
commit 613d75914a
22525 changed files with 4035207 additions and 0 deletions

View File

@@ -0,0 +1,116 @@
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.Events;
using TMPro;
namespace Michsky.MUIP
{
[DisallowMultipleComponent]
[RequireComponent(typeof(Animator))]
public class NotificationManager : MonoBehaviour
{
// Content
public Sprite icon;
public string title = "Notification Title";
[TextArea] public string description = "Notification description";
// Resources
public Animator notificationAnimator;
public Image iconObj;
public TextMeshProUGUI titleObj;
public TextMeshProUGUI descriptionObj;
// Settings
public bool enableTimer = true;
public float timer = 3f;
public bool useCustomContent = false;
public bool useStacking = false;
[HideInInspector] public bool isOn;
public StartBehaviour startBehaviour = StartBehaviour.Disable;
public CloseBehaviour closeBehaviour = CloseBehaviour.Disable;
// Events
public UnityEvent onOpen;
public UnityEvent onClose;
public enum StartBehaviour { None, Disable }
public enum CloseBehaviour { None, Disable, Destroy }
void Awake()
{
isOn = false;
if (useCustomContent == false) { UpdateUI(); }
if (notificationAnimator == null) { notificationAnimator = gameObject.GetComponent<Animator>(); }
if (startBehaviour == StartBehaviour.Disable) { gameObject.SetActive(false); }
if (useStacking == true)
{
try
{
NotificationStacking stacking = transform.GetComponentInParent<NotificationStacking>();
stacking.notifications.Add(this);
stacking.enableUpdating = true;
}
catch { Debug.LogError("<b>[Notification]</b> 'Stacking' is enabled but 'Notification Stacking' cannot be found in parent.", this); }
}
}
public void Open()
{
if (isOn == true)
return;
gameObject.SetActive(true);
isOn = true;
StopCoroutine("StartTimer");
StopCoroutine("DisableNotification");
notificationAnimator.Play("In");
onOpen.Invoke();
if (enableTimer == true) { StartCoroutine("StartTimer"); }
}
public void Close()
{
if (isOn == false)
return;
isOn = false;
notificationAnimator.Play("Out");
onClose.Invoke();
StartCoroutine("DisableNotification");
}
// Obsolete
public void OpenNotification() { Open(); }
public void CloseNotification() { Close(); }
public void UpdateUI()
{
if (iconObj != null) { iconObj.sprite = icon; }
if (titleObj != null) { titleObj.text = title; }
if (descriptionObj != null) { descriptionObj.text = description; }
}
IEnumerator StartTimer()
{
yield return new WaitForSeconds(timer);
CloseNotification();
StartCoroutine("DisableNotification");
}
IEnumerator DisableNotification()
{
yield return new WaitForSeconds(1f);
if (closeBehaviour == CloseBehaviour.Disable) { gameObject.SetActive(false); isOn = false; }
else if (closeBehaviour == CloseBehaviour.Destroy) { Destroy(gameObject); }
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4b4bbdcf873a4164eabf85f0d7820717
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: adf3c8361dd31e1448483775ea241c10, type: 3}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,191 @@
#if UNITY_EDITOR
using UnityEngine;
using UnityEditor;
using UnityEditor.SceneManagement;
namespace Michsky.MUIP
{
[CustomEditor(typeof(NotificationManager))]
public class NotificationManagerEditor : Editor
{
private GUISkin customSkin;
private NotificationManager ntfTarget;
private UIManagerNotification tempUIM;
private int currentTab;
private void OnEnable()
{
ntfTarget = (NotificationManager)target;
try { tempUIM = ntfTarget.GetComponent<UIManagerNotification>(); }
catch { }
if (EditorGUIUtility.isProSkin == true) { customSkin = MUIPEditorHandler.GetDarkEditor(customSkin); }
else { customSkin = MUIPEditorHandler.GetLightEditor(customSkin); }
}
public override void OnInspectorGUI()
{
MUIPEditorHandler.DrawComponentHeader(customSkin, "Notification Top Header");
GUIContent[] toolbarTabs = new GUIContent[3];
toolbarTabs[0] = new GUIContent("Content");
toolbarTabs[1] = new GUIContent("Resources");
toolbarTabs[2] = new GUIContent("Settings");
currentTab = MUIPEditorHandler.DrawTabs(currentTab, toolbarTabs, customSkin);
if (GUILayout.Button(new GUIContent("Content", "Content"), customSkin.FindStyle("Tab Content")))
currentTab = 0;
if (GUILayout.Button(new GUIContent("Resources", "Resources"), customSkin.FindStyle("Tab Resources")))
currentTab = 1;
if (GUILayout.Button(new GUIContent("Settings", "Settings"), customSkin.FindStyle("Tab Settings")))
currentTab = 2;
GUILayout.EndHorizontal();
var icon = serializedObject.FindProperty("icon");
var title = serializedObject.FindProperty("title");
var description = serializedObject.FindProperty("description");
var notificationAnimator = serializedObject.FindProperty("notificationAnimator");
var iconObj = serializedObject.FindProperty("iconObj");
var titleObj = serializedObject.FindProperty("titleObj");
var descriptionObj = serializedObject.FindProperty("descriptionObj");
var enableTimer = serializedObject.FindProperty("enableTimer");
var timer = serializedObject.FindProperty("timer");
var useCustomContent = serializedObject.FindProperty("useCustomContent");
var useStacking = serializedObject.FindProperty("useStacking");
var closeBehaviour = serializedObject.FindProperty("closeBehaviour");
var startBehaviour = serializedObject.FindProperty("startBehaviour");
var onOpen = serializedObject.FindProperty("onOpen");
var onClose = serializedObject.FindProperty("onClose");
switch (currentTab)
{
case 0:
MUIPEditorHandler.DrawHeader(customSkin, "Content Header", 6);
MUIPEditorHandler.DrawProperty(icon, customSkin, "Icon");
if (ntfTarget.iconObj != null)
ntfTarget.iconObj.sprite = ntfTarget.icon;
else
{
if (ntfTarget.iconObj == null)
{
GUILayout.BeginHorizontal();
EditorGUILayout.HelpBox("'Icon Object' is not assigned. Go to Resources tab and assign the correct variable.", MessageType.Error);
GUILayout.EndHorizontal();
}
}
MUIPEditorHandler.DrawProperty(title, customSkin, "Title");
if (ntfTarget.titleObj != null)
ntfTarget.titleObj.text = title.stringValue;
else
{
if (ntfTarget.titleObj == null)
{
GUILayout.BeginHorizontal();
EditorGUILayout.HelpBox("'Title Object' is not assigned. Go to Resources tab and assign the correct variable.", MessageType.Error);
GUILayout.EndHorizontal();
}
}
GUILayout.BeginHorizontal(EditorStyles.helpBox);
EditorGUILayout.LabelField(new GUIContent("Description"), customSkin.FindStyle("Text"), GUILayout.Width(-3));
EditorGUILayout.PropertyField(description, new GUIContent(""), GUILayout.Height(50));
GUILayout.EndHorizontal();
if (ntfTarget.descriptionObj != null)
ntfTarget.descriptionObj.text = description.stringValue;
else
{
if (ntfTarget.descriptionObj == null)
{
GUILayout.BeginHorizontal();
EditorGUILayout.HelpBox("'Description Object' is not assigned. Go to Resources tab and assign the correct variable.", MessageType.Error);
GUILayout.EndHorizontal();
}
}
if (ntfTarget.GetComponent<CanvasGroup>().alpha == 0)
{
if (GUILayout.Button("Make It Visible", customSkin.button))
{
ntfTarget.GetComponent<CanvasGroup>().alpha = 1;
EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
}
}
else
{
if (GUILayout.Button("Make It Invisible", customSkin.button))
{
ntfTarget.GetComponent<CanvasGroup>().alpha = 0;
EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
}
}
MUIPEditorHandler.DrawHeader(customSkin, "Events Header", 10);
EditorGUILayout.PropertyField(onOpen, new GUIContent("On Open"), true);
EditorGUILayout.PropertyField(onClose, new GUIContent("On Close"), true);
break;
case 1:
MUIPEditorHandler.DrawHeader(customSkin, "Core Header", 6);
MUIPEditorHandler.DrawProperty(notificationAnimator, customSkin, "Animator");
MUIPEditorHandler.DrawProperty(iconObj, customSkin, "Icon Object");
MUIPEditorHandler.DrawProperty(titleObj, customSkin, "Title Object");
MUIPEditorHandler.DrawProperty(descriptionObj, customSkin, "Description Object");
break;
case 2:
MUIPEditorHandler.DrawHeader(customSkin, "Options Header", 6);
MUIPEditorHandler.DrawProperty(startBehaviour, customSkin, "Start Behaviour");
MUIPEditorHandler.DrawProperty(closeBehaviour, customSkin, "Close Behaviour");
useCustomContent.boolValue = MUIPEditorHandler.DrawToggle(useCustomContent.boolValue, customSkin, "Use Custom Content");
useStacking.boolValue = MUIPEditorHandler.DrawToggle(useStacking.boolValue, customSkin, "Use Stacking");
enableTimer.boolValue = MUIPEditorHandler.DrawToggle(enableTimer.boolValue, customSkin, "Enable Timer");
if (enableTimer.boolValue == true)
MUIPEditorHandler.DrawProperty(timer, customSkin, "Timer");
MUIPEditorHandler.DrawHeader(customSkin, "UIM Header", 10);
if (tempUIM != null)
{
MUIPEditorHandler.DrawUIManagerConnectedHeader();
tempUIM.overrideColors = MUIPEditorHandler.DrawToggle(tempUIM.overrideColors, customSkin, "Override Colors");
tempUIM.overrideFonts = MUIPEditorHandler.DrawToggle(tempUIM.overrideFonts, customSkin, "Override Fonts");
if (GUILayout.Button("Open UI Manager", customSkin.button))
EditorApplication.ExecuteMenuItem("Tools/Modern UI Pack/Show UI Manager");
if (GUILayout.Button("Disable UI Manager Connection", customSkin.button))
{
if (EditorUtility.DisplayDialog("Modern UI Pack", "Are you sure you want to disable UI Manager connection with the object? " +
"This operation cannot be undone.", "Yes", "Cancel"))
{
try { DestroyImmediate(tempUIM); }
catch { Debug.LogError("<b>[Notification Manager]</b> Failed to delete UI Manager connection.", this); }
}
}
}
else if (tempUIM == null) { MUIPEditorHandler.DrawUIManagerDisconnectedHeader(); }
break;
}
if (Application.isPlaying == false) { this.Repaint(); }
serializedObject.ApplyModifiedProperties();
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b72fc390a6760374ba76d6ae40841bac
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,58 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Michsky.MUIP
{
[AddComponentMenu("Modern UI Pack/Notification/Notification Stacking")]
public class NotificationStacking : MonoBehaviour
{
public List<NotificationManager> notifications = new List<NotificationManager>();
[HideInInspector] public bool enableUpdating = false;
[Header("Settings")]
public float delay = 1;
int currentNotification = 0;
void Update()
{
if (enableUpdating == true)
{
try
{
notifications[currentNotification].gameObject.SetActive(true);
if (notifications[currentNotification].notificationAnimator.GetCurrentAnimatorStateInfo(0).IsName("Wait"))
{
notifications[currentNotification].OpenNotification();
StartCoroutine("StartNotification");
enableUpdating = false;
}
if (currentNotification >= notifications.Count)
{
enableUpdating = false;
currentNotification = 0;
}
}
catch
{
enableUpdating = false;
currentNotification = 0;
notifications.Clear();
}
}
}
IEnumerator StartNotification()
{
yield return new WaitForSeconds(notifications[currentNotification].timer + delay);
Destroy(notifications[currentNotification].gameObject);
// notifications.Remove(notifications[currentNotification]);
enableUpdating = true;
currentNotification += 1;
StopCoroutine("StartNotification");
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1d6e5a79c713c094fb2ea4246d215d24
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: adf3c8361dd31e1448483775ea241c10, type: 3}
userData:
assetBundleName:
assetBundleVariant: