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,131 @@
using System.Collections;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
using UnityEngine.Events;
namespace Michsky.MUIP
{
[RequireComponent(typeof(CanvasGroup))]
public class ModalWindowManager : MonoBehaviour
{
// Resources
public Image windowIcon;
public TextMeshProUGUI windowTitle;
public TextMeshProUGUI windowDescription;
public ButtonManager confirmButton;
public ButtonManager cancelButton;
public Animator mwAnimator;
// Content
public Sprite icon;
public string titleText = "Title";
[TextArea] public string descriptionText = "Description here";
// Events
public UnityEvent onOpen;
public UnityEvent onConfirm;
public UnityEvent onCancel;
// Settings
public bool useCustomContent = false;
public bool isOn = false;
public bool closeOnCancel = true;
public bool closeOnConfirm = true;
public bool showCancelButton = true;
public bool showConfirmButton = true;
public StartBehaviour startBehaviour = StartBehaviour.Disable;
public CloseBehaviour closeBehaviour = CloseBehaviour.Disable;
public enum StartBehaviour { None, Disable, Enable }
public enum CloseBehaviour { None, Disable, Destroy }
void Awake()
{
isOn = false;
if (mwAnimator == null) { mwAnimator = gameObject.GetComponent<Animator>(); }
if (closeOnCancel == true) { onCancel.AddListener(CloseWindow); }
if (closeOnConfirm == true) { onConfirm.AddListener(CloseWindow); }
if (confirmButton != null) { confirmButton.onClick.AddListener(onConfirm.Invoke); }
if (cancelButton != null) { cancelButton.onClick.AddListener(onCancel.Invoke); }
if (startBehaviour == StartBehaviour.Disable) { isOn = false; gameObject.SetActive(false); }
else if (startBehaviour == StartBehaviour.Enable) { isOn = false; OpenWindow(); }
UpdateUI();
}
public void UpdateUI()
{
if (useCustomContent == true)
return;
if (windowIcon != null) { windowIcon.sprite = icon; }
if (windowTitle != null) { windowTitle.text = titleText; }
if (windowDescription != null) { windowDescription.text = descriptionText; }
if (showCancelButton == true && cancelButton != null) { cancelButton.gameObject.SetActive(true); }
else if (cancelButton != null) { cancelButton.gameObject.SetActive(false); }
if (showConfirmButton == true && confirmButton != null) { confirmButton.gameObject.SetActive(true); }
else if (confirmButton != null) { confirmButton.gameObject.SetActive(false); }
}
public void Open()
{
if (isOn == false)
{
StopCoroutine("DisableObject");
gameObject.SetActive(true);
isOn = true;
onOpen.Invoke();
mwAnimator.Play("Fade-in");
}
}
public void Close()
{
if (isOn == true)
{
isOn = false;
mwAnimator.Play("Fade-out");
StartCoroutine("DisableObject");
}
}
// Obsolete
public void OpenWindow() { Open(); }
public void CloseWindow() { Close(); }
public void AnimateWindow()
{
if (isOn == false)
{
StopCoroutine("DisableObject");
isOn = true;
gameObject.SetActive(true);
mwAnimator.Play("Fade-in");
}
else
{
isOn = false;
mwAnimator.Play("Fade-out");
StartCoroutine("DisableObject");
}
}
IEnumerator DisableObject()
{
yield return new WaitForSeconds(1);
if (closeBehaviour == CloseBehaviour.Disable) { gameObject.SetActive(false); }
else if (closeBehaviour == CloseBehaviour.Destroy) { Destroy(gameObject); }
}
}
}

View File

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

View File

