1
This commit is contained in:
@@ -900,8 +900,8 @@ RectTransform:
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
m_AnchoredPosition: {x: 190, y: -85}
|
||||
m_SizeDelta: {x: 380, y: 0}
|
||||
m_AnchoredPosition: {x: 190, y: -60}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &1531445533758858613
|
||||
MonoBehaviour:
|
||||
|
||||
@@ -1,110 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
using XRLib.UI;
|
||||
|
||||
namespace Studio.UI
|
||||
{
|
||||
public class ProjectTemplateDropdown : UIBase
|
||||
{
|
||||
private GameObject optionItemPrefab;
|
||||
|
||||
private RectTransform TemplateDropdown;
|
||||
private RectTransform Content;
|
||||
public TMP_InputField InputField_ProjectTemplate;
|
||||
public Button Button_Dropdown;
|
||||
|
||||
private List<string> options = new();
|
||||
private List<GameObject> activeOptionItems = new List<GameObject>();
|
||||
|
||||
public enum EType
|
||||
{
|
||||
Test1,
|
||||
Test2,
|
||||
Test3,
|
||||
Test4,
|
||||
Test5,
|
||||
Test6,
|
||||
Test7,
|
||||
}
|
||||
|
||||
public override void AfterAwake()
|
||||
{
|
||||
optionItemPrefab = Resources.Load<GameObject>("Prefabs/UI/PRF_QuickStartItem");
|
||||
InputField_ProjectTemplate.onValueChanged.AddListener(FilteringOption);
|
||||
Button_Dropdown.onClick.AddListener(ShowDropdown);
|
||||
|
||||
HideDropdown();
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
CreateDropdown();
|
||||
}
|
||||
|
||||
private void ShowDropdown()
|
||||
{
|
||||
TemplateDropdown.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
private void HideDropdown()
|
||||
{
|
||||
TemplateDropdown.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
private void CreateDropdown()
|
||||
{
|
||||
ClearDropdownItems();
|
||||
|
||||
options = Enum.GetNames(typeof(EType)).ToList();
|
||||
foreach (string option in options)
|
||||
{
|
||||
CreateOption(option);
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateOption(string text)
|
||||
{
|
||||
UI_QuickStartItem item = Instantiate(optionItemPrefab, Content).GetComponent<UI_QuickStartItem>();
|
||||
item.Init(text, () => OnClickOptionItem(text));
|
||||
|
||||
activeOptionItems.Add(item.gameObject);
|
||||
}
|
||||
|
||||
private void OnClickOptionItem(string text)
|
||||
{
|
||||
InputField_ProjectTemplate.text = text;
|
||||
HideDropdown();
|
||||
EventSystem.current.SetSelectedGameObject(null);
|
||||
}
|
||||
|
||||
private void FilteringOption(string input)
|
||||
{
|
||||
ClearDropdownItems();
|
||||
|
||||
foreach (string option in options)
|
||||
{
|
||||
if (option.ToLower().Contains(input.ToLower()))
|
||||
{
|
||||
CreateOption(option);
|
||||
}
|
||||
}
|
||||
|
||||
TemplateDropdown.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
private void ClearDropdownItems()
|
||||
{
|
||||
foreach (GameObject item in activeOptionItems)
|
||||
{
|
||||
Destroy(item);
|
||||
}
|
||||
|
||||
activeOptionItems.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 03b6d3a46836e8b45abda03e9bab7e4f
|
||||
Reference in New Issue
Block a user