Initial Unity project commit
This commit is contained in:
+339
@@ -0,0 +1,339 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.Events;
|
||||
using TMPro;
|
||||
|
||||
namespace Michsky.MUIP
|
||||
{
|
||||
[RequireComponent(typeof(Animator))]
|
||||
public class HorizontalSelector : MonoBehaviour
|
||||
{
|
||||
// Resources
|
||||
public TextMeshProUGUI label;
|
||||
public TextMeshProUGUI labelHelper;
|
||||
public Image labelIcon;
|
||||
public Image labelIconHelper;
|
||||
public Transform indicatorParent;
|
||||
public GameObject indicatorObject;
|
||||
public Animator selectorAnimator;
|
||||
public HorizontalLayoutGroup contentLayout;
|
||||
public HorizontalLayoutGroup contentLayoutHelper;
|
||||
private string newItemTitle;
|
||||
|
||||
// Saving
|
||||
public bool enableIcon = true;
|
||||
public bool saveSelected = false;
|
||||
public string saveKey = "My Selector";
|
||||
|
||||
// Settings
|
||||
public bool enableIndicators = true;
|
||||
public bool invokeAtStart;
|
||||
public bool invertAnimation;
|
||||
public bool loopSelection;
|
||||
[Range(0.25f, 2.5f)] public float iconScale = 1;
|
||||
[Range(1, 50)] public int contentSpacing = 15;
|
||||
public int defaultIndex = 0;
|
||||
[HideInInspector] public int index = 0;
|
||||
|
||||
// Items
|
||||
public List<Item> items = new List<Item>();
|
||||
|
||||
// Events
|
||||
[System.Serializable] public class SelectorEvent : UnityEvent<int> { }
|
||||
public SelectorEvent onValueChanged;
|
||||
[System.Serializable] public class ItemTextChangedEvent : UnityEvent<TMP_Text> { }
|
||||
public ItemTextChangedEvent onItemTextChanged;
|
||||
|
||||
[System.Serializable]
|
||||
public class Item
|
||||
{
|
||||
public string itemTitle = "Item Title";
|
||||
public Sprite itemIcon;
|
||||
public UnityEvent onItemSelect = new UnityEvent();
|
||||
}
|
||||
|
||||
void Awake()
|
||||
{
|
||||
if (selectorAnimator == null) { selectorAnimator = gameObject.GetComponent<Animator>(); }
|
||||
if (label == null || labelHelper == null)
|
||||
{
|
||||
Debug.LogError("<b>[Horizontal Selector]</b> Cannot initalize the object due to missing resources.", this);
|
||||
return;
|
||||
}
|
||||
|
||||
SetupSelector();
|
||||
UpdateContentLayout();
|
||||
|
||||
if (invokeAtStart)
|
||||
{
|
||||
items[index].onItemSelect.Invoke();
|
||||
onValueChanged.Invoke(index);
|
||||
}
|
||||
}
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
if (gameObject.activeInHierarchy) { StartCoroutine("DisableAnimator"); }
|
||||
}
|
||||
|
||||
public void SetupSelector()
|
||||
{
|
||||
if (items.Count == 0)
|
||||
return;
|
||||
|
||||
if (saveSelected)
|
||||
{
|
||||
if (PlayerPrefs.HasKey("HorizontalSelector_" + saveKey)) { defaultIndex = PlayerPrefs.GetInt("HorizontalSelector_" + saveKey); }
|
||||
else { PlayerPrefs.SetInt("HorizontalSelector_" + saveKey, defaultIndex); }
|
||||
}
|
||||
|
||||
label.text = items[defaultIndex].itemTitle;
|
||||
labelHelper.text = label.text;
|
||||
onItemTextChanged?.Invoke(label);
|
||||
|
||||
if (labelIcon != null && enableIcon)
|
||||
{
|
||||
labelIcon.sprite = items[defaultIndex].itemIcon;
|
||||
labelIconHelper.sprite = labelIcon.sprite;
|
||||
}
|
||||
|
||||
else if (!enableIcon)
|
||||
{
|
||||
if (labelIcon != null) { labelIcon.gameObject.SetActive(false); }
|
||||
if (labelIconHelper != null) { labelIconHelper.gameObject.SetActive(false); }
|
||||
}
|
||||
|
||||
index = defaultIndex;
|
||||
|
||||
if (enableIndicators) { UpdateIndicators(); }
|
||||
else if (indicatorParent != null) { Destroy(indicatorParent.gameObject); }
|
||||
}
|
||||
|
||||
public void PreviousItem()
|
||||
{
|
||||
if (items.Count == 0)
|
||||
return;
|
||||
|
||||
StopCoroutine("DisableAnimator");
|
||||
selectorAnimator.enabled = true;
|
||||
|
||||
if (!loopSelection)
|
||||
{
|
||||
if (index != 0)
|
||||
{
|
||||
labelHelper.text = label.text;
|
||||
if (labelIcon != null && enableIcon) { labelIconHelper.sprite = labelIcon.sprite; }
|
||||
|
||||
if (index == 0) { index = items.Count - 1; }
|
||||
else { index--; }
|
||||
|
||||
label.text = items[index].itemTitle;
|
||||
onItemTextChanged?.Invoke(label);
|
||||
if (labelIcon != null && enableIcon) { labelIcon.sprite = items[index].itemIcon; }
|
||||
|
||||
items[index].onItemSelect.Invoke();
|
||||
onValueChanged.Invoke(index);
|
||||
|
||||
selectorAnimator.Play(null);
|
||||
selectorAnimator.StopPlayback();
|
||||
|
||||
if (invertAnimation) { selectorAnimator.Play("Forward"); }
|
||||
else { selectorAnimator.Play("Previous"); }
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
labelHelper.text = label.text;
|
||||
if (labelIcon != null && enableIcon) { labelIconHelper.sprite = labelIcon.sprite; }
|
||||
|
||||
if (index == 0) { index = items.Count - 1; }
|
||||
else { index--; }
|
||||
|
||||
label.text = items[index].itemTitle;
|
||||
onItemTextChanged?.Invoke(label);
|
||||
if (labelIcon != null && enableIcon) { labelIcon.sprite = items[index].itemIcon; }
|
||||
|
||||
items[index].onItemSelect.Invoke();
|
||||
onValueChanged.Invoke(index);
|
||||
|
||||
selectorAnimator.Play(null);
|
||||
selectorAnimator.StopPlayback();
|
||||
|
||||
if (invertAnimation) { selectorAnimator.Play("Forward"); }
|
||||
else { selectorAnimator.Play("Previous"); }
|
||||
}
|
||||
|
||||
if (saveSelected) { PlayerPrefs.SetInt("HorizontalSelector_" + saveKey, index); }
|
||||
if (gameObject.activeInHierarchy) { StartCoroutine("DisableAnimator"); }
|
||||
if (enableIndicators)
|
||||
{
|
||||
for (int i = 0; i < items.Count; ++i)
|
||||
{
|
||||
GameObject go = indicatorParent.GetChild(i).gameObject;
|
||||
Transform onObj = go.transform.Find("On");
|
||||
Transform offObj = go.transform.Find("Off");
|
||||
|
||||
if (i == index) { onObj.gameObject.SetActive(true); offObj.gameObject.SetActive(false); }
|
||||
else { onObj.gameObject.SetActive(false); offObj.gameObject.SetActive(true); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void NextItem()
|
||||
{
|
||||
if (items.Count == 0)
|
||||
return;
|
||||
|
||||
StopCoroutine("DisableAnimator");
|
||||
selectorAnimator.enabled = true;
|
||||
|
||||
if (!loopSelection)
|
||||
{
|
||||
if (index != items.Count - 1)
|
||||
{
|
||||
labelHelper.text = label.text;
|
||||
if (labelIcon != null && enableIcon) { labelIconHelper.sprite = labelIcon.sprite; }
|
||||
|
||||
if ((index + 1) >= items.Count) { index = 0; }
|
||||
else { index++; }
|
||||
|
||||
label.text = items[index].itemTitle;
|
||||
onItemTextChanged?.Invoke(label);
|
||||
if (labelIcon != null && enableIcon) { labelIcon.sprite = items[index].itemIcon; }
|
||||
|
||||
items[index].onItemSelect.Invoke();
|
||||
onValueChanged.Invoke(index);
|
||||
|
||||
selectorAnimator.Play(null);
|
||||
selectorAnimator.StopPlayback();
|
||||
|
||||
if (invertAnimation) { selectorAnimator.Play("Previous"); }
|
||||
else { selectorAnimator.Play("Forward"); }
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
labelHelper.text = label.text;
|
||||
if (labelIcon != null && enableIcon) { labelIconHelper.sprite = labelIcon.sprite; }
|
||||
|
||||
if ((index + 1) >= items.Count) { index = 0; }
|
||||
else { index++; }
|
||||
|
||||
label.text = items[index].itemTitle;
|
||||
onItemTextChanged?.Invoke(label);
|
||||
if (labelIcon != null && enableIcon) { labelIcon.sprite = items[index].itemIcon; }
|
||||
|
||||
items[index].onItemSelect.Invoke();
|
||||
onValueChanged.Invoke(index);
|
||||
|
||||
selectorAnimator.Play(null);
|
||||
selectorAnimator.StopPlayback();
|
||||
|
||||
if (invertAnimation) { selectorAnimator.Play("Previous"); }
|
||||
else { selectorAnimator.Play("Forward"); }
|
||||
}
|
||||
|
||||
if (saveSelected) { PlayerPrefs.SetInt("HorizontalSelector_" + saveKey, index); }
|
||||
if (enableIndicators)
|
||||
{
|
||||
for (int i = 0; i < items.Count; ++i)
|
||||
{
|
||||
GameObject go = indicatorParent.GetChild(i).gameObject;
|
||||
Transform onObj = go.transform.Find("On"); ;
|
||||
Transform offObj = go.transform.Find("Off");
|
||||
|
||||
if (i == index) { onObj.gameObject.SetActive(true); offObj.gameObject.SetActive(false); }
|
||||
else { onObj.gameObject.SetActive(false); offObj.gameObject.SetActive(true); }
|
||||
}
|
||||
}
|
||||
|
||||
if (gameObject.activeInHierarchy) { StartCoroutine("DisableAnimator"); }
|
||||
}
|
||||
|
||||
// Obsolete
|
||||
public void PreviousClick() { PreviousItem(); }
|
||||
public void ForwardClick() { NextItem(); }
|
||||
|
||||
public void CreateNewItem(string title)
|
||||
{
|
||||
Item item = new Item();
|
||||
newItemTitle = title;
|
||||
item.itemTitle = newItemTitle;
|
||||
items.Add(item);
|
||||
}
|
||||
|
||||
public void CreateNewItem(string title, Sprite icon)
|
||||
{
|
||||
Item item = new Item();
|
||||
newItemTitle = title;
|
||||
item.itemTitle = newItemTitle;
|
||||
item.itemIcon = icon;
|
||||
items.Add(item);
|
||||
}
|
||||
|
||||
public void RemoveItem(string itemTitle)
|
||||
{
|
||||
var item = items.Find(x => x.itemTitle == itemTitle);
|
||||
items.Remove(item);
|
||||
SetupSelector();
|
||||
}
|
||||
|
||||
public void UpdateUI()
|
||||
{
|
||||
selectorAnimator.enabled = true;
|
||||
|
||||
label.text = items[index].itemTitle;
|
||||
onItemTextChanged?.Invoke(label);
|
||||
|
||||
if (labelIcon != null && enableIcon) { labelIcon.sprite = items[index].itemIcon; }
|
||||
if (gameObject.activeInHierarchy) { StartCoroutine("DisableAnimator"); }
|
||||
|
||||
UpdateContentLayout();
|
||||
UpdateIndicators();
|
||||
}
|
||||
|
||||
public void UpdateIndicators()
|
||||
{
|
||||
if (!enableIndicators)
|
||||
return;
|
||||
|
||||
foreach (Transform child in indicatorParent) { Destroy(child.gameObject); }
|
||||
for (int i = 0; i < items.Count; ++i)
|
||||
{
|
||||
GameObject go = Instantiate(indicatorObject, new Vector3(0, 0, 0), Quaternion.identity);
|
||||
go.transform.SetParent(indicatorParent, false);
|
||||
go.name = items[i].itemTitle;
|
||||
|
||||
Transform onObj = go.transform.Find("On");
|
||||
Transform offObj = go.transform.Find("Off");
|
||||
|
||||
if (i == index) { onObj.gameObject.SetActive(true); offObj.gameObject.SetActive(false); }
|
||||
else { onObj.gameObject.SetActive(false); offObj.gameObject.SetActive(true); }
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateContentLayout()
|
||||
{
|
||||
if (contentLayout != null) { contentLayout.spacing = contentSpacing; }
|
||||
if (contentLayoutHelper != null) { contentLayoutHelper.spacing = contentSpacing; }
|
||||
if (labelIcon != null)
|
||||
{
|
||||
labelIcon.transform.localScale = new Vector3(iconScale, iconScale, iconScale);
|
||||
labelIconHelper.transform.localScale = new Vector3(iconScale, iconScale, iconScale);
|
||||
}
|
||||
|
||||
LayoutRebuilder.ForceRebuildLayoutImmediate(label.transform.GetComponent<RectTransform>());
|
||||
LayoutRebuilder.ForceRebuildLayoutImmediate(label.transform.parent.GetComponent<RectTransform>());
|
||||
}
|
||||
|
||||
IEnumerator DisableAnimator()
|
||||
{
|
||||
yield return new WaitForSecondsRealtime(0.5f);
|
||||
selectorAnimator.enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 125c77e2c7bf16f4792824151a1d9249
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: 7a33180745301ca4b903e0c6e51cfeb6, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 201717
|
||||
packageName: Modern UI Pack
|
||||
packageVersion: 5.5.28
|
||||
assetPath: Assets/Modern UI Pack/Scripts/Horizontal Selector/HorizontalSelector.cs
|
||||
uploadId: 778406
|
||||
Vendored
+217
@@ -0,0 +1,217 @@
|
||||
#if UNITY_EDITOR
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace Michsky.MUIP
|
||||
{
|
||||
[CustomEditor(typeof(HorizontalSelector))]
|
||||
public class HorizontalSelectorEditor : Editor
|
||||
{
|
||||
private GUISkin customSkin;
|
||||
private HorizontalSelector hsTarget;
|
||||
private UIManagerHSelector tempUIM;
|
||||
private int currentTab;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
hsTarget = (HorizontalSelector)target;
|
||||
|
||||
try { tempUIM = hsTarget.GetComponent<UIManagerHSelector>(); }
|
||||
catch { }
|
||||
|
||||
if (EditorGUIUtility.isProSkin == true) { customSkin = MUIPEditorHandler.GetDarkEditor(customSkin); }
|
||||
else { customSkin = MUIPEditorHandler.GetLightEditor(customSkin); }
|
||||
|
||||
if (hsTarget.defaultIndex > hsTarget.items.Count - 1) { hsTarget.defaultIndex = 0; }
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
MUIPEditorHandler.DrawComponentHeader(customSkin, "HS 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 items = serializedObject.FindProperty("items");
|
||||
var onValueChanged = serializedObject.FindProperty("onValueChanged");
|
||||
var label = serializedObject.FindProperty("label");
|
||||
var selectorAnimator = serializedObject.FindProperty("selectorAnimator");
|
||||
var labelHelper = serializedObject.FindProperty("labelHelper");
|
||||
var labelIcon = serializedObject.FindProperty("labelIcon");
|
||||
var labelIconHelper = serializedObject.FindProperty("labelIconHelper");
|
||||
var indicatorParent = serializedObject.FindProperty("indicatorParent");
|
||||
var indicatorObject = serializedObject.FindProperty("indicatorObject");
|
||||
var enableIcon = serializedObject.FindProperty("enableIcon");
|
||||
var saveSelected = serializedObject.FindProperty("saveSelected");
|
||||
var saveKey = serializedObject.FindProperty("saveKey");
|
||||
var enableIndicators = serializedObject.FindProperty("enableIndicators");
|
||||
var invokeAtStart = serializedObject.FindProperty("invokeAtStart");
|
||||
var invertAnimation = serializedObject.FindProperty("invertAnimation");
|
||||
var loopSelection = serializedObject.FindProperty("loopSelection");
|
||||
var defaultIndex = serializedObject.FindProperty("defaultIndex");
|
||||
var iconScale = serializedObject.FindProperty("iconScale");
|
||||
var contentSpacing = serializedObject.FindProperty("contentSpacing");
|
||||
var contentLayout = serializedObject.FindProperty("contentLayout");
|
||||
var contentLayoutHelper = serializedObject.FindProperty("contentLayoutHelper");
|
||||
var enableUIManager = serializedObject.FindProperty("enableUIManager");
|
||||
|
||||
switch (currentTab)
|
||||
{
|
||||
case 0:
|
||||
MUIPEditorHandler.DrawHeader(customSkin, "Content Header", 6);
|
||||
|
||||
if (Application.isPlaying == false && hsTarget.items.Count != 0)
|
||||
{
|
||||
GUILayout.BeginVertical(EditorStyles.helpBox);
|
||||
GUILayout.BeginHorizontal();
|
||||
|
||||
GUI.enabled = false;
|
||||
EditorGUILayout.LabelField(new GUIContent("Selected Item:"), customSkin.FindStyle("Text"), GUILayout.Width(82));
|
||||
GUI.enabled = true;
|
||||
|
||||
EditorGUILayout.LabelField(new GUIContent(hsTarget.items[defaultIndex.intValue].itemTitle), customSkin.FindStyle("Text"));
|
||||
|
||||
GUILayout.EndHorizontal();
|
||||
GUILayout.Space(2);
|
||||
|
||||
defaultIndex.intValue = EditorGUILayout.IntSlider(defaultIndex.intValue, 0, hsTarget.items.Count - 1);
|
||||
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
|
||||
else if (Application.isPlaying == true && hsTarget.items.Count != 0)
|
||||
{
|
||||
GUILayout.BeginVertical(EditorStyles.helpBox);
|
||||
GUILayout.BeginHorizontal();
|
||||
GUI.enabled = false;
|
||||
|
||||
EditorGUILayout.LabelField(new GUIContent("Current Item:"), customSkin.FindStyle("Text"), GUILayout.Width(74));
|
||||
EditorGUILayout.LabelField(new GUIContent(hsTarget.items[hsTarget.index].itemTitle), customSkin.FindStyle("Text"));
|
||||
|
||||
GUILayout.EndHorizontal();
|
||||
GUILayout.Space(2);
|
||||
|
||||
EditorGUILayout.IntSlider(hsTarget.index, 0, hsTarget.items.Count - 1);
|
||||
|
||||
GUI.enabled = true;
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
|
||||
else { EditorGUILayout.HelpBox("There is no item in the list.", MessageType.Warning); }
|
||||
|
||||
GUILayout.BeginVertical();
|
||||
EditorGUI.indentLevel = 1;
|
||||
EditorGUILayout.PropertyField(items, new GUIContent("Selector Items"), true);
|
||||
EditorGUI.indentLevel = 1;
|
||||
GUILayout.EndVertical();
|
||||
|
||||
MUIPEditorHandler.DrawHeader(customSkin, "Events Header", 10);
|
||||
EditorGUILayout.PropertyField(onValueChanged, new GUIContent("On Value Changed"), true);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
MUIPEditorHandler.DrawHeader(customSkin, "Core Header", 6);
|
||||
MUIPEditorHandler.DrawProperty(selectorAnimator, customSkin, "Animator");
|
||||
MUIPEditorHandler.DrawProperty(label, customSkin, "Label");
|
||||
MUIPEditorHandler.DrawProperty(labelHelper, customSkin, "Label Helper");
|
||||
MUIPEditorHandler.DrawProperty(labelIcon, customSkin, "Label Icon");
|
||||
MUIPEditorHandler.DrawProperty(labelIconHelper, customSkin, "Label Icon Helper");
|
||||
MUIPEditorHandler.DrawProperty(indicatorParent, customSkin, "Indicator Parent");
|
||||
MUIPEditorHandler.DrawProperty(indicatorObject, customSkin, "Indicator Object");
|
||||
MUIPEditorHandler.DrawProperty(contentLayout, customSkin, "Content Layout");
|
||||
MUIPEditorHandler.DrawProperty(contentLayoutHelper, customSkin, "Content Layout Helper");
|
||||
break;
|
||||
|
||||
case 2:
|
||||
MUIPEditorHandler.DrawHeader(customSkin, "Customization Header", 6);
|
||||
GUILayout.BeginVertical(EditorStyles.helpBox);
|
||||
GUILayout.Space(-3);
|
||||
enableIcon.boolValue = MUIPEditorHandler.DrawTogglePlain(enableIcon.boolValue, customSkin, "Enable Icon");
|
||||
GUILayout.Space(3);
|
||||
|
||||
if (enableIcon.boolValue == true && hsTarget.labelIcon == null) { EditorGUILayout.HelpBox("'Enable Icon' is enabled but 'Label Icon' is not assigned. Go to Resources tab and assign the correct variable.", MessageType.Error); }
|
||||
else if (enableIcon.boolValue == true && hsTarget.labelIcon != null) { hsTarget.labelIcon.gameObject.SetActive(true); }
|
||||
else if (enableIcon.boolValue == false && hsTarget.labelIcon != null) { hsTarget.labelIcon.gameObject.SetActive(false); }
|
||||
|
||||
GUILayout.EndVertical();
|
||||
GUILayout.BeginVertical(EditorStyles.helpBox);
|
||||
GUILayout.Space(-3);
|
||||
enableIndicators.boolValue = MUIPEditorHandler.DrawTogglePlain(enableIndicators.boolValue, customSkin, "Enable Indicators");
|
||||
GUILayout.Space(3);
|
||||
GUILayout.BeginHorizontal();
|
||||
|
||||
if (enableIndicators.boolValue == true)
|
||||
{
|
||||
if (hsTarget.indicatorObject == null) { EditorGUILayout.HelpBox("'Enable Indicators' is enabled but 'Indicator Object' is not assigned. Go to Resources tab and assign the correct variable.", MessageType.Error); }
|
||||
if (hsTarget.indicatorParent == null) { EditorGUILayout.HelpBox("'Enable Indicators' is enabled but 'Indicator Parent' is not assigned. Go to Resources tab and assign the correct variable.", MessageType.Error); }
|
||||
else { hsTarget.indicatorParent.gameObject.SetActive(true); }
|
||||
}
|
||||
else if (enableIndicators.boolValue == false && hsTarget.indicatorParent != null) { hsTarget.indicatorParent.gameObject.SetActive(false); }
|
||||
|
||||
GUILayout.EndHorizontal();
|
||||
GUILayout.EndVertical();
|
||||
MUIPEditorHandler.DrawProperty(iconScale, customSkin, "Icon Scale");
|
||||
MUIPEditorHandler.DrawProperty(contentSpacing, customSkin, "Content Spacing");
|
||||
hsTarget.UpdateContentLayout();
|
||||
|
||||
MUIPEditorHandler.DrawHeader(customSkin, "Options Header", 10);
|
||||
invokeAtStart.boolValue = MUIPEditorHandler.DrawToggle(invokeAtStart.boolValue, customSkin, "Invoke At Start");
|
||||
invertAnimation.boolValue = MUIPEditorHandler.DrawToggle(invertAnimation.boolValue, customSkin, "Invert Animation");
|
||||
loopSelection.boolValue = MUIPEditorHandler.DrawToggle(loopSelection.boolValue, customSkin, "Loop Selection");
|
||||
GUI.enabled = true;
|
||||
|
||||
GUILayout.BeginVertical(EditorStyles.helpBox);
|
||||
GUILayout.Space(-3);
|
||||
saveSelected.boolValue = MUIPEditorHandler.DrawTogglePlain(saveSelected.boolValue, customSkin, "Save Selected");
|
||||
GUILayout.Space(3);
|
||||
|
||||
if (saveSelected.boolValue == true)
|
||||
{
|
||||
MUIPEditorHandler.DrawPropertyCW(saveKey, customSkin, "Save Key:", 90);
|
||||
EditorGUILayout.HelpBox("Each selector should has its own unique save key.", MessageType.Info);
|
||||
}
|
||||
|
||||
GUILayout.EndVertical();
|
||||
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(MUIPEditorHandler.UIM_SHORTCUT); }
|
||||
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>[Horizontal Selector]</b> Failed to delete UI Manager connection.", this); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else if (tempUIM == null) { MUIPEditorHandler.DrawUIManagerDisconnectedHeader(); }
|
||||
break;
|
||||
}
|
||||
|
||||
if (Application.isPlaying == false) { this.Repaint(); }
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4dc4a3eba298e1c4b851efe79a336cb5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 201717
|
||||
packageName: Modern UI Pack
|
||||
packageVersion: 5.5.28
|
||||
assetPath: Assets/Modern UI Pack/Scripts/Horizontal Selector/HorizontalSelectorEditor.cs
|
||||
uploadId: 778406
|
||||
Reference in New Issue
Block a user