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));
    }
}
相关推荐
浅陌sss13 小时前
Unity中可靠的UDP实现
unity
虾球xz15 小时前
游戏引擎学习第107天
学习·游戏引擎
虾球xz15 小时前
游戏引擎学习第105天
前端·学习·游戏引擎
奔跑的犀牛先生18 小时前
unity学习46:反向动力学IK
unity
幻世界21 小时前
【工具插件类教学】实现运行时2D物体交互的利器Runtime2DTransformInteractor
unity·交互·运行时2d物体交互
虾球xz1 天前
游戏引擎学习第104天
学习·游戏引擎
音视频牛哥2 天前
Unity实现高性能多实例RTSP|RTMP播放器技术实践
unity·游戏引擎·音视频·实时音视频·大牛直播sdk·rtsp播放器·rtsp player
Artistation Game2 天前
三、Unity基础(主要框架)
游戏·unity·c#·游戏引擎
Edision_li2 天前
DeepSeek教unity------MessagePack-03
unity·messagepack
lalapanda2 天前
Unity学习part2
学习·unity·游戏引擎