mirror of
https://github.com/GrahamKracker/UnityExplorer.git
synced 2025-07-12 23:06:56 +08:00
Finished argument inputs for Method/Props, some UI cleanups and fixes
This commit is contained in:
@ -195,9 +195,7 @@ namespace UnityExplorer.UI
|
||||
|
||||
Text text = textObj.GetComponent<Text>();
|
||||
text.text = $"<b>UnityExplorer</b> <i>v{ExplorerCore.VERSION}</i>";
|
||||
text.resizeTextForBestFit = true;
|
||||
text.resizeTextMinSize = 12;
|
||||
text.resizeTextMaxSize = 20;
|
||||
text.fontSize = 15;
|
||||
LayoutElement textLayout = textObj.AddComponent<LayoutElement>();
|
||||
textLayout.flexibleWidth = 5000;
|
||||
|
||||
|
@ -4,6 +4,7 @@ using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityExplorer.Input;
|
||||
using System.IO;
|
||||
using UnityExplorer.Inspectors;
|
||||
#if CPP
|
||||
using UnityExplorer.Unstrip;
|
||||
#endif
|
||||
@ -27,6 +28,8 @@ namespace UnityExplorer.UI
|
||||
Panel = panelToDrag;
|
||||
|
||||
UpdateResizeCache();
|
||||
|
||||
SceneExplorer.OnToggleShow += OnEndResize;
|
||||
}
|
||||
|
||||
public void Update()
|
||||
@ -133,7 +136,7 @@ namespace UnityExplorer.UI
|
||||
|
||||
private const int RESIZE_THICKNESS = 15;
|
||||
|
||||
private readonly Vector2 minResize = new Vector2(630, 540);
|
||||
internal readonly Vector2 minResize = new Vector2(400, 400);
|
||||
|
||||
private bool WasResizing { get; set; }
|
||||
private ResizeTypes m_currentResizeType = ResizeTypes.NONE;
|
||||
@ -172,26 +175,20 @@ namespace UnityExplorer.UI
|
||||
int halfThick = RESIZE_THICKNESS / 2;
|
||||
int dblThick = RESIZE_THICKNESS * 2;
|
||||
|
||||
// calculate main outer rect
|
||||
// the resize area is both outside and inside the panel,
|
||||
// to give a bit of buffer and make it easier to use.
|
||||
|
||||
// outer rect is the outer-most bounds of our resize area
|
||||
Rect outer = new Rect(Panel.rect.x - halfThick,
|
||||
m_resizeRect = new Rect(Panel.rect.x - halfThick,
|
||||
Panel.rect.y - halfThick,
|
||||
Panel.rect.width + dblThick,
|
||||
Panel.rect.height + dblThick);
|
||||
m_resizeRect = outer;
|
||||
|
||||
// calculate the four cross sections to use as flags
|
||||
|
||||
m_resizeMask[ResizeTypes.Bottom] = new Rect(outer.x, outer.y, outer.width, RESIZE_THICKNESS);
|
||||
m_resizeMask[ResizeTypes.Bottom] = new Rect(m_resizeRect.x, m_resizeRect.y, m_resizeRect.width, RESIZE_THICKNESS);
|
||||
|
||||
m_resizeMask[ResizeTypes.Left] = new Rect(outer.x, outer.y, RESIZE_THICKNESS, outer.height);
|
||||
m_resizeMask[ResizeTypes.Left] = new Rect(m_resizeRect.x, m_resizeRect.y, RESIZE_THICKNESS, m_resizeRect.height);
|
||||
|
||||
m_resizeMask[ResizeTypes.Top] = new Rect(outer.x, outer.y + Panel.rect.height, outer.width, RESIZE_THICKNESS);
|
||||
m_resizeMask[ResizeTypes.Top] = new Rect(m_resizeRect.x, m_resizeRect.y + Panel.rect.height, m_resizeRect.width, RESIZE_THICKNESS);
|
||||
|
||||
m_resizeMask[ResizeTypes.Right] = new Rect(outer.x + Panel.rect.width, outer.y, RESIZE_THICKNESS, outer.height);
|
||||
m_resizeMask[ResizeTypes.Right] = new Rect(m_resizeRect.x + Panel.rect.width, m_resizeRect.y, RESIZE_THICKNESS, m_resizeRect.height);
|
||||
}
|
||||
|
||||
private bool MouseInResizeArea(Vector2 mousePos)
|
||||
@ -298,6 +295,9 @@ namespace UnityExplorer.UI
|
||||
else if (m_currentResizeType.HasFlag(ResizeTypes.Bottom))
|
||||
anchorMin.y -= diffY;
|
||||
|
||||
//Panel.anchorMin = new Vector2(anchorMin.x, anchorMin.y);
|
||||
//Panel.anchorMax = new Vector2(anchorMax.x, anchorMax.y);
|
||||
|
||||
var newWidth = (anchorMax.x - anchorMin.x) * Screen.width;
|
||||
var newHeight = (anchorMax.y - anchorMin.y) * Screen.height;
|
||||
|
||||
|
@ -93,6 +93,9 @@ namespace UnityExplorer.UI
|
||||
rect.anchoredPosition = Vector2.zero;
|
||||
rect.sizeDelta = Vector2.zero;
|
||||
|
||||
var img = panelObj.AddComponent<Image>();
|
||||
img.color = Color.white;
|
||||
|
||||
VerticalLayoutGroup group = panelObj.AddComponent<VerticalLayoutGroup>();
|
||||
group.childControlHeight = true;
|
||||
group.childControlWidth = true;
|
||||
@ -106,8 +109,6 @@ namespace UnityExplorer.UI
|
||||
image2.type = Image.Type.Filled;
|
||||
image2.color = new Color(0.1f, 0.1f, 0.1f);
|
||||
|
||||
content.gameObject.AddComponent<Mask>();
|
||||
|
||||
VerticalLayoutGroup group2 = content.AddComponent<VerticalLayoutGroup>();
|
||||
group2.padding.left = 3;
|
||||
group2.padding.right = 3;
|
||||
@ -150,7 +151,8 @@ namespace UnityExplorer.UI
|
||||
|
||||
VerticalLayoutGroup horiGroup = groupObj.AddComponent<VerticalLayoutGroup>();
|
||||
horiGroup.childAlignment = TextAnchor.UpperLeft;
|
||||
horiGroup.childControlWidth = false;
|
||||
horiGroup.childControlWidth = true;
|
||||
horiGroup.childControlHeight = true;
|
||||
|
||||
Image image = groupObj.AddComponent<Image>();
|
||||
if (color != default)
|
||||
@ -171,7 +173,8 @@ namespace UnityExplorer.UI
|
||||
|
||||
HorizontalLayoutGroup horiGroup = groupObj.AddComponent<HorizontalLayoutGroup>();
|
||||
horiGroup.childAlignment = TextAnchor.UpperLeft;
|
||||
horiGroup.childControlWidth = false;
|
||||
horiGroup.childControlWidth = true;
|
||||
horiGroup.childControlHeight = true;
|
||||
|
||||
Image image = groupObj.AddComponent<Image>();
|
||||
if (color != default)
|
||||
@ -327,7 +330,7 @@ namespace UnityExplorer.UI
|
||||
return scrollObj;
|
||||
}
|
||||
|
||||
public static GameObject CreateToggle(GameObject parent, out Toggle toggle, out Text text)
|
||||
public static GameObject CreateToggle(GameObject parent, out Toggle toggle, out Text text, Color bgColor = default)
|
||||
{
|
||||
GameObject toggleObj = CreateUIObject("Toggle", parent, thinSize);
|
||||
|
||||
@ -336,7 +339,7 @@ namespace UnityExplorer.UI
|
||||
GameObject labelObj = CreateUIObject("Label", toggleObj);
|
||||
|
||||
toggle = toggleObj.AddComponent<Toggle>();
|
||||
toggle.isOn = true;
|
||||
//toggle.isOn = true;
|
||||
Toggle toggleComp = toggle;
|
||||
|
||||
toggle.onValueChanged.AddListener(Deselect);
|
||||
@ -346,11 +349,12 @@ namespace UnityExplorer.UI
|
||||
}
|
||||
|
||||
Image bgImage = bgObj.AddComponent<Image>();
|
||||
bgImage.type = Image.Type.Sliced;
|
||||
bgImage.color = new Color(0.1f, 0.1f, 0.1f, 1.0f);
|
||||
bgImage.color = bgColor == default
|
||||
? new Color(0.2f, 0.2f, 0.2f, 1.0f)
|
||||
: bgColor;
|
||||
|
||||
Image checkImage = checkObj.AddComponent<Image>();
|
||||
checkImage.color = new Color(90f / 255f, 115f / 255f, 90f / 255f, 1.0f);
|
||||
checkImage.color = new Color(0.3f, 0.5f, 0.3f, 1.0f);
|
||||
|
||||
text = labelObj.AddComponent<Text>();
|
||||
text.text = "Toggle";
|
||||
@ -363,7 +367,7 @@ namespace UnityExplorer.UI
|
||||
RectTransform bgRect = bgObj.GetComponent<RectTransform>();
|
||||
bgRect.anchorMin = new Vector2(0f, 1f);
|
||||
bgRect.anchorMax = new Vector2(0f, 1f);
|
||||
bgRect.anchoredPosition = new Vector2(10f, -10f);
|
||||
bgRect.anchoredPosition = new Vector2(13f, -13f);
|
||||
bgRect.sizeDelta = new Vector2(20f, 20f);
|
||||
|
||||
RectTransform checkRect = checkObj.GetComponent<RectTransform>();
|
||||
@ -375,8 +379,8 @@ namespace UnityExplorer.UI
|
||||
RectTransform labelRect = labelObj.GetComponent<RectTransform>();
|
||||
labelRect.anchorMin = new Vector2(0f, 0f);
|
||||
labelRect.anchorMax = new Vector2(1f, 1f);
|
||||
labelRect.offsetMin = new Vector2(23f, 1f);
|
||||
labelRect.offsetMax = new Vector2(-5f, -2f);
|
||||
labelRect.offsetMin = new Vector2(28f, 2f);
|
||||
labelRect.offsetMax = new Vector2(-5f, -5f);
|
||||
return toggleObj;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user