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));
    }
}
相关推荐
不伤欣6 小时前
游戏设计模式 - 子类沙箱
游戏·unity·设计模式
Magnum Lehar8 小时前
vulkan游戏引擎test文件memory实现
游戏引擎
Magnum Lehar8 小时前
vulkan游戏引擎test_manager实现
java·算法·游戏引擎
快乐觉主吖12 小时前
Unity的日志管理类
android·unity·游戏引擎
WarPigs19 小时前
Unity性能优化笔记
笔记·unity·游戏引擎
T.D.C1 天前
【业务框架】3C-相机-Cinemachine
unity
一线灵1 天前
跨平台游戏引擎 Axmol-2.6.1 发布
游戏引擎
Clank的游戏栈2 天前
Unity基于GraphView的可视化关卡编辑器开发指南
unity·编辑器·游戏引擎
海尔辛2 天前
Unity UI 性能优化--Sprite 篇
ui·unity·性能优化
三巧2 天前
Godot 敌人生成半径和围墙不匹配,导致敌人错误的生成在围墙外的解决代码
游戏引擎·godot