架构大更
This commit is contained in:
@@ -1,33 +1,40 @@
|
||||
#if UNITY_EDITOR
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Michsky.MUIP
|
||||
{
|
||||
[CustomEditor(typeof(ContextMenuManager))]
|
||||
public class ContextMenuManagerEditor : Editor
|
||||
{
|
||||
private GUISkin customSkin;
|
||||
private ContextMenuManager cmTarget;
|
||||
private UIManagerContextMenu tempUIM;
|
||||
private int currentTab;
|
||||
private GUISkin customSkin;
|
||||
private UIManagerContextMenu tempUIM;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
cmTarget = (ContextMenuManager)target;
|
||||
|
||||
try { tempUIM = cmTarget.GetComponent<UIManagerContextMenu>(); }
|
||||
catch { }
|
||||
try
|
||||
{
|
||||
tempUIM = cmTarget.GetComponent<UIManagerContextMenu>();
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
if (EditorGUIUtility.isProSkin == true) { customSkin = MUIPEditorHandler.GetDarkEditor(customSkin); }
|
||||
else { customSkin = MUIPEditorHandler.GetLightEditor(customSkin); }
|
||||
if (EditorGUIUtility.isProSkin)
|
||||
customSkin = MUIPEditorHandler.GetDarkEditor(customSkin);
|
||||
else
|
||||
customSkin = MUIPEditorHandler.GetLightEditor(customSkin);
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
MUIPEditorHandler.DrawComponentHeader(customSkin, "CM Top Header");
|
||||
|
||||
GUIContent[] toolbarTabs = new GUIContent[3];
|
||||
var toolbarTabs = new GUIContent[3];
|
||||
toolbarTabs[0] = new GUIContent("Content");
|
||||
toolbarTabs[1] = new GUIContent("Resources");
|
||||
toolbarTabs[2] = new GUIContent("Settings");
|
||||
@@ -80,10 +87,13 @@ namespace Michsky.MUIP
|
||||
case 2:
|
||||
MUIPEditorHandler.DrawHeader(customSkin, "Options Header", 6);
|
||||
debugMode.boolValue = MUIPEditorHandler.DrawToggle(debugMode.boolValue, customSkin, "Debug Mode");
|
||||
autoSubMenuPosition.boolValue = MUIPEditorHandler.DrawToggle(autoSubMenuPosition.boolValue, customSkin, "Auto Sub Menu Position");
|
||||
autoSubMenuPosition.boolValue = MUIPEditorHandler.DrawToggle(autoSubMenuPosition.boolValue,
|
||||
customSkin, "Auto Sub Menu Position");
|
||||
MUIPEditorHandler.DrawProperty(subMenuBehaviour, customSkin, "Sub Menu Behaviour");
|
||||
#if UNITY_2022_1_OR_NEWER
|
||||
EditorGUILayout.HelpBox("Due to an issue with the event system, the 'Hover' option will be temporarily disabled in Unity 2022.1.", MessageType.Info);
|
||||
EditorGUILayout.HelpBox(
|
||||
"Due to an issue with the event system, the 'Hover' option will be temporarily disabled in Unity 2022.1.",
|
||||
MessageType.Info);
|
||||
#endif
|
||||
MUIPEditorHandler.DrawProperty(cameraSource, customSkin, "Camera Source");
|
||||
|
||||
@@ -100,22 +110,29 @@ namespace Michsky.MUIP
|
||||
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>[Context Menu]</b> Failed to delete UI Manager connection.", this); }
|
||||
}
|
||||
}
|
||||
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>[Context Menu]</b> Failed to delete UI Manager connection.",
|
||||
this);
|
||||
}
|
||||
}
|
||||
|
||||
else if (tempUIM == null) { MUIPEditorHandler.DrawUIManagerDisconnectedHeader(); }
|
||||
else if (tempUIM == null)
|
||||
{
|
||||
MUIPEditorHandler.DrawUIManagerDisconnectedHeader();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (Application.isPlaying == false) { this.Repaint(); }
|
||||
if (!Application.isPlaying) Repaint();
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,34 +10,34 @@ namespace Michsky.MUIP
|
||||
{
|
||||
public class DemoElementSway : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler, IPointerClickHandler
|
||||
{
|
||||
[Header("Resources")]
|
||||
[SerializeField] private DemoElementSwayParent swayParent;
|
||||
[Header("Resources")] [SerializeField] private DemoElementSwayParent swayParent;
|
||||
|
||||
[SerializeField] private Canvas mainCanvas;
|
||||
[SerializeField] private RectTransform swayObject;
|
||||
[SerializeField] private CanvasGroup normalCG;
|
||||
[SerializeField] private CanvasGroup highlightedCG;
|
||||
[SerializeField] private CanvasGroup selectedCG;
|
||||
|
||||
[Header("Settings")]
|
||||
[SerializeField] private float smoothness = 10;
|
||||
[Header("Settings")] [SerializeField] private float smoothness = 10;
|
||||
|
||||
[SerializeField] private float transitionSpeed = 8;
|
||||
[SerializeField] [Range(0, 1)] private float dissolveAlpha = 0.5f;
|
||||
|
||||
[Header("Events")]
|
||||
[SerializeField] private UnityEvent onClick;
|
||||
[Header("Events")] [SerializeField] private UnityEvent onClick;
|
||||
|
||||
bool allowSway;
|
||||
[HideInInspector] public bool wmSelected;
|
||||
|
||||
Vector3 cursorPos;
|
||||
Vector2 defaultPos;
|
||||
private bool allowSway;
|
||||
|
||||
void Awake()
|
||||
private Vector3 cursorPos;
|
||||
private Vector2 defaultPos;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (swayParent == null)
|
||||
{
|
||||
var tempSway = transform.parent.GetComponent<DemoElementSwayParent>();
|
||||
if (tempSway == null) { transform.parent.gameObject.AddComponent<DemoElementSwayParent>(); }
|
||||
if (tempSway == null) transform.parent.gameObject.AddComponent<DemoElementSwayParent>();
|
||||
swayParent = tempSway;
|
||||
}
|
||||
|
||||
@@ -46,44 +46,75 @@ namespace Michsky.MUIP
|
||||
highlightedCG.alpha = 0;
|
||||
}
|
||||
|
||||
void Update()
|
||||
private void Update()
|
||||
{
|
||||
#if ENABLE_LEGACY_INPUT_MANAGER
|
||||
if (allowSway == true) { cursorPos = Input.mousePosition; }
|
||||
#elif ENABLE_INPUT_SYSTEM
|
||||
if (allowSway == true) { cursorPos = Mouse.current.position.ReadValue(); }
|
||||
if (allowSway) cursorPos = Mouse.current.position.ReadValue();
|
||||
#endif
|
||||
|
||||
if (mainCanvas.renderMode == RenderMode.ScreenSpaceOverlay) { ProcessOverlay(); }
|
||||
else if (mainCanvas.renderMode == RenderMode.ScreenSpaceCamera) { ProcessSSC(); }
|
||||
else if (mainCanvas.renderMode == RenderMode.WorldSpace) { ProcessWorldSpace(); }
|
||||
if (mainCanvas.renderMode == RenderMode.ScreenSpaceOverlay)
|
||||
ProcessOverlay();
|
||||
else if (mainCanvas.renderMode == RenderMode.ScreenSpaceCamera)
|
||||
ProcessSSC();
|
||||
else if (mainCanvas.renderMode == RenderMode.WorldSpace) ProcessWorldSpace();
|
||||
}
|
||||
|
||||
void ProcessOverlay()
|
||||
public void OnPointerClick(PointerEventData data)
|
||||
{
|
||||
if (allowSway == true) { swayObject.position = Vector2.Lerp(swayObject.position, cursorPos, Time.deltaTime * smoothness); }
|
||||
else { swayObject.localPosition = Vector2.Lerp(swayObject.localPosition, defaultPos, Time.deltaTime * smoothness); }
|
||||
onClick.Invoke();
|
||||
}
|
||||
|
||||
void ProcessSSC()
|
||||
public void OnPointerEnter(PointerEventData data)
|
||||
{
|
||||
if (allowSway == true) { swayObject.position = Vector2.Lerp(swayObject.position, Camera.main.ScreenToWorldPoint(cursorPos), Time.deltaTime * smoothness); }
|
||||
else { swayObject.localPosition = Vector2.Lerp(swayObject.localPosition, defaultPos, Time.deltaTime * smoothness); }
|
||||
allowSway = true;
|
||||
swayParent.DissolveAll(this);
|
||||
}
|
||||
|
||||
void ProcessWorldSpace()
|
||||
public void OnPointerExit(PointerEventData data)
|
||||
{
|
||||
if (allowSway == true)
|
||||
allowSway = false;
|
||||
swayParent.HighlightAll();
|
||||
}
|
||||
|
||||
private void ProcessOverlay()
|
||||
{
|
||||
if (allowSway)
|
||||
swayObject.position = Vector2.Lerp(swayObject.position, cursorPos, Time.deltaTime * smoothness);
|
||||
else
|
||||
swayObject.localPosition =
|
||||
Vector2.Lerp(swayObject.localPosition, defaultPos, Time.deltaTime * smoothness);
|
||||
}
|
||||
|
||||
private void ProcessSSC()
|
||||
{
|
||||
if (allowSway)
|
||||
swayObject.position = Vector2.Lerp(swayObject.position, Camera.main.ScreenToWorldPoint(cursorPos),
|
||||
Time.deltaTime * smoothness);
|
||||
else
|
||||
swayObject.localPosition =
|
||||
Vector2.Lerp(swayObject.localPosition, defaultPos, Time.deltaTime * smoothness);
|
||||
}
|
||||
|
||||
private void ProcessWorldSpace()
|
||||
{
|
||||
if (allowSway)
|
||||
{
|
||||
Vector3 clampedPos = new Vector3(cursorPos.x, cursorPos.y, (mainCanvas.transform.position.z / 6f));
|
||||
swayObject.position = Vector3.Lerp(swayObject.position, Camera.main.ScreenToWorldPoint(clampedPos), Time.deltaTime * smoothness);
|
||||
var clampedPos = new Vector3(cursorPos.x, cursorPos.y, mainCanvas.transform.position.z / 6f);
|
||||
swayObject.position = Vector3.Lerp(swayObject.position, Camera.main.ScreenToWorldPoint(clampedPos),
|
||||
Time.deltaTime * smoothness);
|
||||
}
|
||||
else
|
||||
{
|
||||
swayObject.localPosition =
|
||||
Vector3.Lerp(swayObject.localPosition, defaultPos, Time.deltaTime * smoothness);
|
||||
}
|
||||
else { swayObject.localPosition = Vector3.Lerp(swayObject.localPosition, defaultPos, Time.deltaTime * smoothness); }
|
||||
}
|
||||
|
||||
public void Dissolve()
|
||||
{
|
||||
if (wmSelected == true)
|
||||
if (wmSelected)
|
||||
return;
|
||||
|
||||
StopCoroutine("DissolveHelper");
|
||||
@@ -95,7 +126,7 @@ namespace Michsky.MUIP
|
||||
|
||||
public void Highlight()
|
||||
{
|
||||
if (wmSelected == true)
|
||||
if (wmSelected)
|
||||
return;
|
||||
|
||||
StopCoroutine("DissolveHelper");
|
||||
@@ -107,7 +138,7 @@ namespace Michsky.MUIP
|
||||
|
||||
public void Active()
|
||||
{
|
||||
if (wmSelected == true)
|
||||
if (wmSelected)
|
||||
return;
|
||||
|
||||
StopCoroutine("DissolveHelper");
|
||||
@@ -134,24 +165,7 @@ namespace Michsky.MUIP
|
||||
StartCoroutine("DissolveHelper");
|
||||
}
|
||||
|
||||
public void OnPointerEnter(PointerEventData data)
|
||||
{
|
||||
allowSway = true;
|
||||
swayParent.DissolveAll(this);
|
||||
}
|
||||
|
||||
public void OnPointerExit(PointerEventData data)
|
||||
{
|
||||
allowSway = false;
|
||||
swayParent.HighlightAll();
|
||||
}
|
||||
|
||||
public void OnPointerClick(PointerEventData data)
|
||||
{
|
||||
onClick.Invoke();
|
||||
}
|
||||
|
||||
IEnumerator DissolveHelper()
|
||||
private IEnumerator DissolveHelper()
|
||||
{
|
||||
while (normalCG.alpha > dissolveAlpha)
|
||||
{
|
||||
@@ -165,7 +179,7 @@ namespace Michsky.MUIP
|
||||
highlightedCG.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
IEnumerator HighlightHelper()
|
||||
private IEnumerator HighlightHelper()
|
||||
{
|
||||
while (normalCG.alpha < 1)
|
||||
{
|
||||
@@ -179,7 +193,7 @@ namespace Michsky.MUIP
|
||||
highlightedCG.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
IEnumerator ActiveHelper()
|
||||
private IEnumerator ActiveHelper()
|
||||
{
|
||||
highlightedCG.gameObject.SetActive(true);
|
||||
|
||||
@@ -194,7 +208,7 @@ namespace Michsky.MUIP
|
||||
normalCG.alpha = 0;
|
||||
}
|
||||
|
||||
IEnumerator WMSelectHelper()
|
||||
private IEnumerator WMSelectHelper()
|
||||
{
|
||||
selectedCG.gameObject.SetActive(true);
|
||||
|
||||
@@ -211,7 +225,7 @@ namespace Michsky.MUIP
|
||||
selectedCG.alpha = 1;
|
||||
}
|
||||
|
||||
IEnumerator WMDeselectHelper()
|
||||
private IEnumerator WMDeselectHelper()
|
||||
{
|
||||
while (selectedCG.alpha > 0)
|
||||
{
|
||||
|
||||
@@ -6,12 +6,6 @@ namespace Michsky.MUIP
|
||||
[RequireComponent(typeof(Animator))]
|
||||
public class AnimatedIconHandler : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler, IPointerClickHandler
|
||||
{
|
||||
[Header("Settings")]
|
||||
public PlayType playType;
|
||||
public Animator iconAnimator;
|
||||
|
||||
bool isClicked;
|
||||
|
||||
public enum PlayType
|
||||
{
|
||||
Click,
|
||||
@@ -19,21 +13,18 @@ namespace Michsky.MUIP
|
||||
None
|
||||
}
|
||||
|
||||
void Start()
|
||||
[Header("Settings")] public PlayType playType;
|
||||
|
||||
public Animator iconAnimator;
|
||||
|
||||
private bool isClicked;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
if (iconAnimator == null)
|
||||
iconAnimator = gameObject.GetComponent<Animator>();
|
||||
}
|
||||
|
||||
public void PlayIn() { iconAnimator.Play("In"); }
|
||||
public void PlayOut() { iconAnimator.Play("Out"); }
|
||||
|
||||
public void ClickEvent()
|
||||
{
|
||||
if (isClicked == true) { PlayOut(); isClicked = false; }
|
||||
else { PlayIn(); isClicked = true; }
|
||||
}
|
||||
|
||||
public void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
if (playType == PlayType.Click)
|
||||
@@ -51,5 +42,29 @@ namespace Michsky.MUIP
|
||||
if (playType == PlayType.Hover)
|
||||
iconAnimator.Play("Out");
|
||||
}
|
||||
|
||||
public void PlayIn()
|
||||
{
|
||||
iconAnimator.Play("In");
|
||||
}
|
||||
|
||||
public void PlayOut()
|
||||
{
|
||||
iconAnimator.Play("Out");
|
||||
}
|
||||
|
||||
public void ClickEvent()
|
||||
{
|
||||
if (isClicked)
|
||||
{
|
||||
PlayOut();
|
||||
isClicked = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayIn();
|
||||
isClicked = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,81 +16,88 @@ namespace Michsky.MUIP
|
||||
public string selectedIconID;
|
||||
public int selectedIconIndex;
|
||||
[Range(0, 3)] public int spriteSize;
|
||||
|
||||
Image imageObject;
|
||||
[HideInInspector] public string currentSize;
|
||||
[HideInInspector] public bool size32;
|
||||
[HideInInspector] public bool size64;
|
||||
[HideInInspector] public bool size128;
|
||||
[HideInInspector] public bool size256;
|
||||
|
||||
void Awake()
|
||||
private Image imageObject;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (iconLibrary == null) { iconLibrary = Resources.Load<IconLibrary>("Icon Library"); }
|
||||
if (imageObject == null) { imageObject = gameObject.GetComponent<Image>(); }
|
||||
if (iconLibrary == null) iconLibrary = Resources.Load<IconLibrary>("Icon Library");
|
||||
if (imageObject == null) imageObject = gameObject.GetComponent<Image>();
|
||||
|
||||
this.enabled = true;
|
||||
enabled = true;
|
||||
UpdateElement();
|
||||
}
|
||||
|
||||
catch { Debug.LogWarning("<b>Icon Library</b> is missing, but it should be assigned.", this); }
|
||||
catch
|
||||
{
|
||||
Debug.LogWarning("<b>Icon Library</b> is missing, but it should be assigned.", this);
|
||||
}
|
||||
}
|
||||
|
||||
void Update()
|
||||
private void Update()
|
||||
{
|
||||
if (iconLibrary.alwaysUpdate == true) { UpdateElement(); }
|
||||
if (Application.isPlaying == true && iconLibrary.optimizeUpdates == true) { this.enabled = false; }
|
||||
if (iconLibrary.alwaysUpdate) UpdateElement();
|
||||
if (Application.isPlaying && iconLibrary.optimizeUpdates) enabled = false;
|
||||
}
|
||||
|
||||
public void UpdateElement()
|
||||
{
|
||||
if (iconLibrary == null)
|
||||
{
|
||||
this.enabled = false;
|
||||
enabled = false;
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < iconLibrary.icons.Count; i++)
|
||||
{
|
||||
if (selectedIconID == iconLibrary.icons[i].iconTitle && gameObject.activeInHierarchy == true)
|
||||
for (var i = 0; i < iconLibrary.icons.Count; i++)
|
||||
if (selectedIconID == iconLibrary.icons[i].iconTitle && gameObject.activeInHierarchy)
|
||||
{
|
||||
if (spriteSize == 0) { imageObject.sprite = iconLibrary.icons[i].iconSprite32; }
|
||||
else if (spriteSize == 1) { imageObject.sprite = iconLibrary.icons[i].iconSprite64; }
|
||||
else if (spriteSize == 2) { imageObject.sprite = iconLibrary.icons[i].iconSprite128; }
|
||||
else if (spriteSize == 3) { imageObject.sprite = iconLibrary.icons[i].iconSprite256; }
|
||||
if (spriteSize == 0)
|
||||
imageObject.sprite = iconLibrary.icons[i].iconSprite32;
|
||||
else if (spriteSize == 1)
|
||||
imageObject.sprite = iconLibrary.icons[i].iconSprite64;
|
||||
else if (spriteSize == 2)
|
||||
imageObject.sprite = iconLibrary.icons[i].iconSprite128;
|
||||
else if (spriteSize == 3) imageObject.sprite = iconLibrary.icons[i].iconSprite256;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (iconLibrary.alwaysUpdate == false)
|
||||
this.enabled = false;
|
||||
if (!iconLibrary.alwaysUpdate)
|
||||
enabled = false;
|
||||
}
|
||||
|
||||
public void UpdateSpriteSize(int spriteIndex, int newSize)
|
||||
{
|
||||
if (newSize == 0) { imageObject.sprite = iconLibrary.icons[spriteIndex].iconSprite32; }
|
||||
else if (newSize == 1) { imageObject.sprite = iconLibrary.icons[spriteIndex].iconSprite64; }
|
||||
else if (newSize == 2) { imageObject.sprite = iconLibrary.icons[spriteIndex].iconSprite128; }
|
||||
else if (newSize == 3) { imageObject.sprite = iconLibrary.icons[spriteIndex].iconSprite256; }
|
||||
if (newSize == 0)
|
||||
imageObject.sprite = iconLibrary.icons[spriteIndex].iconSprite32;
|
||||
else if (newSize == 1)
|
||||
imageObject.sprite = iconLibrary.icons[spriteIndex].iconSprite64;
|
||||
else if (newSize == 2)
|
||||
imageObject.sprite = iconLibrary.icons[spriteIndex].iconSprite128;
|
||||
else if (newSize == 3) imageObject.sprite = iconLibrary.icons[spriteIndex].iconSprite256;
|
||||
}
|
||||
|
||||
public void ChangeIcon(string newSprite, int preferredSize)
|
||||
{
|
||||
int selectedSpriteIndex = -1;
|
||||
var selectedSpriteIndex = -1;
|
||||
|
||||
for (int i = 0; i < iconLibrary.icons.Count; i++)
|
||||
{
|
||||
for (var i = 0; i < iconLibrary.icons.Count; i++)
|
||||
if (newSprite == iconLibrary.icons[i].iconTitle)
|
||||
{
|
||||
selectedSpriteIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (selectedSpriteIndex != -1) { UpdateSpriteSize(selectedSpriteIndex, preferredSize); }
|
||||
else { Debug.Log("<b>[Icon Manager]</b> Cannot find an icon named '" + newSprite + "'"); }
|
||||
if (selectedSpriteIndex != -1)
|
||||
UpdateSpriteSize(selectedSpriteIndex, preferredSize);
|
||||
else
|
||||
Debug.Log("<b>[Icon Manager]</b> Cannot find an icon named '" + newSprite + "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,26 +1,28 @@
|
||||
#if UNITY_EDITOR
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Michsky.MUIP
|
||||
{
|
||||
[CustomEditor(typeof(UIGradient))]
|
||||
public class UIGradientEditor : Editor
|
||||
{
|
||||
private GUISkin customSkin;
|
||||
private int currentTab;
|
||||
private GUISkin customSkin;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
if (EditorGUIUtility.isProSkin == true) { customSkin = MUIPEditorHandler.GetDarkEditor(customSkin); }
|
||||
else { customSkin = MUIPEditorHandler.GetLightEditor(customSkin); }
|
||||
if (EditorGUIUtility.isProSkin)
|
||||
customSkin = MUIPEditorHandler.GetDarkEditor(customSkin);
|
||||
else
|
||||
customSkin = MUIPEditorHandler.GetLightEditor(customSkin);
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
MUIPEditorHandler.DrawComponentHeader(customSkin, "Gradient Top Header");
|
||||
|
||||
GUIContent[] toolbarTabs = new GUIContent[1];
|
||||
var toolbarTabs = new GUIContent[1];
|
||||
toolbarTabs[0] = new GUIContent("Settings");
|
||||
|
||||
currentTab = MUIPEditorHandler.DrawTabs(currentTab, toolbarTabs, customSkin);
|
||||
@@ -44,11 +46,12 @@ namespace Michsky.MUIP
|
||||
MUIPEditorHandler.DrawPropertyCW(_gradientType, customSkin, "Type", 100);
|
||||
MUIPEditorHandler.DrawPropertyCW(_offset, customSkin, "Offset", 100);
|
||||
MUIPEditorHandler.DrawPropertyCW(_zoom, customSkin, "Zoom", 100);
|
||||
_modifyVertices.boolValue = MUIPEditorHandler.DrawToggle(_modifyVertices.boolValue, customSkin, "Complex Gradient");
|
||||
_modifyVertices.boolValue =
|
||||
MUIPEditorHandler.DrawToggle(_modifyVertices.boolValue, customSkin, "Complex Gradient");
|
||||
break;
|
||||
}
|
||||
|
||||
if (Application.isPlaying == false) { this.Repaint(); }
|
||||
if (!Application.isPlaying) Repaint();
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using TMPro;
|
||||
|
||||
namespace Michsky.MUIP
|
||||
{
|
||||
@@ -11,7 +11,7 @@ namespace Michsky.MUIP
|
||||
public string numberFormat;
|
||||
|
||||
public float realValue;
|
||||
private bool assignedRealValue = false;
|
||||
private bool assignedRealValue;
|
||||
|
||||
protected override void Start()
|
||||
{
|
||||
@@ -31,9 +31,11 @@ namespace Michsky.MUIP
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
realValue = maxValue - input + minValue;
|
||||
}
|
||||
|
||||
if (wholeNumbers == true)
|
||||
if (wholeNumbers)
|
||||
realValue = Mathf.Round(realValue);
|
||||
|
||||
if (realValue <= minSlider.value)
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using TMPro;
|
||||
|
||||
namespace Michsky.MUIP
|
||||
{
|
||||
public class RangeMinSlider : Slider
|
||||
{
|
||||
[Header("RESOURCES")]
|
||||
public RangeMaxSlider maxSlider;
|
||||
[Header("RESOURCES")] public RangeMaxSlider maxSlider;
|
||||
|
||||
public TextMeshProUGUI label;
|
||||
public string numberFormat;
|
||||
|
||||
@@ -16,9 +16,9 @@ namespace Michsky.MUIP
|
||||
if (maxSlider == null)
|
||||
maxSlider = transform.parent.Find("Max Slider").GetComponent<RangeMaxSlider>();
|
||||
|
||||
float newValue = input;
|
||||
|
||||
if (wholeNumbers == true)
|
||||
var newValue = input;
|
||||
|
||||
if (wholeNumbers)
|
||||
newValue = Mathf.Round(newValue);
|
||||
|
||||
if (newValue >= maxSlider.realValue && maxSlider.realValue != maxSlider.minValue)
|
||||
@@ -26,7 +26,7 @@ namespace Michsky.MUIP
|
||||
|
||||
if (label != null)
|
||||
label.text = newValue.ToString(numberFormat);
|
||||
|
||||
|
||||
base.Set(input, sendCallback);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,45 +1,45 @@
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using TMPro;
|
||||
|
||||
namespace Michsky.MUIP
|
||||
{
|
||||
[ExecuteInEditMode]
|
||||
public class UIManagerNotification : MonoBehaviour
|
||||
{
|
||||
[Header("Settings")]
|
||||
[SerializeField] private UIManager UIManagerAsset;
|
||||
[HideInInspector] public bool overrideColors = false;
|
||||
[HideInInspector] public bool overrideFonts = false;
|
||||
[Header("Settings")] [SerializeField] private UIManager UIManagerAsset;
|
||||
|
||||
[HideInInspector] public bool overrideColors;
|
||||
[HideInInspector] public bool overrideFonts;
|
||||
|
||||
[Header("Resources")] [SerializeField] private Image background;
|
||||
|
||||
[Header("Resources")]
|
||||
[SerializeField] private Image background;
|
||||
[SerializeField] private Image icon;
|
||||
[SerializeField] private TextMeshProUGUI title;
|
||||
[SerializeField] private TextMeshProUGUI description;
|
||||
|
||||
void Awake()
|
||||
private void Awake()
|
||||
{
|
||||
if (UIManagerAsset == null) { UIManagerAsset = Resources.Load<UIManager>("MUIP Manager"); }
|
||||
if (UIManagerAsset == null) UIManagerAsset = Resources.Load<UIManager>("MUIP Manager");
|
||||
|
||||
this.enabled = true;
|
||||
enabled = true;
|
||||
|
||||
if (UIManagerAsset.enableDynamicUpdate == false)
|
||||
if (!UIManagerAsset.enableDynamicUpdate)
|
||||
{
|
||||
UpdateNotification();
|
||||
this.enabled = false;
|
||||
enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
void Update()
|
||||
private void Update()
|
||||
{
|
||||
if (UIManagerAsset == null) { return; }
|
||||
if (UIManagerAsset.enableDynamicUpdate == true) { UpdateNotification(); }
|
||||
if (UIManagerAsset == null) return;
|
||||
if (UIManagerAsset.enableDynamicUpdate) UpdateNotification();
|
||||
}
|
||||
|
||||
void UpdateNotification()
|
||||
private void UpdateNotification()
|
||||
{
|
||||
if (overrideColors == false)
|
||||
if (!overrideColors)
|
||||
{
|
||||
background.color = UIManagerAsset.notificationBackgroundColor;
|
||||
icon.color = UIManagerAsset.notificationIconColor;
|
||||
@@ -47,7 +47,7 @@ namespace Michsky.MUIP
|
||||
description.color = UIManagerAsset.notificationDescriptionColor;
|
||||
}
|
||||
|
||||
if (overrideFonts == false)
|
||||
if (!overrideFonts)
|
||||
{
|
||||
title.font = UIManagerAsset.notificationTitleFont;
|
||||
title.fontSize = UIManagerAsset.notificationTitleFontSize;
|
||||
|
||||
@@ -1,33 +1,40 @@
|
||||
#if UNITY_EDITOR
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Michsky.MUIP
|
||||
{
|
||||
[CustomEditor(typeof(WindowManager))]
|
||||
public class WindowManagerEditor : Editor
|
||||
{
|
||||
private GUISkin customSkin;
|
||||
private WindowManager wmTarget;
|
||||
private UIManagerWindowManager tempUIM;
|
||||
private int currentTab;
|
||||
private GUISkin customSkin;
|
||||
private UIManagerWindowManager tempUIM;
|
||||
private WindowManager wmTarget;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
wmTarget = (WindowManager)target;
|
||||
|
||||
try { tempUIM = wmTarget.GetComponent<UIManagerWindowManager>(); }
|
||||
catch { }
|
||||
try
|
||||
{
|
||||
tempUIM = wmTarget.GetComponent<UIManagerWindowManager>();
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
if (EditorGUIUtility.isProSkin == true) { customSkin = MUIPEditorHandler.GetDarkEditor(customSkin); }
|
||||
else { customSkin = MUIPEditorHandler.GetLightEditor(customSkin); }
|
||||
if (EditorGUIUtility.isProSkin)
|
||||
customSkin = MUIPEditorHandler.GetDarkEditor(customSkin);
|
||||
else
|
||||
customSkin = MUIPEditorHandler.GetLightEditor(customSkin);
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
MUIPEditorHandler.DrawComponentHeader(customSkin, "WM Top Header");
|
||||
|
||||
GUIContent[] toolbarTabs = new GUIContent[2];
|
||||
var toolbarTabs = new GUIContent[2];
|
||||
toolbarTabs[0] = new GUIContent("Content");
|
||||
toolbarTabs[1] = new GUIContent("Settings");
|
||||
|
||||
@@ -53,38 +60,44 @@ namespace Michsky.MUIP
|
||||
|
||||
if (wmTarget.windows.Count != 0)
|
||||
{
|
||||
if (Application.isPlaying == true) { GUI.enabled = false; }
|
||||
if (Application.isPlaying) GUI.enabled = false;
|
||||
GUILayout.BeginVertical(EditorStyles.helpBox);
|
||||
|
||||
EditorGUILayout.LabelField(new GUIContent("Selected Window:"), customSkin.FindStyle("Text"), GUILayout.Width(120));
|
||||
currentWindowIndex.intValue = EditorGUILayout.IntSlider(currentWindowIndex.intValue, 0, wmTarget.windows.Count - 1);
|
||||
EditorGUILayout.LabelField(new GUIContent("Selected Window:"), customSkin.FindStyle("Text"),
|
||||
GUILayout.Width(120));
|
||||
currentWindowIndex.intValue = EditorGUILayout.IntSlider(currentWindowIndex.intValue, 0,
|
||||
wmTarget.windows.Count - 1);
|
||||
|
||||
GUILayout.Space(2);
|
||||
EditorGUILayout.LabelField(new GUIContent(wmTarget.windows[currentWindowIndex.intValue].windowName), customSkin.FindStyle("Text"));
|
||||
EditorGUILayout.LabelField(
|
||||
new GUIContent(wmTarget.windows[currentWindowIndex.intValue].windowName),
|
||||
customSkin.FindStyle("Text"));
|
||||
|
||||
if (Application.isPlaying == false && wmTarget.windows[currentWindowIndex.intValue].windowObject != null)
|
||||
{
|
||||
for (int i = 0; i < wmTarget.windows.Count; i++)
|
||||
{
|
||||
if (i == currentWindowIndex.intValue)
|
||||
if (!Application.isPlaying &&
|
||||
wmTarget.windows[currentWindowIndex.intValue].windowObject != null)
|
||||
for (var i = 0; i < wmTarget.windows.Count; i++)
|
||||
if (i == currentWindowIndex.intValue)
|
||||
{
|
||||
var tempCG = wmTarget.windows[currentWindowIndex.intValue].windowObject.GetComponent<CanvasGroup>();
|
||||
if (tempCG != null) { tempCG.alpha = 1; }
|
||||
var tempCG = wmTarget.windows[currentWindowIndex.intValue].windowObject
|
||||
.GetComponent<CanvasGroup>();
|
||||
if (tempCG != null) tempCG.alpha = 1;
|
||||
}
|
||||
|
||||
else if (wmTarget.windows[i].windowObject != null)
|
||||
{
|
||||
var tempCG = wmTarget.windows[i].windowObject.GetComponent<CanvasGroup>();
|
||||
if (tempCG != null) { tempCG.alpha = 0; }
|
||||
if (tempCG != null) tempCG.alpha = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GUI.enabled = true;
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
|
||||
else { EditorGUILayout.HelpBox("Window List is empty. Create a new item to see more options.", MessageType.Info); }
|
||||
else
|
||||
{
|
||||
EditorGUILayout.HelpBox("Window List is empty. Create a new item to see more options.",
|
||||
MessageType.Info);
|
||||
}
|
||||
|
||||
GUILayout.BeginVertical();
|
||||
EditorGUI.indentLevel = 1;
|
||||
@@ -102,8 +115,10 @@ namespace Michsky.MUIP
|
||||
|
||||
case 1:
|
||||
MUIPEditorHandler.DrawHeader(customSkin, "Options Header", 6);
|
||||
cullWindows.boolValue = MUIPEditorHandler.DrawToggle(cullWindows.boolValue, customSkin, "Cull Transparent Windows");
|
||||
initializeButtons.boolValue = MUIPEditorHandler.DrawToggle(initializeButtons.boolValue, customSkin, "Initialize Buttons");
|
||||
cullWindows.boolValue =
|
||||
MUIPEditorHandler.DrawToggle(cullWindows.boolValue, customSkin, "Cull Transparent Windows");
|
||||
initializeButtons.boolValue = MUIPEditorHandler.DrawToggle(initializeButtons.boolValue, customSkin,
|
||||
"Initialize Buttons");
|
||||
|
||||
MUIPEditorHandler.DrawHeader(customSkin, "UIM Header", 10);
|
||||
|
||||
@@ -115,22 +130,29 @@ namespace Michsky.MUIP
|
||||
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>[Window Manager]</b> Failed to delete UI Manager connection.", this); }
|
||||
}
|
||||
}
|
||||
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>[Window Manager]</b> Failed to delete UI Manager connection.",
|
||||
this);
|
||||
}
|
||||
}
|
||||
|
||||
else if (tempUIM == null) { MUIPEditorHandler.DrawUIManagerDisconnectedHeader(); }
|
||||
else if (tempUIM == null)
|
||||
{
|
||||
MUIPEditorHandler.DrawUIManagerDisconnectedHeader();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (Application.isPlaying == false) { this.Repaint(); }
|
||||
if (!Application.isPlaying) Repaint();
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user