Progress on inspector, interactive list basically done

This commit is contained in:
Sinai
2021-05-01 20:55:27 +10:00
parent ab8b736f7e
commit 15ec64b106
26 changed files with 695 additions and 309 deletions

View File

@ -89,6 +89,7 @@ namespace UnityExplorer.UI.Utility
if (totalHeight <= viewportHeight)
{
Slider.handleRect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 0f);
Slider.value = 0f;
Slider.interactable = false;
return;

View File

@ -19,43 +19,40 @@ namespace UnityExplorer.UI.Widgets
#region ICell
public GameObject UIRoot => uiRoot;
public GameObject uiRoot;
public bool Enabled => m_enabled;
private bool m_enabled;
public RectTransform Rect => m_rect;
private RectTransform m_rect;
public GameObject UIRoot { get; set; }
public RectTransform Rect { get; set; }
public void Disable()
{
m_enabled = false;
uiRoot.SetActive(false);
UIRoot.SetActive(false);
}
public void Enable()
{
m_enabled = true;
uiRoot.SetActive(true);
UIRoot.SetActive(true);
}
#endregion
public GameObject CreateContent(GameObject parent)
{
uiRoot = UIFactory.CreateHorizontalGroup(parent, "ButtonCell", true, true, true, true, 2, default,
UIRoot = UIFactory.CreateHorizontalGroup(parent, "ButtonCell", true, true, true, true, 2, default,
new Color(0.11f, 0.11f, 0.11f), TextAnchor.MiddleCenter);
m_rect = uiRoot.GetComponent<RectTransform>();
m_rect.anchorMin = new Vector2(0, 1);
m_rect.anchorMax = new Vector2(0, 1);
m_rect.pivot = new Vector2(0.5f, 1);
m_rect.sizeDelta = new Vector2(25, 25);
UIFactory.SetLayoutElement(uiRoot, minWidth: 100, flexibleWidth: 9999, minHeight: 25, flexibleHeight: 0);
Rect = UIRoot.GetComponent<RectTransform>();
Rect.anchorMin = new Vector2(0, 1);
Rect.anchorMax = new Vector2(0, 1);
Rect.pivot = new Vector2(0.5f, 1);
Rect.sizeDelta = new Vector2(25, 25);
UIFactory.SetLayoutElement(UIRoot, minWidth: 100, flexibleWidth: 9999, minHeight: 25, flexibleHeight: 0);
uiRoot.SetActive(false);
UIRoot.SetActive(false);
this.Button = UIFactory.CreateButton(uiRoot, "NameButton", "Name");
this.Button = UIFactory.CreateButton(UIRoot, "NameButton", "Name");
UIFactory.SetLayoutElement(Button.Button.gameObject, flexibleWidth: 9999, minHeight: 25, flexibleHeight: 0);
var buttonText = Button.Button.GetComponentInChildren<Text>();
buttonText.horizontalOverflow = HorizontalWrapMode.Overflow;
@ -69,7 +66,7 @@ namespace UnityExplorer.UI.Widgets
Button.OnClick += () => { OnClick?.Invoke(CurrentDataIndex); };
return uiRoot;
return UIRoot;
}
}
}

View File

@ -11,7 +11,7 @@ namespace UnityExplorer.UI.Widgets
{
bool Enabled { get; }
RectTransform Rect { get; }
RectTransform Rect { get; set; }
void Enable();
void Disable();

View File

@ -114,7 +114,8 @@ namespace UnityExplorer.UI.Widgets
else if (Content.rect.height != prevContentHeight)
{
prevContentHeight = Content.rect.height;
OnValueChangedListener(Vector2.zero);
if (!writingLocked)
OnValueChangedListener(Vector2.zero);
}
}
#endregion
@ -152,7 +153,7 @@ namespace UnityExplorer.UI.Widgets
ScrollRect.vertical = true;
ScrollRect.horizontal = false;
//ScrollRect.onValueChanged.RemoveListener(OnValueChangedListener);
LayoutRebuilder.ForceRebuildLayoutImmediate(Content);
RuntimeProvider.Instance.StartCoroutine(InitCoroutine());
}
@ -182,6 +183,8 @@ namespace UnityExplorer.UI.Widgets
// add onValueChanged listener after setup
ScrollRect.onValueChanged.AddListener(OnValueChangedListener);
ExplorerCore.Log("ScrollPool Init finished");
}
private void SetScrollBounds()

