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));
    }
}
相关推荐
qiu_zhongya4 小时前
unity以战斗截图并加上微信二维码分享
unity
死也不注释14 小时前
【Unity UGUI 交互组件——Dropdown(TMP版本)(10)】
java·unity·交互
Magnum Lehar15 小时前
wpf 3d游戏引擎的PrimitiveMesh.h和ToolsCommon.h
3d·游戏引擎
SmalBox15 小时前
【光照】[光照模型]是什么?以UnityURP为例
unity·渲染
死也不注释1 天前
【Unity UGUI 交互组件——Scrollbar(8)】
unity·游戏引擎·交互
九章云极AladdinEdu2 天前
绿色算力技术栈:AI集群功耗建模与动态调频系统
人工智能·pytorch·深度学习·unity·游戏引擎·transformer·gpu算力
伽蓝_游戏2 天前
UGUI源码剖析(15):Slider的运行时逻辑与编辑器实现
游戏·ui·unity·性能优化·c#·游戏引擎·.net
lrh30252 天前
Custom SRP - Complex Maps
unity·srp·render pipeline
m0_497214152 天前
unity中通过拖拽,自定义scroll view中子物体顺序
unity·游戏引擎
地狱为王2 天前
在Unity中实现DTLN-AEC处理音频文件的功能
unity·aec·降噪