unity 控制Dropdown的Arrow箭头变化

Dropdown打开下拉菜单会以"Template"为模板创建一个Dropdown List,在"Template"上添加一个脚本在Start()中执行下拉框打开时的操作,在OnDestroy()中执行下拉框收起时的操作即可。

效果代码如下用于控制Arrow旋转可以根据自己的想法进行修改:

cs 复制代码
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

/// <summary>
/// 控制Dropdown中的Arrow效果,脚本挂在Template上
/// </summary>
public class DropdownArrowCtr : MonoBehaviour
{
    public RectTransform arrow;
    // Start is called before the first frame update
    void Start()
    {
        if (this.name == "Dropdown List")
        {
            arrow.eulerAngles = new Vector3(0, 0, 180);
        }
    }

    private void OnDestroy()
    {
        if (this.name == "Dropdown List")
        {
            arrow.eulerAngles = Vector3.zero;
        }
    }
}
相关推荐
XR-AI-JK12 小时前
Unity VR/MR开发-VR/开发SDK选型对比分析
unity·vr·mr
心之所向,自强不息19 小时前
【Unity Shader编程】之让画面动起来
unity·游戏引擎
不伤欣2 天前
游戏设计模式 - 子类沙箱
游戏·unity·设计模式
Magnum Lehar2 天前
vulkan游戏引擎test文件memory实现
游戏引擎
Magnum Lehar2 天前
vulkan游戏引擎test_manager实现
java·算法·游戏引擎
快乐觉主吖2 天前
Unity的日志管理类
android·unity·游戏引擎
WarPigs2 天前
Unity性能优化笔记
笔记·unity·游戏引擎
T.D.C2 天前
【业务框架】3C-相机-Cinemachine
unity
一线灵3 天前
跨平台游戏引擎 Axmol-2.6.1 发布
游戏引擎
Clank的游戏栈3 天前
Unity基于GraphView的可视化关卡编辑器开发指南
unity·编辑器·游戏引擎