unity旋转选中效果


代码和预制体


函数PlayAnim()中的角度要根据按钮数量手动填好

csharp 复制代码
using System;
using DG.Tweening;
using DG.Tweening.Core;
using DG.Tweening.Plugins.Options;
using UnityEngine;

// Token: 0x0200001B RID: 27
public class BtnParentScript : BaseWindow<BtnParentScript>
{
	// Token: 0x060000A7 RID: 167 RVA: 0x00004774 File Offset: 0x00002974
	private void Update()
	{
		if (Input.touchCount > 0)
		{
			count += Input.touchCount;
		}
		if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Moved)
		{
			this.touchposition = Input.GetTouch(0).deltaPosition * 0.1f;
			base.transform.localEulerAngles = new Vector3(base.transform.localEulerAngles.x, base.transform.localEulerAngles.y - this.touchposition.x, base.transform.localEulerAngles.z);
		}
	}

	// Token: 0x060000A8 RID: 168 RVA: 0x00004824 File Offset: 0x00002A24
	public void PlayAnim(int index)
	{
		float y = 0f;
		switch (index)
		{
		case 0:
			y = 300f;
			break;
		case 1:
			y = 240f;
			break;
		case 2:
			y = 180f;
			break;
		case 3:
			y = 120f;
			break;
		case 4:
			y = 60;
			break;
		case 5:
			y = 0;
			break;
		}
		//BaseWindow<Page1Script>.Instance.Mask.SetActive(true);
		base.transform.DOLocalRotate(new Vector3(0, y, 0), 0.5f, RotateMode.Fast).OnComplete(delegate
		{
			print("旋转动画,index:"+ index);
			//Page1Script.Instance.ShowOneFlyBtn(index);
			//UIRootScript.Instance.ShowOnePage(1);
		});
	}

	// Token: 0x04000074 RID: 116
	public int count;

	// Token: 0x04000075 RID: 117
	public Vector3 touchposition;
}

按钮根据数量计算角度排列均匀


csharp 复制代码
using UnityEngine;
public class LookAtCamera : MonoBehaviour
{
    void Update()
    {
        transform.LookAt(transform.position + new Vector3(0,0,1));
    }
}
相关推荐
霜绛1 小时前
Unity:UGUI笔记(一)——三大基础控件、组合控件
笔记·学习·unity·游戏引擎
小趴菜82277 小时前
Android中加载unity aar包实现方案
android·unity·游戏引擎
今夕资源网15 小时前
牛童三国单机游戏Unity源码 免费开源
游戏·unity·单机游戏·游戏源码·unity源码·unity游戏
future_studio21 小时前
聊聊 Unity(小白专享、C# 小程序 之 图片播放器)
unity·小程序·c#
ellis19701 天前
toLua[七] Examples 06_LuaCoroutine2分析
unity
L X..1 天前
Unity 光照贴图异常修复笔记
unity·c#·游戏引擎
Xeon_CC2 天前
打开多个Unity编辑器时使用Visual Studio调试,弹出选择Unity实例窗口,但是没有实例
unity·编辑器·visual studio·调试·unity 调试
小L~~~2 天前
2025吉比特-游戏引擎开发-一面复盘
数据结构·算法·游戏引擎
云卓SKYDROID2 天前
无人机中继器模式技术对比
人工智能·游戏引擎·php·无人机·cocos2d·高科技·云卓科技
future_studio3 天前
聊聊 Unity(小白专享、熟悉基础编程 ... ...)
unity·游戏引擎