質問編集履歴

3

コードの記入もれ

2018/07/24 09:34

投稿

manmanJ
manmanJ

スコア19

test CHANGED
File without changes
test CHANGED
@@ -156,7 +156,9 @@
156
156
 
157
157
  }
158
158
 
159
+ }
160
+
159
- }```
161
+ ```
160
162
 
161
163
  if文とfor文もまだ少し理解できてません。
162
164
 

2

解決後に不具合がないのか確認のため

2018/07/24 09:34

投稿

manmanJ
manmanJ

スコア19

test CHANGED
File without changes
test CHANGED
@@ -18,11 +18,11 @@
18
18
 
19
19
 
20
20
 
21
+ public class menu02 : MonoBehaviour
22
+
23
+ {
21
24
 
22
25
 
23
- public class Menu01 : MonoBehaviour
24
-
25
- {
26
26
 
27
27
  [SerializeField] UnityEngine.UI.Text textbox01;
28
28
 
@@ -38,105 +38,125 @@
38
38
 
39
39
 
40
40
 
41
+ // Use this for initialization
42
+
41
43
  void Start()
42
44
 
43
- { }
45
+ {
44
46
 
47
+
48
+
49
+ }
50
+
51
+
52
+
53
+ // Update is called once per frame
54
+
45
- void Update()
55
+ void Update()
56
+
57
+ {
58
+
59
+ //入力判定のみ行う。実際の表示・非表示は別メソッドへ
60
+
61
+ if (Input.GetButtonDown("メニュー"))
46
62
 
47
63
  {
48
64
 
65
+ //非表示中なら表示、そうでない場合は非表示処理を呼ぶ
49
66
 
67
+ if (textbox01.text == "")
50
68
 
69
+ {
70
+
71
+ Show();
72
+
73
+ }
74
+
75
+ else
76
+
77
+ {
78
+
79
+ Hide();
80
+
81
+ }
82
+
83
+ }
84
+
51
- if (Game_01 < 1)
85
+ if (Input.GetButtonDown("Jump"))
52
86
 
53
87
  {
54
88
 
89
+ //問答無用で非表示
55
90
 
91
+ Hide();
56
92
 
57
- var duration = 0F;
93
+ }
58
94
 
59
- textbox01.text = "";
95
+ }
60
-
61
- textbox02.text = "";
62
-
63
- textbox03.text = "";
64
-
65
- image01.CrossFadeAlpha(0, duration, true);
66
-
67
- image02.CrossFadeAlpha(0, duration, true);
68
96
 
69
97
 
70
98
 
71
-
99
+ //表示する処理
72
100
 
101
+ private void Show()
102
+
103
+ {
104
+
73
- if (Input.GetButtonDown("メニュー"))
105
+ textbox01.text = "メニュー";
106
+
107
+ textbox01.enabled = true;
108
+
109
+ textbox02.text = "メンバー";
110
+
111
+ textbox02.enabled = true;
112
+
113
+ textbox03.text = "閉じる";
114
+
115
+ textbox03.enabled = true;
116
+
117
+ image01.CrossFadeColor(targetColor: Color.red, duration: 0f, ignoreTimeScale: true, useAlpha: true);
118
+
119
+ image01.enabled = true;
120
+
121
+ image02.CrossFadeColor(targetColor: Color.yellow, duration: 0f, ignoreTimeScale: true, useAlpha: true);
122
+
123
+ image02.enabled = true;
124
+
125
+ image02.CrossFadeColor(targetColor: Color.red, duration: 1f, ignoreTimeScale: true, useAlpha: true);
126
+
127
+ }
74
128
 
75
129
 
76
130
 
77
- {
131
+ //非表示にする処理
78
132
 
79
-
133
+ private void Hide()
80
134
 
81
-
135
+ {
82
136
 
83
- Game_01 += 1;
137
+ textbox01.text = "";
84
138
 
139
+ textbox01.enabled = false;
85
140
 
141
+ textbox02.text = "";
86
142
 
87
- if (Game_01 > 0)
143
+ textbox02.enabled = false;
88
144
 
89
- {
145
+ textbox03.text = "";
90
146
 
91
- textbox01.text = "メニュー";
147
+ textbox03.enabled = false;
92
148
 
93
- textbox02.text = "メンバー";
149
+ image01.CrossFadeAlpha(0, 0f, true);
94
150
 
95
- textbox03.text = "閉じる";
151
+ image01.enabled = false;
96
152
 
97
- image01.CrossFadeColor(targetColor: Color.red, duration: duration, ignoreTimeScale: true, useAlpha: true);
153
+ image02.CrossFadeAlpha(0, 0f, true);
98
154
 
99
- image02.CrossFadeColor(targetColor: Color.yellow, duration: duration, ignoreTimeScale: true, useAlpha: true);
100
-
101
- image02.CrossFadeColor(targetColor: Color.red, duration: 1f, ignoreTimeScale: true, useAlpha: true);
102
-
103
-
104
-
105
- if (Input.GetButtonDown("Jump"))
106
-
107
- {
108
-
109
- Game_01 -= 1;
155
+ image02.enabled = false;
110
-
111
- }
112
-
113
-
114
-
115
- if (Input.GetButtonDown("メニュー"))
116
-
117
- {
118
-
119
- Game_01 -= 1;
120
-
121
- }
122
-
123
- }
124
-
125
- else { }
126
-
127
- }
128
-
129
-
130
-
131
- }
132
-
133
- else { }
134
156
 
135
157
  }
136
158
 
137
- }
138
-
139
- ```
159
+ }```
140
160
 
141
161
  if文とfor文もまだ少し理解できてません。
142
162
 

1

コードの記入もれ

2018/07/24 09:31

投稿

manmanJ
manmanJ

スコア19

test CHANGED
File without changes
test CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
 
8
8
 
9
- ### 該当のソースコード
9
+ ```ここに言語を入力
10
10
 
11
11
 
12
12
 
@@ -135,3 +135,9 @@
135
135
  }
136
136
 
137
137
  }
138
+
139
+ ```
140
+
141
+ if文とfor文もまだ少し理解できてません。
142
+
143
+ このコードを簡素化か修正できたらおねがいします。