@@ -0,0 +1,187 @@
#if UNITY_EDITOR
using UnityEngine;
using UnityEditor;
using UnityEditor.SceneManagement;
namespace Michsky.MUIP
{
[CustomEditor(typeof(ModalWindowManager))]
public class ModalWindowManagerEditor : Editor
{
private GUISkin customSkin;
private ModalWindowManager mwTarget;
private UIManagerModalWindow tempUIM;
private int currentTab;
private void OnEnable()
{
mwTarget = (ModalWindowManager)target;
try { tempUIM = mwTarget.GetComponent<UIManagerModalWindow>(); }
catch { }
if (EditorGUIUtility.isProSkin == true) { customSkin = MUIPEditorHandler.GetDarkEditor(customSkin); }
else { customSkin = MUIPEditorHandler.GetLightEditor(customSkin); }
}
public override void OnInspectorGUI()
{
MUIPEditorHandler.DrawComponentHeader(customSkin, "MW 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 windowIcon = serializedObject.FindProperty("windowIcon");
var windowTitle = serializedObject.FindProperty("windowTitle");
var windowDescription = serializedObject.FindProperty("windowDescription");
var onConfirm = serializedObject.FindProperty("onConfirm");
var onCancel = serializedObject.FindProperty("onCancel");
var onOpen = serializedObject.FindProperty("onOpen");
var icon = serializedObject.FindProperty("icon");
var titleText = serializedObject.FindProperty("titleText");
var descriptionText = serializedObject.FindProperty("descriptionText");
var confirmButton = serializedObject.FindProperty("confirmButton");
var cancelButton = serializedObject.FindProperty("cancelButton");
var mwAnimator = serializedObject.FindProperty("mwAnimator");
var useCustomContent = serializedObject.FindProperty("useCustomContent");
var closeBehaviour = serializedObject.FindProperty("closeBehaviour");
var startBehaviour = serializedObject.FindProperty("startBehaviour");
var closeOnCancel = serializedObject.FindProperty("closeOnCancel");
var closeOnConfirm = serializedObject.FindProperty("closeOnConfirm");
var showCancelButton = serializedObject.FindProperty("showCancelButton");
var showConfirmButton = serializedObject.FindProperty("showConfirmButton");
switch (currentTab)
{
case 0:
MUIPEditorHandler.DrawHeader(customSkin, "Content Header", 6);
if (useCustomContent.boolValue == false)
{
MUIPEditorHandler.DrawProperty(icon, customSkin, "Icon");
if (mwTarget.windowIcon != null) { mwTarget.windowIcon.sprite = mwTarget.icon; }
else if (mwTarget.windowIcon == 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(titleText, customSkin, "Title");
if (mwTarget.windowTitle != null) { mwTarget.windowTitle.text = titleText.stringValue; }
else if (mwTarget.windowTitle == 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(descriptionText, new GUIContent(""), GUILayout.Height(80));
GUILayout.EndHorizontal();
if (mwTarget.windowDescription != null) { mwTarget.windowDescription.text = descriptionText.stringValue; }
else if (mwTarget.windowDescription == null)
{
GUILayout.BeginHorizontal();
EditorGUILayout.HelpBox("'Description Object' is not assigned. Go to Resources tab and assign the correct variable.", MessageType.Error);
GUILayout.EndHorizontal();
}
}
else { EditorGUILayout.HelpBox("'Use Custom Content' is enabled.", MessageType.Info); }
if (mwTarget.GetComponent<CanvasGroup>().alpha == 0)
{
if (GUILayout.Button("Make It Visible", customSkin.button))
{
mwTarget.GetComponent<CanvasGroup>().alpha = 1;
EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
}
}
else
{
if (GUILayout.Button("Make It Invisible", customSkin.button))
{
mwTarget.GetComponent<CanvasGroup>().alpha = 0;
EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
}
}
MUIPEditorHandler.DrawHeader(customSkin, "Events Header", 10);
EditorGUILayout.PropertyField(onOpen, new GUIContent("On Open"), true);
EditorGUILayout.PropertyField(onConfirm, new GUIContent("On Confirm"), true);
EditorGUILayout.PropertyField(onCancel, new GUIContent("On Cancel"), true);
break;
case 1:
MUIPEditorHandler.DrawHeader(customSkin, "Core Header", 6);
MUIPEditorHandler.DrawProperty(windowIcon, customSkin, "Icon Object");
MUIPEditorHandler.DrawProperty(windowTitle, customSkin, "Title Object");
MUIPEditorHandler.DrawProperty(windowDescription, customSkin, "Description Object");
MUIPEditorHandler.DrawProperty(confirmButton, customSkin, "Confirm Button");
MUIPEditorHandler.DrawProperty(cancelButton, customSkin, "Cancel Button");
MUIPEditorHandler.DrawProperty(mwAnimator, customSkin, "Animator");
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");
closeOnCancel.boolValue = MUIPEditorHandler.DrawToggle(closeOnCancel.boolValue, customSkin, "Close Window On Cancel");
closeOnConfirm.boolValue = MUIPEditorHandler.DrawToggle(closeOnConfirm.boolValue, customSkin, "Close Window On Confirm");
showCancelButton.boolValue = MUIPEditorHandler.DrawToggle(showCancelButton.boolValue, customSkin, "Show Cancel Button");
showConfirmButton.boolValue = MUIPEditorHandler.DrawToggle(showConfirmButton.boolValue, customSkin, "Show Confirm Button");
MUIPEditorHandler.DrawHeader(customSkin, "UIM Header", 10);
if (tempUIM != null)
{
MUIPEditorHandler.DrawUIManagerConnectedHeader();
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>[Modal Window]</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: a4a5d2752ec07da4aa46f6540abbd763
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: