**Unityで始めるc#**という本を読みながら脱出ゲームを作っています。
c#
1using System.Collections; 2using System.Collections.Generic; 3using UnityEngine; 4using UnityEngine.SceneManagement; 5using UnityEngine.UI; 6 7public class GameManeger : MonoBehaviour { 8 public const int WALL_1 = 1; 9 public const int WALL_2 = 2; 10 public const int WALL_3 = 3; 11 public const int WALL_4 = 4; 12 public const int WALL_5 = 5; 13 public const int WALL_6 = 6; 14 public const int WALL_7 = 7; 15 public const int WALL_8 = 8; 16 public const int WALL_9 = 9; 17 public const int WALL_10 = 10; 18 public const int WALL_11 = 11; 19 20 public GameObject panelWalls; 21 22 private int wallNo; 23 24 // Use this for initialization 25 void Start () { 26 wallNo = WALL_1; 27 } 28 29 // Update is called once per frame 30 void Update () { 31 32 } 33 34 public void PushButtonRight(){ 35 wallNo++; 36 if (wallNo > WALL_11){ 37 wallNo = 1; 38 } 39 DisplayWall(); 40 } 41 42 void DisplayWall(){ 43 switch (wallNo) { 44 case WALL_1: 45 panelWalls.transform.localPosition = new Vector3(0.0f, 0.0f, 0.0f); 46 break; 47 48 case WALL_2: 49 panelWalls.transform.localPosition = new Vector3(-2000.0f, 0.0f, 0.0f); 50 break; 51 52 case WALL_3: 53 panelWalls.transform.localPosition = new Vector3(-4000.0f, 0.0f, 0.0f); 54 break; 55 56 case WALL_4: 57 panelWalls.transform.localPosition = new Vector3(-6000.0f, 0.0f, 0.0f); 58 break; 59 60 case WALL_5: 61 panelWalls.transform.localPosition = new Vector3(-8000.0f, 0.0f, 0.0f); 62 break; 63 64 case WALL_6: 65 panelWalls.transform.localPosition = new Vector3(-10000.0f, 0.0f, 0.0f); 66 break; 67 68 case WALL_7: 69 panelWalls.transform.localPosition = new Vector3(-12000.0f, 0.0f, 0.0f); 70 break; 71 72 case WALL_8: 73 panelWalls.transform.localPosition = new Vector3(-14000.0f, 0.0f, 0.0f); 74 break; 75 76 case WALL_9: 77 panelWalls.transform.localPosition = new Vector3(-16000.0f, 0.0f, 0.0f); 78 break; 79 80 case WALL_10: 81 panelWalls.transform.localPosition = new Vector3(-18000.0f, 0.0f, 0.0f); 82 break; 83 84 case WALL_11: 85 panelWalls.transform.localPosition = new Vector3(-20000.0f, 0.0f, 0.0f); 86 break; 87 } 88 } 89} 90
パネルを11枚作っていて、クリックすれば次のパネルになるように作っています。そこで次のパネルに移る時にフェードインフェードアウトをしたいのですがどうすればいいでしょうか?
またもうちょっとコードを短かくかける方法があれば教えていただけたら嬉しいです。よろしくお願いします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/12/13 04:22