Unity做一个魔方
最近項目周期變得平穩,不再像之前那么忙了,所以抽空寫了個魔方小游戲,在這里跟大家分享。
游戲原理并不復雜,在場景中,我們放了27個Cube,和6個面的觸發器,根據觸發器的Enter檢測和Exit檢測,確定對應面的子物體,使得觸發器底下的9個Cube能同時轉動,同時,再設置X,Y,Z三個軸向的整體轉動,子物體是固定的27個Cube。
有了思路以后,我們來做場景,做完場景以后,畫面大概是這樣:
在FrontContent及以下5個物體中,我們要掛靠BoxCollider,和Rigibody組件,如圖:
接下來,我們來寫腳本,因為總體邏輯并不復雜,所以主邏輯只寫了了一個GameController腳本,另外還有6個觸發器腳本,以下是代碼:
GameController.cs
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI;public class GameController : MonoBehaviour {public static GameController Instance;public enum Axis {//旋轉軸X = 1,Y = 2,Z = 3}public enum RotateModel {//旋轉模式Forward = 90,Back = -90}public enum Direction {//旋轉方位First = -90,Second = -180,Third = 90,Fourth = 0}private Direction cubeDirF;//F面轉向private Direction cubeDirB;//B面轉向private Direction cubeDirU;//U面轉向private Direction cubeDirD;//D面轉向private Direction cubeDirL;//L面轉向private Direction cubeDirR;//R面轉向private Direction cubeDirWholeX;//整體轉向private Direction cubeDirWholeY;private Direction cubeDirWholeZ;private const float rotateSpeed = 150f;//旋轉速度private Quaternion targetRotationF;//旋轉角度private Quaternion targetRotationB;private Quaternion targetRotationU;private Quaternion targetRotationD;private Quaternion targetRotationL;private Quaternion targetRotationR;private Quaternion targetRotationWholeX;private Quaternion targetRotationWholeY;private Quaternion targetRotationWholeZ;private int targetFZ = 0;//旋轉軸度數private int targetBZ = 0;private int targetUY = 0;private int targetDY = 0;private int targetLX = 0;private int targetRX = 0;private int targetWholeX = 0;private int targetWholeY = 0;private int targetWholeZ = 0;public Button FButton;public Button FAntiButton;public Button BButton;public Button BAntiButton;public Button UButton;public Button UAntiButton;public Button DButton;public Button DAntiButton;public Button LButton;public Button LAntiButton;public Button RButton;public Button RAntiButton;public Button XButton;public Button XAntiButton;public Button YButton;public Button YAntiButton;public Button ZButton;public Button ZAntiButton;public GameObject FrontContent;//旋轉父物體public GameObject BackContent;public GameObject UpContent;public GameObject DownContent;public GameObject LeftContent;public GameObject RightContent;public GameObject WholeXContent;public GameObject WholeYContent;public GameObject WholeZContent;private GameObject prevContent;//上一個轉動的模塊public List<GameObject> FrontObjList;//旋轉面方塊集合public List<GameObject> BackObjList;public List<GameObject> UpObjList;public List<GameObject> DownObjList;public List<GameObject> LeftObjList;public List<GameObject> RightObjList;public List<GameObject> WholeObjList; private bool isFrontClockwise = false;//旋轉判斷條件private bool isFrontAntiClockwise = false;private bool isBackClockwise = false;private bool isBackAntiClockwise = false;private bool isUpClockwise = false;private bool isUpAntiClockwise = false;private bool isDownClockwise = false;private bool isDownAntiClockwise = false;private bool isLeftClockwise = false;private bool isLeftAntiClockwise = false;private bool isRightClockwise = false;private bool isRightAntiClockwise = false;private bool isXClockwise = false;private bool isXAntiClockwise = false;private bool isYClockwise = false;private bool isYAntiClockwise = false;private bool isZClockwise = false;private bool isZAntiClockwise = false;private bool isPlaying = false;//正在旋轉void Awake(){Instance = this;}void Start () {FButton.onClick.AddListener(OnClickFBtn);FAntiButton.onClick.AddListener(OnClickFAntiBtn);BButton.onClick.AddListener(OnClickBBtn);BAntiButton.onClick.AddListener(OnClickBAntiBtn);UButton.onClick.AddListener(OnClickUBtn);UAntiButton.onClick.AddListener(OnClickUAntiBtn);DButton.onClick.AddListener(OnClickDBtn);DAntiButton.onClick.AddListener(OnClickDAntiBtn);LButton.onClick.AddListener(OnClickLBtn);LAntiButton.onClick.AddListener(OnClickLAntiBtn);RButton.onClick.AddListener(OnClickRBtn);RAntiButton.onClick.AddListener(OnClickRAntiBtn);XButton.onClick.AddListener(OnClickXBtn);XAntiButton.onClick.AddListener(OnClickXAntiBtn);YButton.onClick.AddListener(OnClickYBtn);YAntiButton.onClick.AddListener(OnClickYAntiBtn);ZButton.onClick.AddListener(OnClickZBtn);ZAntiButton.onClick.AddListener(OnClickZAntiBtn);}void Update () {UpdateFrontClockwise();UpdateFrontAntiClockwise();UpdateBackClockwise();UpdateBackAntiClosewise();UpdateUpClockwise();UpdateUpAntiClockwise();UpdateDownClockwise();UpdateDownAntiClockwise();UpdateLeftClockwise();UpdateLeftAntiClockwise();UpdateRightClockwise();UpdateRightAntiClockwise();UpdateXAxisClockwise();UpdateXAxisAntiClockwise();UpdateYAxisClockwise();UpdateYAxisAntiClockwise();UpdateZAxisClockwise();UpdateZAxisAntiClockwise();}public void OnClickFBtn()//點擊F按鈕{ClickBtnEvent(RotateModel.Back, Axis.Z, ref FrontContent, ref FrontObjList, ref targetFZ, ref cubeDirF, ref targetRotationF, ref isFrontClockwise);}public void OnClickFAntiBtn()//點擊F'按鈕{ClickBtnEvent(RotateModel.Forward, Axis.Z, ref FrontContent, ref FrontObjList, ref targetFZ, ref cubeDirF, ref targetRotationF, ref isFrontAntiClockwise);}private void UpdateFrontClockwise()//F面正向旋轉{UpdateRotateZEvent(Vector3.back, cubeDirF, targetRotationF, RotateModel.Back, ref FrontContent, ref isFrontClockwise, ref isFrontAntiClockwise);}private void UpdateFrontAntiClockwise()//F面反向旋轉{UpdateRotateZEvent(Vector3.forward, cubeDirF, targetRotationF, RotateModel.Forward, ref FrontContent, ref isFrontAntiClockwise, ref isFrontClockwise);}public void OnClickBBtn()//點擊B按鈕{ClickBtnEvent(RotateModel.Forward, Axis.Z, ref BackContent, ref BackObjList,ref targetBZ, ref cubeDirB, ref targetRotationB, ref isBackClockwise);}public void OnClickBAntiBtn()//點擊B'按鈕{ClickBtnEvent(RotateModel.Back, Axis.Z, ref BackContent, ref BackObjList, ref targetBZ, ref cubeDirB, ref targetRotationB, ref isBackAntiClockwise);}public void UpdateBackClockwise()//B面正向旋轉{UpdateRotateZEvent(Vector3.forward, cubeDirB, targetRotationB, RotateModel.Forward, ref BackContent,ref isBackClockwise,ref isBackAntiClockwise);}public void UpdateBackAntiClosewise()//B面反向旋轉{UpdateRotateZEvent(Vector3.back, cubeDirB, targetRotationB, RotateModel.Back, ref BackContent, ref isBackAntiClockwise, ref isBackClockwise);}public void OnClickUBtn()//點擊U按鈕{ClickBtnEvent(RotateModel.Forward, Axis.Y, ref UpContent, ref UpObjList, ref targetUY, ref cubeDirU, ref targetRotationU, ref isUpClockwise);}public void OnClickUAntiBtn()//點擊U'按鈕{ClickBtnEvent(RotateModel.Back, Axis.Y, ref UpContent, ref UpObjList, ref targetUY, ref cubeDirU, ref targetRotationU, ref isUpAntiClockwise);}public void UpdateUpClockwise()//U面正向旋轉{UpdateRotateYEvent(Vector3.up, cubeDirU, targetRotationU, RotateModel.Forward, ref UpContent, ref isUpClockwise, ref isUpAntiClockwise);}public void UpdateUpAntiClockwise()//U面反向旋轉{UpdateRotateYEvent(Vector3.down, cubeDirU, targetRotationU, RotateModel.Back, ref UpContent, ref isUpAntiClockwise, ref isUpClockwise);}public void OnClickDBtn()//點擊D按鈕{ClickBtnEvent(RotateModel.Back, Axis.Y, ref DownContent, ref DownObjList, ref targetDY, ref cubeDirD, ref targetRotationD, ref isDownClockwise);}public void OnClickDAntiBtn()//點擊D'按鈕{ClickBtnEvent(RotateModel.Forward, Axis.Y, ref DownContent, ref DownObjList, ref targetDY, ref cubeDirD, ref targetRotationD, ref isDownAntiClockwise);}public void UpdateDownClockwise()//D面正向旋轉{UpdateRotateYEvent(Vector3.down, cubeDirD, targetRotationD, RotateModel.Back, ref DownContent, ref isDownClockwise, ref isDownAntiClockwise);}public void UpdateDownAntiClockwise()//D面反向旋轉{UpdateRotateYEvent(Vector3.up, cubeDirD, targetRotationD, RotateModel.Forward, ref DownContent, ref isDownAntiClockwise, ref isDownClockwise);}public void OnClickLBtn()//點擊L按鈕{ClickBtnEvent(RotateModel.Back, Axis.X, ref LeftContent, ref LeftObjList, ref targetLX, ref cubeDirL, ref targetRotationL, ref isLeftClockwise);}public void OnClickLAntiBtn()//點擊L'按鈕{ClickBtnEvent(RotateModel.Forward, Axis.X, ref LeftContent, ref LeftObjList, ref targetLX, ref cubeDirL, ref targetRotationL, ref isLeftAntiClockwise);}public void UpdateLeftClockwise()//L面正向旋轉{UpdateRotateXEvent(Vector3.left, cubeDirL, targetRotationL, RotateModel.Back, ref LeftContent, ref isLeftClockwise, ref isLeftAntiClockwise);}public void UpdateLeftAntiClockwise()//L面反向旋轉{UpdateRotateXEvent(Vector3.right, cubeDirL, targetRotationL, RotateModel.Forward, ref LeftContent, ref isLeftAntiClockwise, ref isLeftClockwise);}public void OnClickRBtn()//點擊R按鈕{ClickBtnEvent(RotateModel.Forward, Axis.X, ref RightContent, ref RightObjList, ref targetRX, ref cubeDirR, ref targetRotationR, ref isRightClockwise);}public void OnClickRAntiBtn()//點擊R'按鈕{ClickBtnEvent(RotateModel.Back, Axis.X, ref RightContent, ref RightObjList, ref targetRX, ref cubeDirR, ref targetRotationR, ref isRightAntiClockwise);}public void UpdateRightClockwise()//R面正向旋轉{UpdateRotateXEvent(Vector3.right, cubeDirR, targetRotationR, RotateModel.Forward, ref RightContent, ref isRightClockwise, ref isRightAntiClockwise);}public void UpdateRightAntiClockwise()//R面反向旋轉{UpdateRotateXEvent(Vector3.left, cubeDirR, targetRotationR, RotateModel.Back, ref RightContent, ref isRightAntiClockwise, ref isRightClockwise);}public void OnClickXBtn()//點擊X按鈕{ClickBtnEvent(RotateModel.Forward, Axis.X, ref WholeXContent, ref WholeObjList, ref targetWholeX, ref cubeDirWholeX, ref targetRotationWholeX, ref isXClockwise);}public void OnClickXAntiBtn()//點擊X'按鈕{ClickBtnEvent(RotateModel.Back, Axis.X, ref WholeXContent, ref WholeObjList, ref targetWholeX, ref cubeDirWholeX, ref targetRotationWholeX, ref isXAntiClockwise);}public void UpdateXAxisClockwise()//X軸正向旋轉{UpdateRotateXEvent(Vector3.right, cubeDirWholeX, targetRotationWholeX, RotateModel.Forward, ref WholeXContent, ref isXClockwise, ref isXAntiClockwise);}public void UpdateXAxisAntiClockwise()//X軸反向旋轉{UpdateRotateXEvent(Vector3.left, cubeDirWholeX, targetRotationWholeX, RotateModel.Back, ref WholeXContent, ref isXAntiClockwise, ref isXClockwise);}public void OnClickYBtn()//點擊Y按鈕{ClickBtnEvent(RotateModel.Forward, Axis.Y, ref WholeYContent, ref WholeObjList, ref targetWholeY, ref cubeDirWholeY, ref targetRotationWholeY, ref isYClockwise);}public void OnClickYAntiBtn()//點擊Y'按鈕{ClickBtnEvent(RotateModel.Back, Axis.Y, ref WholeYContent, ref WholeObjList, ref targetWholeY, ref cubeDirWholeY, ref targetRotationWholeY, ref isYAntiClockwise);}public void UpdateYAxisClockwise()//Y軸正向旋轉{UpdateRotateYEvent(Vector3.up, cubeDirWholeY, targetRotationWholeY, RotateModel.Forward, ref WholeYContent, ref isYClockwise, ref isYAntiClockwise);}public void UpdateYAxisAntiClockwise()//Y軸反向旋轉{UpdateRotateYEvent(Vector3.down, cubeDirWholeY, targetRotationWholeY, RotateModel.Back, ref WholeYContent, ref isYAntiClockwise, ref isYClockwise);}public void OnClickZBtn()//點擊Z按鈕{ClickBtnEvent(RotateModel.Forward, Axis.Z, ref WholeZContent, ref WholeObjList, ref targetWholeZ, ref cubeDirWholeZ, ref targetRotationWholeZ, ref isZClockwise);}public void OnClickZAntiBtn()//點擊Z'按鈕{ClickBtnEvent(RotateModel.Back, Axis.Z, ref WholeZContent, ref WholeObjList, ref targetWholeZ, ref cubeDirWholeZ, ref targetRotationWholeZ, ref isZAntiClockwise);}public void UpdateZAxisClockwise()//Z軸正向旋轉{UpdateRotateZEvent(Vector3.forward, cubeDirWholeZ, targetRotationWholeZ, RotateModel.Forward, ref WholeZContent, ref isZClockwise, ref isZAntiClockwise);}public void UpdateZAxisAntiClockwise()//Z軸反向旋轉{UpdateRotateZEvent(Vector3.back, cubeDirWholeZ, targetRotationWholeZ, RotateModel.Back, ref WholeZContent, ref isZAntiClockwise, ref isZClockwise);}//封裝點擊事件public void ClickBtnEvent(RotateModel model, Axis axis, ref GameObject nowContent,ref List<GameObject> objList,ref int targetDegree,ref Direction cubeDir,ref Quaternion targetRotation,ref bool isRotateStart){if (isPlaying)return;foreach (GameObject cubeObj in objList){cubeObj.transform.SetParent(nowContent.transform);}targetDegree += (int)model;int index = targetDegree % 360;if (index == -270)index = 90;if (index == 270)index = -90;if (index == 180)index = -180;//Debug.Log("Dir:" + cubeDir);cubeDir = (Direction)index;switch (axis){case Axis.X:targetRotation = Quaternion.Euler((float)cubeDir, 0, 0);break;case Axis.Y:targetRotation = Quaternion.Euler(0, (float)cubeDir, 0);break;case Axis.Z:targetRotation = Quaternion.Euler(0, 0, (float)cubeDir);break;default:break;}if (nowContent.GetComponent<Rigidbody>() != null)Destroy(nowContent.GetComponent<Rigidbody>());isRotateStart = true;prevContent = nowContent;}//魔方旋轉(x軸)public void UpdateRotateXEvent(Vector3 rotateDir, Direction cubeDir, Quaternion targetRotation, RotateModel model, ref GameObject nowContent, ref bool isRotateStart, ref bool isRotateAntiStart){if (isRotateStart){isPlaying = isRotateStart;nowContent.transform.Rotate(rotateDir * Time.deltaTime * rotateSpeed);//Debug.Log("X:" + nowContent.transform.localRotation.x);//Debug.Log("X2:" + targetRotation.x);bool isBreak = false;switch (model){case RotateModel.Forward:{switch (cubeDir){case Direction.First:{if (nowContent.transform.localRotation.x >= targetRotation.x){isBreak = true;}}break;case Direction.Second:{if (nowContent.transform.localRotation.x >= -targetRotation.x - 0.0001f){isBreak = true;}}break;case Direction.Third:{if (nowContent.transform.localRotation.x >= targetRotation.x){isBreak = true;}}break;case Direction.Fourth:{if (nowContent.transform.localRotation.x >= targetRotation.x){isBreak = true;}}break;}}break;case RotateModel.Back:{switch (cubeDir){case Direction.First:{if (nowContent.transform.localRotation.x <= targetRotation.x){isBreak = true;}}break;case Direction.Second:{if (nowContent.transform.localRotation.x <= targetRotation.x + 0.0001f){isBreak = true;}}break;case Direction.Third:{if (nowContent.transform.localRotation.x >= -targetRotation.x){isBreak = true;}}break;case Direction.Fourth:{if (nowContent.transform.localRotation.x <= targetRotation.x){isBreak = true;}}break;}}break;}if (isBreak){nowContent.transform.localRotation = targetRotation;isRotateStart = false;isRotateAntiStart = false;Rigidbody rigidbody = nowContent.AddComponent<Rigidbody>();rigidbody.useGravity = false;isPlaying = isRotateStart;}}}//魔方旋轉(y軸)public void UpdateRotateYEvent(Vector3 rotateDir, Direction cubeDir, Quaternion targetRotation, RotateModel model, ref GameObject nowContent, ref bool isRotateStart, ref bool isRotateAntiStart){if (isRotateStart){isPlaying = isRotateStart;nowContent.transform.Rotate(rotateDir * Time.deltaTime * rotateSpeed);bool isBreak = false;switch (model){case RotateModel.Forward:{switch (cubeDir){case Direction.First:{if (nowContent.transform.localRotation.y >= targetRotation.y){isBreak = true;}}break;case Direction.Second:{if (nowContent.transform.localRotation.y >= -targetRotation.y - 0.0001f){isBreak = true;}}break;case Direction.Third:{if (nowContent.transform.localRotation.y >= targetRotation.y){isBreak = true;}}break;case Direction.Fourth:{if (nowContent.transform.localRotation.y >= targetRotation.y){isBreak = true;}}break;}}break;case RotateModel.Back:{switch (cubeDir){case Direction.First:{if (nowContent.transform.localRotation.y <= targetRotation.y){isBreak = true;}}break;case Direction.Second:{if (nowContent.transform.localRotation.y <= targetRotation.y + 0.0001f){isBreak = true;}}break;case Direction.Third:{if (nowContent.transform.localRotation.y >= -targetRotation.y){isBreak = true;}}break;case Direction.Fourth:{if (nowContent.transform.localRotation.y <= targetRotation.y){isBreak = true;}}break;}}break;}if (isBreak){nowContent.transform.localRotation = targetRotation;isRotateStart = false;isRotateAntiStart = false;Rigidbody rigidbody = nowContent.AddComponent<Rigidbody>();rigidbody.useGravity = false;isPlaying = isRotateStart;}}}//魔方旋轉(z軸)public void UpdateRotateZEvent(Vector3 rotateDir, Direction cubeDir, Quaternion targetRotation,RotateModel model, ref GameObject nowContent, ref bool isRotateStart, ref bool isRotateAntiStart){if (isRotateStart){isPlaying = isRotateStart;nowContent.transform.Rotate(rotateDir * Time.deltaTime * rotateSpeed);bool isBreak = false;switch (model) {case RotateModel.Forward:{switch (cubeDir){case Direction.First:{if (nowContent.transform.localRotation.z >= targetRotation.z){isBreak = true;}}break;case Direction.Second:{if (nowContent.transform.localRotation.z >= -targetRotation.z - 0.0001f){isBreak = true;}}break;case Direction.Third:{if (nowContent.transform.localRotation.z >= targetRotation.z){isBreak = true;}}break;case Direction.Fourth:{if (nowContent.transform.localRotation.z >= targetRotation.z){isBreak = true;}}break;}}break;case RotateModel.Back:{switch (cubeDir){case Direction.First:{if (nowContent.transform.localRotation.z <= targetRotation.z){isBreak = true;}}break;case Direction.Second:{if (nowContent.transform.localRotation.z <= targetRotation.z + 0.0001f){isBreak = true;}}break;case Direction.Third:{if (nowContent.transform.localRotation.z >= -targetRotation.z){isBreak = true;}}break;case Direction.Fourth:{if (nowContent.transform.localRotation.z <= targetRotation.z){isBreak = true;}}break;}}break;}if (isBreak){nowContent.transform.localRotation = targetRotation;isRotateStart = false;isRotateAntiStart = false;Rigidbody rigidbody = nowContent.AddComponent<Rigidbody>();rigidbody.useGravity = false;isPlaying = isRotateStart;}}} }FrontContentTrigger.cs
using System.Collections; using System.Collections.Generic; using UnityEngine;public class FrontContentTrigger : MonoBehaviour {private void OnTriggerEnter(Collider other){if (other.gameObject.tag == "Cube")if(!GameController.Instance.FrontObjList.Contains(other.gameObject))GameController.Instance.FrontObjList.Add(other.gameObject);}private void OnTriggerExit(Collider other){if (other.gameObject.tag == "Cube")if(GameController.Instance.FrontObjList.Contains(other.gameObject))GameController.Instance.FrontObjList.Remove(other.gameObject);}}BackContentTrigger.cs
using System.Collections; using System.Collections.Generic; using UnityEngine;public class BackContentTrigger : MonoBehaviour {private void OnTriggerEnter(Collider other){if (other.gameObject.tag == "Cube")if (!GameController.Instance.BackObjList.Contains(other.gameObject))GameController.Instance.BackObjList.Add(other.gameObject); }private void OnTriggerExit(Collider other){if (other.gameObject.tag == "Cube")if (GameController.Instance.BackObjList.Contains(other.gameObject))GameController.Instance.BackObjList.Remove(other.gameObject);}}UpContentTrigger.cs
using System.Collections; using System.Collections.Generic; using UnityEngine;public class UpContentTrigger : MonoBehaviour {private void OnTriggerEnter(Collider other){if (other.gameObject.tag == "Cube")if (!GameController.Instance.UpObjList.Contains(other.gameObject))GameController.Instance.UpObjList.Add(other.gameObject);}private void OnTriggerExit(Collider other){if (other.gameObject.tag == "Cube")if (GameController.Instance.UpObjList.Contains(other.gameObject))GameController.Instance.UpObjList.Remove(other.gameObject);}}DownContentTrigger.cs
using System.Collections; using System.Collections.Generic; using UnityEngine;public class DownContentTrigger : MonoBehaviour {private void OnTriggerEnter(Collider other){if (other.gameObject.tag == "Cube")if (!GameController.Instance.DownObjList.Contains(other.gameObject))GameController.Instance.DownObjList.Add(other.gameObject);}private void OnTriggerExit(Collider other){if (other.gameObject.tag == "Cube")if (GameController.Instance.DownObjList.Contains(other.gameObject))GameController.Instance.DownObjList.Remove(other.gameObject);}}LeftContentTrigger.cs
using System.Collections; using System.Collections.Generic; using UnityEngine;public class LeftContentTrigger : MonoBehaviour {private void OnTriggerEnter(Collider other){if (other.gameObject.tag == "Cube")if (!GameController.Instance.LeftObjList.Contains(other.gameObject))GameController.Instance.LeftObjList.Add(other.gameObject);}private void OnTriggerExit(Collider other){if (other.gameObject.tag == "Cube")if (GameController.Instance.LeftObjList.Contains(other.gameObject))GameController.Instance.LeftObjList.Remove(other.gameObject);}}RightContentTrigger.cs
using System.Collections; using System.Collections.Generic; using UnityEngine;public class RightContentTrigger : MonoBehaviour {private void OnTriggerEnter(Collider other){if (other.gameObject.tag == "Cube")if (!GameController.Instance.RightObjList.Contains(other.gameObject))GameController.Instance.RightObjList.Add(other.gameObject);}private void OnTriggerExit(Collider other){if (other.gameObject.tag == "Cube")if (GameController.Instance.RightObjList.Contains(other.gameObject))GameController.Instance.RightObjList.Remove(other.gameObject);}}寫完腳本以后,我們把GameController腳本掛到MainCamera上,然后吧場景中對應的游戲物體拖上去,如下圖:
接著,把FrontContent到RightContent對應的觸發器腳本掛上,同時,需要注意的是,要把27個Cube游戲物體的tag值,改成“Cube”。整個魔方的控制,就算完成了。
按上面的按鈕可以整體轉動魔方,按下面的按鈕可以轉動單獨的某個魔方面。
以上。
總結
以上是生活随笔為你收集整理的Unity做一个魔方的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 基于运放的功率放大器设计
- 下一篇: Java 常用限流算法解析