View File

@ -21,10 +21,8 @@ namespace UnityExplorer.UI.Widgets
public CachedTransform cachedTransform;
public int _cellIndex;
public GameObject UIRoot => uiRoot;
public GameObject uiRoot;
public RectTransform Rect => m_rect;
private RectTransform m_rect;
public GameObject UIRoot { get; set; }
public RectTransform Rect { get; set; }
public ButtonRef ExpandButton;
public ButtonRef NameButton;
@ -78,13 +76,13 @@ namespace UnityExplorer.UI.Widgets
public void Disable()
{
m_enabled = false;
uiRoot.SetActive(false);
UIRoot.SetActive(false);
}
public void Enable()
{
m_enabled = true;
uiRoot.SetActive(true);
UIRoot.SetActive(true);
}
public void OnExpandClicked()
@ -102,23 +100,23 @@ namespace UnityExplorer.UI.Widgets
public GameObject CreateContent(GameObject parent)
{
uiRoot = UIFactory.CreateUIObject("TransformCell", parent);
UIFactory.SetLayoutGroup<HorizontalLayoutGroup>(uiRoot, true, true, true, true, 2, childAlignment: TextAnchor.MiddleCenter);
m_rect = uiRoot.GetComponent<RectTransform>();
m_rect.anchorMin = new Vector2(0, 1);
m_rect.anchorMax = new Vector2(0, 1);
m_rect.pivot = new Vector2(0.5f, 1);
m_rect.sizeDelta = new Vector2(25, 25);
UIFactory.SetLayoutElement(uiRoot, minWidth: 100, flexibleWidth: 9999, minHeight: 25, flexibleHeight: 0);
UIRoot = UIFactory.CreateUIObject("TransformCell", parent);
UIFactory.SetLayoutGroup<HorizontalLayoutGroup>(UIRoot, true, true, true, true, 2, childAlignment: TextAnchor.MiddleCenter);
Rect = UIRoot.GetComponent<RectTransform>();
Rect.anchorMin = new Vector2(0, 1);
Rect.anchorMax = new Vector2(0, 1);
Rect.pivot = new Vector2(0.5f, 1);
Rect.sizeDelta = new Vector2(25, 25);
UIFactory.SetLayoutElement(UIRoot, minWidth: 100, flexibleWidth: 9999, minHeight: 25, flexibleHeight: 0);
var spacerObj = UIFactory.CreateUIObject("Spacer", uiRoot, new Vector2(0, 0));
var spacerObj = UIFactory.CreateUIObject("Spacer", UIRoot, new Vector2(0, 0));
UIFactory.SetLayoutElement(spacerObj, minWidth: 0, flexibleWidth: 0, minHeight: 0, flexibleHeight: 0);
this.spacer = spacerObj.GetComponent<LayoutElement>();
ExpandButton = UIFactory.CreateButton(this.uiRoot, "ExpandButton", "►");
ExpandButton = UIFactory.CreateButton(this.UIRoot, "ExpandButton", "►");
UIFactory.SetLayoutElement(ExpandButton.Button.gameObject, minWidth: 15, flexibleWidth: 0, minHeight: 25, flexibleHeight: 0);
NameButton = UIFactory.CreateButton(this.uiRoot, "NameButton", "Name", null);
NameButton = UIFactory.CreateButton(this.UIRoot, "NameButton", "Name", null);
UIFactory.SetLayoutElement(NameButton.Button.gameObject, flexibleWidth: 9999, minHeight: 25, flexibleHeight: 0);
var nameLabel = NameButton.Button.GetComponentInChildren<Text>();
nameLabel.horizontalOverflow = HorizontalWrapMode.Overflow;
@ -134,9 +132,9 @@ namespace UnityExplorer.UI.Widgets
NameButton.OnClick += OnMainButtonClicked;
ExpandButton.OnClick += OnExpandClicked;
uiRoot.SetActive(false);
UIRoot.SetActive(false);
return this.uiRoot;
return this.UIRoot;
}
}
}