mirror of
https://github.com/GrahamKracker/UnityExplorer.git
synced 2025-07-03 12:02:28 +08:00
Finish GameObject Inspector, start Search page, some other UI changes/fixes
This commit is contained in:
@ -6,12 +6,18 @@ using UnityEngine.UI;
|
||||
|
||||
namespace UnityExplorer.UI.PageModel
|
||||
{
|
||||
// Probably do this after I've made the CacheObjectBase / InteractiveValue classes.
|
||||
// Might not use CacheObject, but InteractiveValue would be useful here.
|
||||
|
||||
// Maybe InteractiveValue could have an OnSetValue event, which CacheObject and this class can subscribe to separately.
|
||||
|
||||
public class OptionsPage : MainMenu.Page
|
||||
{
|
||||
public override string Name => "Options / Misc";
|
||||
public override string Name => "Options";
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
ConstructUI();
|
||||
|
||||
}
|
||||
|
||||
@ -19,5 +25,54 @@ namespace UnityExplorer.UI.PageModel
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#region UI CONSTRUCTION
|
||||
|
||||
internal void ConstructUI()
|
||||
{
|
||||
GameObject parent = MainMenu.Instance.PageViewport;
|
||||
|
||||
Content = UIFactory.CreateHorizontalGroup(parent);
|
||||
var mainGroup = Content.GetComponent<HorizontalLayoutGroup>();
|
||||
mainGroup.padding.left = 4;
|
||||
mainGroup.padding.right = 4;
|
||||
mainGroup.padding.top = 4;
|
||||
mainGroup.padding.bottom = 4;
|
||||
mainGroup.spacing = 5;
|
||||
mainGroup.childForceExpandHeight = true;
|
||||
mainGroup.childForceExpandWidth = true;
|
||||
mainGroup.childControlHeight = true;
|
||||
mainGroup.childControlWidth = true;
|
||||
|
||||
ConstructTopArea();
|
||||
|
||||
}
|
||||
|
||||
internal void ConstructTopArea()
|
||||
{
|
||||
var topAreaObj = UIFactory.CreateVerticalGroup(Content, new Color(0.15f, 0.15f, 0.15f));
|
||||
var topGroup = topAreaObj.GetComponent<VerticalLayoutGroup>();
|
||||
topGroup.childForceExpandHeight = false;
|
||||
topGroup.childControlHeight = true;
|
||||
topGroup.childForceExpandWidth = true;
|
||||
topGroup.childControlWidth = true;
|
||||
topGroup.padding.top = 5;
|
||||
topGroup.padding.left = 5;
|
||||
topGroup.padding.right = 5;
|
||||
topGroup.padding.bottom = 5;
|
||||
topGroup.spacing = 5;
|
||||
|
||||
GameObject titleObj = UIFactory.CreateLabel(Content, TextAnchor.UpperLeft);
|
||||
Text titleLabel = titleObj.GetComponent<Text>();
|
||||
titleLabel.text = "Options";
|
||||
titleLabel.fontSize = 20;
|
||||
LayoutElement titleLayout = titleObj.AddComponent<LayoutElement>();
|
||||
titleLayout.minHeight = 30;
|
||||
titleLayout.flexibleHeight = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,9 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityExplorer.Helpers;
|
||||
using UnityExplorer.Inspectors;
|
||||
using UnityExplorer.UI.Shared;
|
||||
|
||||
namespace UnityExplorer.UI.PageModel
|
||||
{
|
||||
@ -10,14 +13,226 @@ namespace UnityExplorer.UI.PageModel
|
||||
{
|
||||
public override string Name => "Search";
|
||||
|
||||
internal object[] m_results;
|
||||
internal readonly List<object> m_resultShortList = new List<object>();
|
||||
|
||||
private int m_lastCount;
|
||||
public PageHandler m_resultListPageHandler;
|
||||
private GameObject m_resultListContent;
|
||||
private readonly List<Text> m_resultListTexts = new List<Text>();
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
|
||||
ConstructUI();
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
|
||||
//RefreshResultList();
|
||||
}
|
||||
|
||||
internal void OnSearchClicked()
|
||||
{
|
||||
m_results = Resources.FindObjectsOfTypeAll(typeof(UnityEngine.Object));
|
||||
|
||||
RefreshResultList();
|
||||
}
|
||||
|
||||
private void OnResultPageTurn()
|
||||
{
|
||||
RefreshResultList();
|
||||
}
|
||||
|
||||
private void RefreshResultList()
|
||||
{
|
||||
m_resultListPageHandler.ListCount = m_results.Length;
|
||||
|
||||
int newCount = 0;
|
||||
|
||||
foreach (var itemIndex in m_resultListPageHandler)
|
||||
{
|
||||
newCount++;
|
||||
|
||||
// normalized index starting from 0
|
||||
var i = itemIndex - m_resultListPageHandler.StartIndex;
|
||||
|
||||
if (itemIndex >= m_results.Length)
|
||||
{
|
||||
if (i > m_lastCount || i >= m_resultListTexts.Count)
|
||||
break;
|
||||
|
||||
GameObject label = m_resultListTexts[i].transform.parent.parent.gameObject;
|
||||
if (label.activeSelf)
|
||||
label.SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
var obj = m_results[itemIndex];
|
||||
|
||||
if (obj == null || obj is UnityEngine.Object uObj && !uObj)
|
||||
continue;
|
||||
|
||||
if (i >= m_resultShortList.Count)
|
||||
{
|
||||
m_resultShortList.Add(obj);
|
||||
AddResultButton();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_resultShortList[i] = obj;
|
||||
}
|
||||
|
||||
var text = m_resultListTexts[i];
|
||||
|
||||
var name = $"<color={SyntaxColors.Class_Instance}>{ReflectionHelpers.GetActualType(obj).Name}</color>"
|
||||
+ $" ({obj.ToString()})";
|
||||
|
||||
text.text = name;
|
||||
|
||||
var label = text.transform.parent.parent.gameObject;
|
||||
if (!label.activeSelf)
|
||||
label.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
m_lastCount = newCount;
|
||||
}
|
||||
|
||||
#region UI CONSTRUCTION
|
||||
|
||||
internal void ConstructUI()
|
||||
{
|
||||
GameObject parent = MainMenu.Instance.PageViewport;
|
||||
|
||||
Content = UIFactory.CreateVerticalGroup(parent);
|
||||
var mainGroup = Content.GetComponent<VerticalLayoutGroup>();
|
||||
mainGroup.padding.left = 4;
|
||||
mainGroup.padding.right = 4;
|
||||
mainGroup.padding.top = 4;
|
||||
mainGroup.padding.bottom = 4;
|
||||
mainGroup.spacing = 5;
|
||||
mainGroup.childForceExpandHeight = true;
|
||||
mainGroup.childForceExpandWidth = true;
|
||||
mainGroup.childControlHeight = true;
|
||||
mainGroup.childControlWidth = true;
|
||||
|
||||
ConstructTopArea();
|
||||
|
||||
ConstructResultsArea();
|
||||
}
|
||||
|
||||
internal void ConstructTopArea()
|
||||
{
|
||||
var topAreaObj = UIFactory.CreateVerticalGroup(Content, new Color(0.15f, 0.15f, 0.15f));
|
||||
var topGroup = topAreaObj.GetComponent<VerticalLayoutGroup>();
|
||||
topGroup.childForceExpandHeight = false;
|
||||
topGroup.childControlHeight = true;
|
||||
topGroup.childForceExpandWidth = true;
|
||||
topGroup.childControlWidth = true;
|
||||
topGroup.padding.top = 5;
|
||||
topGroup.padding.left = 5;
|
||||
topGroup.padding.right = 5;
|
||||
topGroup.padding.bottom = 5;
|
||||
topGroup.spacing = 5;
|
||||
|
||||
GameObject titleObj = UIFactory.CreateLabel(topAreaObj, TextAnchor.UpperLeft);
|
||||
Text titleLabel = titleObj.GetComponent<Text>();
|
||||
titleLabel.text = "Search";
|
||||
titleLabel.fontSize = 20;
|
||||
LayoutElement titleLayout = titleObj.AddComponent<LayoutElement>();
|
||||
titleLayout.minHeight = 30;
|
||||
titleLayout.flexibleHeight = 0;
|
||||
|
||||
// top area options
|
||||
|
||||
var tempObj = UIFactory.CreateLabel(topAreaObj, TextAnchor.MiddleLeft);
|
||||
var tempText = tempObj.GetComponent<Text>();
|
||||
tempText.text = "TODO Options / Filters";
|
||||
|
||||
var testBtnObj = UIFactory.CreateButton(topAreaObj);
|
||||
var testText = testBtnObj.GetComponentInChildren<Text>();
|
||||
testText.text = "Search";
|
||||
LayoutElement searchBtnLayout = testBtnObj.AddComponent<LayoutElement>();
|
||||
searchBtnLayout.minHeight = 30;
|
||||
searchBtnLayout.flexibleHeight = 0;
|
||||
var testBtn = testBtnObj.GetComponent<Button>();
|
||||
#if MONO
|
||||
testBtn.onClick.AddListener(OnSearchClicked);
|
||||
#else
|
||||
testBtn.onClick.AddListener(new Action(OnSearchClicked));
|
||||
#endif
|
||||
}
|
||||
|
||||
internal void ConstructResultsArea()
|
||||
{
|
||||
// Result group holder (NOT actual result list content)
|
||||
|
||||
var resultGroupObj = UIFactory.CreateVerticalGroup(Content, new Color(0.1f, 0.1f, 0.1f));
|
||||
var resultGroup = resultGroupObj.GetComponent<VerticalLayoutGroup>();
|
||||
resultGroup.childForceExpandHeight = false;
|
||||
resultGroup.childForceExpandWidth = true;
|
||||
resultGroup.childControlHeight = true;
|
||||
resultGroup.childControlWidth = true;
|
||||
resultGroup.spacing = 5;
|
||||
resultGroup.padding.top = 5;
|
||||
resultGroup.padding.right = 5;
|
||||
resultGroup.padding.left = 5;
|
||||
resultGroup.padding.bottom = 5;
|
||||
|
||||
m_resultListPageHandler = new PageHandler();
|
||||
m_resultListPageHandler.ConstructUI(resultGroupObj);
|
||||
m_resultListPageHandler.OnPageChanged += OnResultPageTurn;
|
||||
|
||||
GameObject scrollObj = UIFactory.CreateScrollView(resultGroupObj, out m_resultListContent, new Color(0.15f, 0.15f, 0.15f));
|
||||
|
||||
// actual result list content
|
||||
var contentGroup = m_resultListContent.GetComponent<VerticalLayoutGroup>();
|
||||
contentGroup.spacing = 2;
|
||||
}
|
||||
|
||||
internal void AddResultButton()
|
||||
{
|
||||
int thisIndex = m_resultListTexts.Count();
|
||||
|
||||
GameObject btnGroupObj = UIFactory.CreateHorizontalGroup(m_resultListContent, new Color(0.1f, 0.1f, 0.1f));
|
||||
HorizontalLayoutGroup btnGroup = btnGroupObj.GetComponent<HorizontalLayoutGroup>();
|
||||
btnGroup.childForceExpandWidth = true;
|
||||
btnGroup.childControlWidth = true;
|
||||
btnGroup.childForceExpandHeight = false;
|
||||
btnGroup.childControlHeight = true;
|
||||
btnGroup.padding.top = 3;
|
||||
btnGroup.padding.left = 3;
|
||||
btnGroup.padding.right = 3;
|
||||
btnGroup.padding.bottom = 3;
|
||||
LayoutElement btnLayout = btnGroupObj.AddComponent<LayoutElement>();
|
||||
btnLayout.flexibleWidth = 320;
|
||||
btnLayout.minHeight = 25;
|
||||
btnLayout.flexibleHeight = 0;
|
||||
btnGroupObj.AddComponent<Mask>();
|
||||
|
||||
GameObject mainButtonObj = UIFactory.CreateButton(btnGroupObj);
|
||||
LayoutElement mainBtnLayout = mainButtonObj.AddComponent<LayoutElement>();
|
||||
mainBtnLayout.minHeight = 25;
|
||||
mainBtnLayout.flexibleHeight = 0;
|
||||
mainBtnLayout.minWidth = 230;
|
||||
mainBtnLayout.flexibleWidth = 0;
|
||||
Button mainBtn = mainButtonObj.GetComponent<Button>();
|
||||
ColorBlock mainColors = mainBtn.colors;
|
||||
mainColors.normalColor = new Color(0.1f, 0.1f, 0.1f);
|
||||
mainColors.highlightedColor = new Color(0.2f, 0.2f, 0.2f, 1);
|
||||
mainBtn.colors = mainColors;
|
||||
#if CPP
|
||||
mainBtn.onClick.AddListener(new Action(() => { SceneListObjectClicked(thisIndex); }));
|
||||
#else
|
||||
mainBtn.onClick.AddListener(() => { InspectorManager.Instance.Inspect(m_resultShortList[thisIndex]); });
|
||||
#endif
|
||||
|
||||
Text mainText = mainButtonObj.GetComponentInChildren<Text>();
|
||||
mainText.alignment = TextAnchor.MiddleLeft;
|
||||
mainText.horizontalOverflow = HorizontalWrapMode.Overflow;
|
||||
m_resultListTexts.Add(mainText);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ namespace UnityExplorer.UI
|
||||
public void OnEndDrag()
|
||||
{
|
||||
WasDragging = false;
|
||||
UpdateResizeCache();
|
||||
//UpdateResizeCache();
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -131,6 +131,8 @@ namespace UnityExplorer.UI
|
||||
|
||||
private const int RESIZE_THICKNESS = 10;
|
||||
|
||||
private readonly Vector2 minResize = new Vector2(733, 542);
|
||||
|
||||
private bool WasResizing { get; set; }
|
||||
private ResizeTypes m_currentResizeType = ResizeTypes.NONE;
|
||||
private Vector2 m_lastResizePos;
|
||||
@ -287,35 +289,40 @@ namespace UnityExplorer.UI
|
||||
{
|
||||
Vector3 mousePos = InputManager.MousePosition;
|
||||
Vector2 diff = m_lastResizePos - (Vector2)mousePos;
|
||||
|
||||
if ((Vector2)mousePos == m_lastResizePos)
|
||||
return;
|
||||
|
||||
m_lastResizePos = mousePos;
|
||||
|
||||
float diffX = (float)((decimal)diff.x / Screen.width);
|
||||
float diffY = (float)((decimal)diff.y / Screen.height);
|
||||
|
||||
Vector2 anchorMin = Panel.anchorMin;
|
||||
Vector2 anchorMax = Panel.anchorMax;
|
||||
|
||||
if (m_currentResizeType.HasFlag(ResizeTypes.Left))
|
||||
{
|
||||
Vector2 anch = Panel.anchorMin;
|
||||
anch.x -= diffX;
|
||||
Panel.anchorMin = anch;
|
||||
}
|
||||
anchorMin.x -= diffX;
|
||||
else if (m_currentResizeType.HasFlag(ResizeTypes.Right))
|
||||
{
|
||||
Vector2 anch = Panel.anchorMax;
|
||||
anch.x -= diffX;
|
||||
Panel.anchorMax = anch;
|
||||
}
|
||||
anchorMax.x -= diffX;
|
||||
|
||||
if (m_currentResizeType.HasFlag(ResizeTypes.Top))
|
||||
{
|
||||
Vector2 anch = Panel.anchorMax;
|
||||
anch.y -= diffY;
|
||||
Panel.anchorMax = anch;
|
||||
}
|
||||
anchorMax.y -= diffY;
|
||||
else if (m_currentResizeType.HasFlag(ResizeTypes.Bottom))
|
||||
anchorMin.y -= diffY;
|
||||
|
||||
var newWidth = (anchorMax.x - anchorMin.x) * Screen.width;
|
||||
var newHeight = (anchorMax.y - anchorMin.y) * Screen.height;
|
||||
|
||||
if (newWidth >= minResize.x)
|
||||
{
|
||||
Vector2 anch = Panel.anchorMin;
|
||||
anch.y -= diffY;
|
||||
Panel.anchorMin = anch;
|
||||
Panel.anchorMin = new Vector2(anchorMin.x, Panel.anchorMin.y);
|
||||
Panel.anchorMax = new Vector2(anchorMax.x, Panel.anchorMax.y);
|
||||
}
|
||||
if (newHeight >= minResize.y)
|
||||
{
|
||||
Panel.anchorMin = new Vector2(Panel.anchorMin.x, anchorMin.y);
|
||||
Panel.anchorMax = new Vector2(Panel.anchorMax.x, anchorMax.y);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -149,17 +149,17 @@ namespace UnityExplorer.UI.Shared
|
||||
Image image = m_pageUIHolder.GetComponent<Image>();
|
||||
image.color = new Color(0f, 0f, 0f, 0f);
|
||||
|
||||
HorizontalLayoutGroup parentGroup = m_pageUIHolder.GetComponent<HorizontalLayoutGroup>();
|
||||
parentGroup.childForceExpandHeight = true;
|
||||
parentGroup.childForceExpandWidth = false;
|
||||
parentGroup.childControlWidth = true;
|
||||
parentGroup.childControlHeight = true;
|
||||
HorizontalLayoutGroup mainGroup = m_pageUIHolder.GetComponent<HorizontalLayoutGroup>();
|
||||
mainGroup.childForceExpandHeight = true;
|
||||
mainGroup.childForceExpandWidth = false;
|
||||
mainGroup.childControlWidth = true;
|
||||
mainGroup.childControlHeight = true;
|
||||
|
||||
LayoutElement parentLayout = m_pageUIHolder.AddComponent<LayoutElement>();
|
||||
parentLayout.minHeight = 20;
|
||||
parentLayout.flexibleHeight = 0;
|
||||
parentLayout.minWidth = 200;
|
||||
parentLayout.flexibleWidth = 30;
|
||||
LayoutElement mainLayout = m_pageUIHolder.AddComponent<LayoutElement>();
|
||||
mainLayout.minHeight = 20;
|
||||
mainLayout.flexibleHeight = 0;
|
||||
mainLayout.minWidth = 100;
|
||||
mainLayout.flexibleWidth = 30;
|
||||
|
||||
GameObject leftBtnObj = UIFactory.CreateButton(m_pageUIHolder);
|
||||
Button leftBtn = leftBtnObj.GetComponent<Button>();
|
||||
@ -169,19 +169,19 @@ namespace UnityExplorer.UI.Shared
|
||||
leftBtn.onClick.AddListener(() => { TurnPage(Turn.Left); });
|
||||
#endif
|
||||
Text leftBtnText = leftBtnObj.GetComponentInChildren<Text>();
|
||||
leftBtnText.text = "<";
|
||||
leftBtnText.text = "◄";
|
||||
LayoutElement leftBtnLayout = leftBtnObj.AddComponent<LayoutElement>();
|
||||
leftBtnLayout.flexibleHeight = 0;
|
||||
leftBtnLayout.flexibleWidth = 0;
|
||||
leftBtnLayout.minWidth = 40;
|
||||
leftBtnLayout.minWidth = 30;
|
||||
leftBtnLayout.minHeight = 20;
|
||||
|
||||
GameObject labelObj = UIFactory.CreateLabel(m_pageUIHolder, TextAnchor.MiddleCenter);
|
||||
m_currentPageLabel = labelObj.GetComponent<Text>();
|
||||
m_currentPageLabel.text = "Page 1 / TODO";
|
||||
LayoutElement textLayout = labelObj.AddComponent<LayoutElement>();
|
||||
textLayout.flexibleWidth = 1.5f;
|
||||
textLayout.preferredWidth = 120;
|
||||
textLayout.minWidth = 60f;
|
||||
textLayout.flexibleWidth = 5000f;
|
||||
|
||||
GameObject rightBtnObj = UIFactory.CreateButton(m_pageUIHolder);
|
||||
Button rightBtn = rightBtnObj.GetComponent<Button>();
|
||||
@ -191,11 +191,11 @@ namespace UnityExplorer.UI.Shared
|
||||
rightBtn.onClick.AddListener(() => { TurnPage(Turn.Right); });
|
||||
#endif
|
||||
Text rightBtnText = rightBtnObj.GetComponentInChildren<Text>();
|
||||
rightBtnText.text = ">";
|
||||
rightBtnText.text = "►";
|
||||
LayoutElement rightBtnLayout = rightBtnObj.AddComponent<LayoutElement>();
|
||||
rightBtnLayout.flexibleHeight = 0;
|
||||
rightBtnLayout.flexibleWidth = 0;
|
||||
rightBtnLayout.minWidth = 40;
|
||||
rightBtnLayout.minWidth = 30;
|
||||
rightBtnLayout.minHeight = 20;
|
||||
|
||||
ListCount = 0;
|
||||
|
103
src/UI/Shared/SliderScrollbar.cs
Normal file
103
src/UI/Shared/SliderScrollbar.cs
Normal file
@ -0,0 +1,103 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.UI;
|
||||
using UnityExplorer;
|
||||
using UnityExplorer.Helpers;
|
||||
|
||||
// Basically just to fix an issue with Scrollbars, instead we use a Slider as the scrollbar.
|
||||
// This class contains only what is needed to update and manage one after creation.
|
||||
public class SliderScrollbar
|
||||
{
|
||||
internal static readonly List<SliderScrollbar> Instances = new List<SliderScrollbar>();
|
||||
|
||||
internal readonly Scrollbar m_scrollbar;
|
||||
internal readonly Slider m_slider;
|
||||
|
||||
public SliderScrollbar(Scrollbar scrollbar, Slider slider)
|
||||
{
|
||||
Instances.Add(this);
|
||||
|
||||
this.m_scrollbar = scrollbar;
|
||||
this.m_slider = slider;
|
||||
|
||||
#if MONO
|
||||
this.m_scrollbar.onValueChanged.AddListener(this.OnScrollbarValueChanged);
|
||||
this.m_slider.onValueChanged.AddListener(this.OnSliderValueChanged);
|
||||
#else
|
||||
this.m_scrollbar.onValueChanged.AddListener(new Action<float>(this.OnScrollbarValueChanged));
|
||||
this.m_slider.onValueChanged.AddListener(new Action<float>(this.OnSliderValueChanged));
|
||||
#endif
|
||||
|
||||
this.RefreshVisibility();
|
||||
this.m_slider.Set(1f, false);
|
||||
}
|
||||
|
||||
internal void Update()
|
||||
{
|
||||
this.RefreshVisibility();
|
||||
}
|
||||
|
||||
internal void RefreshVisibility()
|
||||
{
|
||||
if (this.m_slider && this.m_scrollbar)
|
||||
{
|
||||
bool shouldShow = !Mathf.Approximately(this.m_scrollbar.size, 1);
|
||||
var obj = this.m_slider.handleRect.gameObject;
|
||||
|
||||
if (obj.activeSelf != shouldShow)
|
||||
{
|
||||
obj.SetActive(shouldShow);
|
||||
|
||||
if (shouldShow)
|
||||
this.m_slider.Set(this.m_scrollbar.value, false);
|
||||
else
|
||||
m_slider.Set(1f, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OnScrollbarValueChanged(float _value)
|
||||
{
|
||||
//this.RefreshVisibility();
|
||||
if (this.m_slider && this.m_slider.value != _value)
|
||||
{
|
||||
this.m_slider.Set(_value, false);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnSliderValueChanged(float _value)
|
||||
{
|
||||
if (this.m_scrollbar)
|
||||
{
|
||||
this.m_scrollbar.value = _value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if MONO
|
||||
public static class SliderExtensions
|
||||
{
|
||||
// il2cpp can just use the orig method directly (forced public)
|
||||
|
||||
private static MethodInfo m_setMethod;
|
||||
private static MethodInfo SetMethod
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_setMethod == null)
|
||||
{
|
||||
m_setMethod = typeof(Slider).GetMethod("Set", ReflectionHelpers.CommonFlags, null, new[] { typeof(float), typeof(bool) }, null);
|
||||
}
|
||||
return m_setMethod;
|
||||
}
|
||||
}
|
||||
|
||||
public static void Set(this Slider slider, float value, bool invokeCallback)
|
||||
{
|
||||
SetMethod.Invoke(slider, new object[] { value, invokeCallback });
|
||||
}
|
||||
}
|
||||
#endif
|
@ -222,7 +222,7 @@ namespace UnityExplorer.UI
|
||||
return labelObj;
|
||||
}
|
||||
|
||||
public static GameObject CreateButton(GameObject parent)
|
||||
public static GameObject CreateButton(GameObject parent, Color normalColor = default)
|
||||
{
|
||||
GameObject buttonObj = CreateUIObject("Button", parent, thinSize);
|
||||
|
||||
@ -236,6 +236,14 @@ namespace UnityExplorer.UI
|
||||
|
||||
SetDefaultColorTransitionValues(buttonObj.AddComponent<Button>());
|
||||
|
||||
if (normalColor != default)
|
||||
{
|
||||
var btn = buttonObj.GetComponent<Button>();
|
||||
var colors = btn.colors;
|
||||
colors.normalColor = normalColor;
|
||||
btn.colors = colors;
|
||||
}
|
||||
|
||||
Text text = textObj.AddComponent<Text>();
|
||||
text.text = "Button";
|
||||
SetDefaultTextValues(text);
|
||||
@ -249,6 +257,74 @@ namespace UnityExplorer.UI
|
||||
return buttonObj;
|
||||
}
|
||||
|
||||
//public static GameObject CreateSlider(GameObject parent)
|
||||
//{
|
||||
// GameObject sliderObj = CreateUIObject("Slider", parent, thinSize);
|
||||
|
||||
// GameObject bgObj = CreateUIObject("Background", sliderObj);
|
||||
// GameObject fillAreaObj = CreateUIObject("Fill Area", sliderObj);
|
||||
// GameObject fillObj = CreateUIObject("Fill", fillAreaObj);
|
||||
// GameObject handleSlideAreaObj = CreateUIObject("Handle Slide Area", sliderObj);
|
||||
// GameObject handleObj = CreateUIObject("Handle", handleSlideAreaObj);
|
||||
|
||||
// Image bgImage = bgObj.AddComponent<Image>();
|
||||
// bgImage.type = Image.Type.Sliced;
|
||||
// bgImage.color = new Color(0.15f, 0.15f, 0.15f, 1.0f);
|
||||
|
||||
// RectTransform bgRect = bgObj.GetComponent<RectTransform>();
|
||||
// bgRect.anchorMin = new Vector2(0f, dynamic ? 0f : 0.25f);
|
||||
// bgRect.anchorMax = new Vector2(1f, dynamic ? 1f : 0.75f);
|
||||
// bgRect.sizeDelta = new Vector2(0f, 0f);
|
||||
|
||||
// RectTransform fillAreaRect = fillAreaObj.GetComponent<RectTransform>();
|
||||
// fillAreaRect.anchorMin = new Vector2(0f, 0.25f);
|
||||
// fillAreaRect.anchorMax = new Vector2(1f, 0.75f);
|
||||
// fillAreaRect.anchoredPosition = new Vector2(-5f, 0f);
|
||||
// fillAreaRect.sizeDelta = new Vector2(-20f, 0f);
|
||||
|
||||
// Image fillImage = fillObj.AddComponent<Image>();
|
||||
// fillImage.type = Image.Type.Sliced;
|
||||
// fillImage.color = dynamic ? Color.clear : new Color(0.3f, 0.3f, 0.3f, 1.0f);
|
||||
|
||||
// fillObj.GetComponent<RectTransform>().sizeDelta = new Vector2(10f, 0f);
|
||||
|
||||
// RectTransform handleSlideRect = handleSlideAreaObj.GetComponent<RectTransform>();
|
||||
// handleSlideRect.anchorMin = new Vector2(0f, 0f);
|
||||
// handleSlideRect.anchorMax = new Vector2(1f, 1f);
|
||||
// handleSlideRect.offsetMin = new Vector2(15f, 20f);
|
||||
// handleSlideRect.offsetMax = new Vector2(-15f, 0f);
|
||||
// handleSlideRect.sizeDelta = new Vector2(dynamic ? -30f : -20f, 0f);
|
||||
|
||||
// Image handleImage = handleObj.AddComponent<Image>();
|
||||
// handleImage.color = new Color(0.5f, 0.5f, 0.5f, 1.0f);
|
||||
|
||||
// var handleRect = handleObj.GetComponent<RectTransform>();
|
||||
// handleRect.sizeDelta = new Vector2(dynamic ? 25f : 20f, dynamic ? 25f : 0f);
|
||||
|
||||
// if (dynamic)
|
||||
// {
|
||||
// handleRect.offsetMin = new Vector2(-15f, -20f);
|
||||
// handleRect.offsetMax = Vector2.zero;
|
||||
|
||||
// var sliderBarLayout = sliderObj.AddComponent<LayoutElement>();
|
||||
// sliderBarLayout.minWidth = 25;
|
||||
// sliderBarLayout.flexibleWidth = 0;
|
||||
// sliderBarLayout.minHeight = 25;
|
||||
// sliderBarLayout.flexibleHeight = 5000;
|
||||
|
||||
// bgRect.offsetMax = new Vector2(-15f, 0f);
|
||||
// }
|
||||
|
||||
// Slider slider = sliderObj.AddComponent<Slider>();
|
||||
// slider.fillRect = fillObj.GetComponent<RectTransform>();
|
||||
// slider.handleRect = handleObj.GetComponent<RectTransform>();
|
||||
// slider.targetGraphic = handleImage;
|
||||
// slider.direction = dynamic ? Slider.Direction.BottomToTop : Slider.Direction.LeftToRight;
|
||||
// SetDefaultColorTransitionValues(slider);
|
||||
|
||||
// return sliderObj;
|
||||
//}
|
||||
|
||||
public static GameObject CreateSlider(GameObject parent)
|
||||
{
|
||||
GameObject sliderObj = CreateUIObject("Slider", parent, thinSize);
|
||||
@ -611,14 +687,14 @@ namespace UnityExplorer.UI
|
||||
dropdown.captionText = labelText;
|
||||
dropdown.itemText = itemLabelText;
|
||||
itemLabelText.text = "1";
|
||||
dropdown.options.Add(new Dropdown.OptionData
|
||||
{
|
||||
text = "2"
|
||||
});
|
||||
dropdown.options.Add(new Dropdown.OptionData
|
||||
{
|
||||
text = "3"
|
||||
});
|
||||
//dropdown.options.Add(new Dropdown.OptionData
|
||||
//{
|
||||
// text = "2"
|
||||
//});
|
||||
//dropdown.options.Add(new Dropdown.OptionData
|
||||
//{
|
||||
// text = "3"
|
||||
//});
|
||||
|
||||
dropdown.RefreshShownValue();
|
||||
|
||||
@ -670,91 +746,245 @@ namespace UnityExplorer.UI
|
||||
|
||||
public static GameObject CreateScrollView(GameObject parent, out GameObject content, Color color = default)
|
||||
{
|
||||
GameObject scrollObj = CreateUIObject("Scroll View", parent);
|
||||
GameObject mainObj = CreateUIObject("DynamicScrollView", parent);
|
||||
|
||||
LayoutElement mainLayout = scrollObj.AddComponent<LayoutElement>();
|
||||
mainLayout.flexibleWidth = 999;
|
||||
mainLayout.flexibleHeight = 999;
|
||||
mainLayout.preferredHeight = 200;
|
||||
mainLayout.preferredWidth = 200;
|
||||
var mainLayout = mainObj.AddComponent<LayoutElement>();
|
||||
mainLayout.minWidth = 100;
|
||||
mainLayout.minHeight = 100;
|
||||
mainLayout.flexibleWidth = 5000;
|
||||
mainLayout.flexibleHeight = 5000;
|
||||
|
||||
GameObject viewportObj = CreateUIObject("Viewport", scrollObj);
|
||||
Image mainImage = mainObj.AddComponent<Image>();
|
||||
mainImage.type = Image.Type.Filled;
|
||||
mainImage.color = (color == default) ? new Color(0.3f, 0.3f, 0.3f, 1f) : color;
|
||||
|
||||
VerticalLayoutGroup viewportGroup = viewportObj.AddComponent<VerticalLayoutGroup>();
|
||||
viewportGroup.childControlHeight = true;
|
||||
viewportGroup.childControlWidth = true;
|
||||
viewportGroup.childForceExpandHeight = true;
|
||||
viewportGroup.childForceExpandWidth = true;
|
||||
GameObject viewportObj = CreateUIObject("Viewport", mainObj);
|
||||
|
||||
content = CreateUIObject("Content", viewportObj);
|
||||
|
||||
VerticalLayoutGroup contentGroup = content.AddComponent<VerticalLayoutGroup>();
|
||||
contentGroup.padding.left = 5;
|
||||
contentGroup.padding.right = 5;
|
||||
contentGroup.padding.top = 5;
|
||||
contentGroup.padding.bottom = 5;
|
||||
contentGroup.childControlHeight = false;
|
||||
contentGroup.childControlWidth = true;
|
||||
contentGroup.childForceExpandHeight = false;
|
||||
contentGroup.childForceExpandWidth = true;
|
||||
|
||||
GameObject horiScroll = CreateScrollbar(scrollObj);
|
||||
horiScroll.name = "Scrollbar Horizontal";
|
||||
SetParentAndAlign(horiScroll, scrollObj);
|
||||
|
||||
RectTransform horiRect = horiScroll.GetComponent<RectTransform>();
|
||||
horiRect.anchorMin = Vector2.zero;
|
||||
horiRect.anchorMax = Vector2.right;
|
||||
horiRect.pivot = Vector2.zero;
|
||||
horiRect.sizeDelta = new Vector2(0f, horiRect.sizeDelta.y);
|
||||
|
||||
GameObject vertScroll = CreateScrollbar(scrollObj);
|
||||
vertScroll.name = "Scrollbar Vertical";
|
||||
SetParentAndAlign(vertScroll, scrollObj);
|
||||
vertScroll.GetComponent<Scrollbar>().SetDirection(Scrollbar.Direction.BottomToTop, true);
|
||||
|
||||
RectTransform vertRect = vertScroll.GetComponent<RectTransform>();
|
||||
vertRect.anchorMin = Vector2.right;
|
||||
vertRect.anchorMax = Vector2.one;
|
||||
vertRect.pivot = Vector2.one;
|
||||
vertRect.sizeDelta = new Vector2(vertRect.sizeDelta.x, 0f);
|
||||
|
||||
RectTransform viewportRect = viewportObj.GetComponent<RectTransform>();
|
||||
var viewportRect = viewportObj.GetComponent<RectTransform>();
|
||||
viewportRect.anchorMin = Vector2.zero;
|
||||
viewportRect.anchorMax = Vector2.one;
|
||||
viewportRect.sizeDelta = Vector2.zero;
|
||||
viewportRect.pivot = Vector2.up;
|
||||
viewportRect.pivot = new Vector2(0.0f, 1.0f);
|
||||
viewportRect.sizeDelta = new Vector2(-15.0f, 0.0f);
|
||||
viewportRect.offsetMax = new Vector2(-20.0f, 0.0f);
|
||||
|
||||
RectTransform contentRect = content.GetComponent<RectTransform>();
|
||||
contentRect.anchorMin = Vector2.up;
|
||||
contentRect.anchorMax = Vector2.one;
|
||||
contentRect.pivot = Vector2.up;
|
||||
viewportObj.AddComponent<Image>().color = Color.white;
|
||||
viewportObj.AddComponent<Mask>().showMaskGraphic = false;
|
||||
|
||||
ScrollRect scrollRect = scrollObj.AddComponent<ScrollRect>();
|
||||
scrollRect.content = contentRect;
|
||||
scrollRect.viewport = viewportRect;
|
||||
scrollRect.horizontalScrollbar = horiScroll.GetComponent<Scrollbar>();
|
||||
scrollRect.verticalScrollbar = vertScroll.GetComponent<Scrollbar>();
|
||||
scrollRect.horizontalScrollbarVisibility = ScrollRect.ScrollbarVisibility.AutoHideAndExpandViewport;
|
||||
scrollRect.verticalScrollbarVisibility = ScrollRect.ScrollbarVisibility.AutoHideAndExpandViewport;
|
||||
scrollRect.horizontalScrollbarSpacing = -3f;
|
||||
scrollRect.verticalScrollbarSpacing = -3f;
|
||||
content = CreateUIObject("Content", viewportObj);
|
||||
var contentRect = content.GetComponent<RectTransform>();
|
||||
contentRect.anchorMin = new Vector2(0.0f, 1.0f);
|
||||
contentRect.anchorMax = new Vector2(1.0f, 1.0f);
|
||||
contentRect.pivot = new Vector2(0.0f, 1.0f);
|
||||
contentRect.sizeDelta = new Vector2(5f, 0f);
|
||||
contentRect.offsetMax = new Vector2(0f, 0f);
|
||||
var contentFitter = content.AddComponent<ContentSizeFitter>();
|
||||
contentFitter.horizontalFit = ContentSizeFitter.FitMode.Unconstrained;
|
||||
contentFitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize;
|
||||
|
||||
var contentLayout = content.AddComponent<VerticalLayoutGroup>();
|
||||
contentLayout.childForceExpandHeight = true;
|
||||
contentLayout.childControlHeight = true;
|
||||
contentLayout.childForceExpandWidth = true;
|
||||
contentLayout.childControlWidth = true;
|
||||
contentLayout.padding.left = 5;
|
||||
contentLayout.padding.right = 5;
|
||||
contentLayout.padding.top = 5;
|
||||
contentLayout.padding.bottom = 5;
|
||||
contentLayout.spacing = 5;
|
||||
|
||||
GameObject scrollBar = CreateUIObject("DynamicScrollbar", mainObj);
|
||||
|
||||
var scrollbarLayout = scrollBar.AddComponent<VerticalLayoutGroup>();
|
||||
scrollbarLayout.childForceExpandHeight = true;
|
||||
scrollbarLayout.childControlHeight = true;
|
||||
|
||||
RectTransform scrollBarRect = scrollBar.GetComponent<RectTransform>();
|
||||
scrollBarRect.anchorMin = new Vector2(1.0f, 0.0f);
|
||||
scrollBarRect.anchorMax = new Vector2(1.0f, 1.0f);
|
||||
scrollBarRect.sizeDelta = new Vector2(15.0f, 0.0f);
|
||||
scrollBarRect.offsetMin = new Vector2(-15.0f, 0.0f);
|
||||
|
||||
GameObject hiddenBar = CreateScrollbar(scrollBar);
|
||||
var hiddenScroll = hiddenBar.GetComponent<Scrollbar>();
|
||||
hiddenScroll.SetDirection(Scrollbar.Direction.BottomToTop, true);
|
||||
|
||||
for (int i = 0; i < hiddenBar.transform.childCount; i++)
|
||||
{
|
||||
var child = hiddenBar.transform.GetChild(i);
|
||||
child.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
CreateScrollSlider(scrollBar, out Slider scrollSlider);
|
||||
|
||||
// Back to the main scrollview ScrollRect, setting it up now that we have all references.
|
||||
|
||||
var scrollRect = mainObj.AddComponent<ScrollRect>();
|
||||
scrollRect.horizontal = false;
|
||||
scrollRect.vertical = true;
|
||||
scrollRect.verticalScrollbar = hiddenScroll;
|
||||
scrollRect.movementType = ScrollRect.MovementType.Clamped;
|
||||
scrollRect.scrollSensitivity = 25;
|
||||
scrollRect.horizontalScrollbarVisibility = ScrollRect.ScrollbarVisibility.AutoHideAndExpandViewport;
|
||||
scrollRect.verticalScrollbarVisibility = ScrollRect.ScrollbarVisibility.Permanent;
|
||||
|
||||
Image scrollImage = scrollObj.AddComponent<Image>();
|
||||
scrollImage.type = Image.Type.Filled;
|
||||
scrollRect.viewport = viewportRect;
|
||||
scrollRect.content = contentRect;
|
||||
|
||||
scrollImage.color = (color == default) ? new Color(0.3f, 0.3f, 0.3f, 1f) : color;
|
||||
// Create a custom DynamicScrollbar module
|
||||
new SliderScrollbar(hiddenScroll, scrollSlider);
|
||||
|
||||
Image viewportImage = viewportObj.AddComponent<Image>();
|
||||
//viewportImage.sprite = Theme.mask;
|
||||
viewportImage.type = Image.Type.Sliced;
|
||||
viewportImage.color = new Color(1, 1, 1, 1);
|
||||
|
||||
Mask mask = viewportObj.AddComponent<Mask>();
|
||||
mask.showMaskGraphic = false;
|
||||
|
||||
return scrollObj;
|
||||
return mainObj;
|
||||
}
|
||||
|
||||
public static GameObject CreateScrollSlider(GameObject parent, out Slider slider)
|
||||
{
|
||||
GameObject sliderObj = CreateUIObject("Slider", parent, thinSize);
|
||||
|
||||
GameObject bgObj = CreateUIObject("Background", sliderObj);
|
||||
GameObject fillAreaObj = CreateUIObject("Fill Area", sliderObj);
|
||||
GameObject fillObj = CreateUIObject("Fill", fillAreaObj);
|
||||
GameObject handleSlideAreaObj = CreateUIObject("Handle Slide Area", sliderObj);
|
||||
GameObject handleObj = CreateUIObject("Handle", handleSlideAreaObj);
|
||||
|
||||
Image bgImage = bgObj.AddComponent<Image>();
|
||||
bgImage.type = Image.Type.Sliced;
|
||||
bgImage.color = new Color(0.05f, 0.05f, 0.05f, 1.0f);
|
||||
|
||||
RectTransform bgRect = bgObj.GetComponent<RectTransform>();
|
||||
bgRect.anchorMin = Vector2.zero;
|
||||
bgRect.anchorMax = Vector2.one;
|
||||
bgRect.sizeDelta = Vector2.zero;
|
||||
bgRect.offsetMax = new Vector2(-10f, 0f);
|
||||
|
||||
RectTransform fillAreaRect = fillAreaObj.GetComponent<RectTransform>();
|
||||
fillAreaRect.anchorMin = new Vector2(0f, 0.25f);
|
||||
fillAreaRect.anchorMax = new Vector2(1f, 0.75f);
|
||||
fillAreaRect.anchoredPosition = new Vector2(-5f, 0f);
|
||||
fillAreaRect.sizeDelta = new Vector2(-20f, 0f);
|
||||
|
||||
Image fillImage = fillObj.AddComponent<Image>();
|
||||
fillImage.type = Image.Type.Sliced;
|
||||
fillImage.color = Color.clear;
|
||||
|
||||
fillObj.GetComponent<RectTransform>().sizeDelta = new Vector2(10f, 0f);
|
||||
|
||||
RectTransform handleSlideRect = handleSlideAreaObj.GetComponent<RectTransform>();
|
||||
handleSlideRect.anchorMin = new Vector2(0f, 0f);
|
||||
handleSlideRect.anchorMax = new Vector2(1f, 1f);
|
||||
handleSlideRect.offsetMin = new Vector2(15f, 25f);
|
||||
handleSlideRect.offsetMax = new Vector2(-15f, 0f);
|
||||
handleSlideRect.sizeDelta = new Vector2(-30f, -25f);
|
||||
|
||||
Image handleImage = handleObj.AddComponent<Image>();
|
||||
handleImage.color = new Color(0.5f, 0.5f, 0.5f, 1.0f);
|
||||
|
||||
var handleRect = handleObj.GetComponent<RectTransform>();
|
||||
handleRect.sizeDelta = new Vector2(15f, 25f);
|
||||
handleRect.offsetMin = new Vector2(-13f, -23f);
|
||||
handleRect.offsetMax = new Vector2(3f, -2f);
|
||||
|
||||
var sliderBarLayout = sliderObj.AddComponent<LayoutElement>();
|
||||
sliderBarLayout.minWidth = 25;
|
||||
sliderBarLayout.flexibleWidth = 0;
|
||||
sliderBarLayout.minHeight = 25;
|
||||
sliderBarLayout.flexibleHeight = 5000;
|
||||
|
||||
slider = sliderObj.AddComponent<Slider>();
|
||||
slider.fillRect = fillObj.GetComponent<RectTransform>();
|
||||
slider.handleRect = handleObj.GetComponent<RectTransform>();
|
||||
slider.targetGraphic = handleImage;
|
||||
slider.direction = Slider.Direction.BottomToTop;
|
||||
SetDefaultColorTransitionValues(slider);
|
||||
|
||||
return sliderObj;
|
||||
}
|
||||
|
||||
//public static GameObject CreateScrollView(GameObject parent, out GameObject content, Color color = default)
|
||||
//{
|
||||
// GameObject scrollObj = CreateUIObject("Scroll View", parent);
|
||||
|
||||
// LayoutElement mainLayout = scrollObj.AddComponent<LayoutElement>();
|
||||
// mainLayout.flexibleWidth = 999;
|
||||
// mainLayout.flexibleHeight = 999;
|
||||
// mainLayout.preferredHeight = 200;
|
||||
// mainLayout.preferredWidth = 200;
|
||||
|
||||
// GameObject viewportObj = CreateUIObject("Viewport", scrollObj);
|
||||
|
||||
// VerticalLayoutGroup viewportGroup = viewportObj.AddComponent<VerticalLayoutGroup>();
|
||||
// viewportGroup.childControlHeight = true;
|
||||
// viewportGroup.childControlWidth = true;
|
||||
// viewportGroup.childForceExpandHeight = true;
|
||||
// viewportGroup.childForceExpandWidth = true;
|
||||
|
||||
// content = CreateUIObject("Content", viewportObj);
|
||||
|
||||
// VerticalLayoutGroup contentGroup = content.AddComponent<VerticalLayoutGroup>();
|
||||
// contentGroup.padding.left = 5;
|
||||
// contentGroup.padding.right = 5;
|
||||
// contentGroup.padding.top = 5;
|
||||
// contentGroup.padding.bottom = 5;
|
||||
// contentGroup.childControlHeight = false;
|
||||
// contentGroup.childControlWidth = true;
|
||||
// contentGroup.childForceExpandHeight = false;
|
||||
// contentGroup.childForceExpandWidth = true;
|
||||
|
||||
// GameObject horiScroll = CreateScrollbar(scrollObj);
|
||||
// horiScroll.name = "Scrollbar Horizontal";
|
||||
// SetParentAndAlign(horiScroll, scrollObj);
|
||||
|
||||
// RectTransform horiRect = horiScroll.GetComponent<RectTransform>();
|
||||
// horiRect.anchorMin = Vector2.zero;
|
||||
// horiRect.anchorMax = Vector2.right;
|
||||
// horiRect.pivot = Vector2.zero;
|
||||
// horiRect.sizeDelta = new Vector2(0f, horiRect.sizeDelta.y);
|
||||
|
||||
// GameObject vertScroll = CreateScrollbar(scrollObj);
|
||||
// vertScroll.name = "Scrollbar Vertical";
|
||||
// SetParentAndAlign(vertScroll, scrollObj);
|
||||
// vertScroll.GetComponent<Scrollbar>().SetDirection(Scrollbar.Direction.BottomToTop, true);
|
||||
|
||||
// RectTransform vertRect = vertScroll.GetComponent<RectTransform>();
|
||||
// vertRect.anchorMin = Vector2.right;
|
||||
// vertRect.anchorMax = Vector2.one;
|
||||
// vertRect.pivot = Vector2.one;
|
||||
// vertRect.sizeDelta = new Vector2(vertRect.sizeDelta.x, 0f);
|
||||
|
||||
// RectTransform viewportRect = viewportObj.GetComponent<RectTransform>();
|
||||
// viewportRect.anchorMin = Vector2.zero;
|
||||
// viewportRect.anchorMax = Vector2.one;
|
||||
// viewportRect.sizeDelta = Vector2.zero;
|
||||
// viewportRect.pivot = Vector2.up;
|
||||
|
||||
// RectTransform contentRect = content.GetComponent<RectTransform>();
|
||||
// contentRect.anchorMin = Vector2.up;
|
||||
// contentRect.anchorMax = Vector2.one;
|
||||
// contentRect.pivot = Vector2.up;
|
||||
|
||||
// ScrollRect scrollRect = scrollObj.AddComponent<ScrollRect>();
|
||||
// scrollRect.content = contentRect;
|
||||
// scrollRect.viewport = viewportRect;
|
||||
// scrollRect.horizontalScrollbar = horiScroll.GetComponent<Scrollbar>();
|
||||
// scrollRect.verticalScrollbar = vertScroll.GetComponent<Scrollbar>();
|
||||
// scrollRect.horizontalScrollbarVisibility = ScrollRect.ScrollbarVisibility.AutoHideAndExpandViewport;
|
||||
// scrollRect.verticalScrollbarVisibility = ScrollRect.ScrollbarVisibility.AutoHideAndExpandViewport;
|
||||
// scrollRect.horizontalScrollbarSpacing = -3f;
|
||||
// scrollRect.verticalScrollbarSpacing = -3f;
|
||||
// scrollRect.scrollSensitivity = 25;
|
||||
|
||||
// Image scrollImage = scrollObj.AddComponent<Image>();
|
||||
// scrollImage.type = Image.Type.Filled;
|
||||
// scrollImage.color = (color == default) ? new Color(0.3f, 0.3f, 0.3f, 1f) : color;
|
||||
|
||||
// Image viewportImage = viewportObj.AddComponent<Image>();
|
||||
// //viewportImage.sprite = Theme.mask;
|
||||
// viewportImage.type = Image.Type.Sliced;
|
||||
// viewportImage.color = new Color(1, 1, 1, 1);
|
||||
|
||||
// Mask mask = viewportObj.AddComponent<Mask>();
|
||||
// mask.showMaskGraphic = false;
|
||||
|
||||
// return scrollObj;
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,8 @@ namespace UnityExplorer.UI
|
||||
// Create submodules
|
||||
new MainMenu();
|
||||
|
||||
MouseInspector.ConstructUI();
|
||||
|
||||
// Force refresh of anchors
|
||||
Canvas.ForceUpdateCanvases();
|
||||
|
||||
@ -89,6 +91,14 @@ namespace UnityExplorer.UI
|
||||
{
|
||||
PanelDragger.Instance.Update();
|
||||
}
|
||||
|
||||
foreach (var slider in SliderScrollbar.Instances)
|
||||
{
|
||||
if (slider.m_slider.gameObject.activeInHierarchy)
|
||||
{
|
||||
slider.Update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void OnSceneChange()
|
||||
|
Reference in New Issue
Block a user