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;
        }
    }
}
相关推荐
孟无岐15 小时前
【Laya】Component 使用说明
typescript·游戏引擎·游戏程序·laya
weixin_4093831215 小时前
cocos shader三角流光
游戏引擎·cocos2d
Mars-xq18 小时前
godot 毛玻璃效果着色器shader
游戏引擎·godot·着色器
绀目澄清18 小时前
unity3d AI Navigation 中文文档
游戏·unity
绀目澄清20 小时前
Unity 的AI Navigation 系统详细总结
人工智能·unity·游戏引擎
绀目澄清1 天前
Unity3D AI Navigation 详解:从基础概念到实战应用
unity·游戏引擎
weixin_409383121 天前
cocos shader流光文字 不显示透明部分
游戏引擎·cocos2d
绀目澄清1 天前
Unity3D AI导航系统完全指南:从核心概念到动画耦合
人工智能·unity
__water1 天前
RHK《模型贴图自由更换位置》
unity·贴图·模型贴图·移动不丢失
JIes__1 天前
Unity(二)——3D数学
unity·游戏引擎