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));
    }
}
相关推荐
8 小时前
3D碰撞检测系统 基于SAT算法+Burst优化(Unity)
算法·3d·unity·c#·游戏引擎·sat
dzj202113 小时前
Unity是如何把3D场景显示到屏幕上的——Unity的渲染过程
3d·unity·游戏引擎·渲染·图形学
死也不注释1 天前
【鸡零狗碎记录】
unity·c#
★YUI★1 天前
学习游戏制作记录(剑投掷技能)7.26
学习·游戏·unity·c#
★YUI★2 天前
学习游戏制作记录(克隆技能)7.25
学习·游戏·unity·c#
不绝1912 天前
ARPG开发流程第一章——方法合集
算法·游戏·unity·游戏引擎
玩代码2 天前
Unity里的加力
开发语言·unity
贵州晓智信息科技2 天前
Unity 性能优化全攻略
unity·性能优化·游戏引擎
UWA2 天前
UWA DAY 2025 游戏开发者大会|全议程
游戏·unity·性能优化·游戏开发·uwa·unreal engine
unicrom_深圳市由你创科技2 天前
Unity 的UI动画调节
ui·unity·游戏引擎