20 lines
677 B
C#
20 lines
677 B
C#
using System;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.UI;
|
|
|
|
public class CustomDropdown : Dropdown
|
|
{
|
|
public override void OnPointerClick(PointerEventData eventData)
|
|
{
|
|
// 调用基类的 OnPointerClick 方法
|
|
base.OnPointerClick(eventData);
|
|
// 在此处添加你想要的逻辑,这将在 Dropdown 展开时执行
|
|
Debug.Log("Dropdown is showing");
|
|
|
|
var rect = this.transform.Find("Dropdown List/Viewport/Content").GetComponent<RectTransform>();
|
|
var pos = rect.localPosition;
|
|
pos.y = rect.sizeDelta.y * ((float)this.value / this.options.Count);
|
|
rect.localPosition = pos;
|
|
}
|
|
} |