(一)基础设置
拖入资源库中的“银河”材质球,设置放大参数,使相机包裹其中;
设置Canvas分辨率为1920*1080,RenderMode选为世界空间;调整位置,视图如下所示。
(二)场景选择设置需要设置一个面片,position(0,0,-2000),设置一个空物体(0,0,0),将面片作为空物体的子物体。将GameItem作为预制体,使用代码自动生成。
在游戏运行时,在GameItemSpan下生成GameItem,定义一个Material[],每次选择旋转的角度private float m_Angle;
using System.Collections; using System.Collections.Generic; using UnityEngine; using DG.Tweening; public class GameItemSelect : MonoBehaviour { public static GameItemSelect _Instance; public Material[] m_gameItemMatArr; public GameObject go_GameItem; private float m_Angle; public int Index = 0; private void Awake() { _Instance = this; m_Angle = 360.0f / m_gameItemMatArr.Length; for (int i = 0; i < m_gameItemMatArr.Length; i++) { GameObject go = Instantiate(go_GameItem, transform); go.transform.localEulerAngles = new Vector3(0, i * m_Angle, 0); go.GetComponentInChildren<MeshRenderer>().material = m_gameItemMatArr[i]; go.GetComponentInChildren<GameItem>().SetVideoName(m_gameItemMatArr[i].name); go.GetComponentInChildren<GameItem>().Index = i; } } public void RotateForWord() { Index++; if (Index >= m_gameItemMatArr.Length) { Index = 0; } transform.DORotate(new Vector3(0, -Index * m_Angle, 0), 0.3f); } public void RotateBack() { Index--; if (Index < 0) { Index = m_gameItemMatArr.Length - 1; } transform.DORotate(new Vector3(0, -Index * m_Angle, 0), 0.3f); } }