teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

3

コードの記入もれ

2018/07/24 09:34

投稿

manmanJ
manmanJ

スコア19

title CHANGED
File without changes
body CHANGED
@@ -77,6 +77,7 @@
77
77
  image02.CrossFadeAlpha(0, 0f, true);
78
78
  image02.enabled = false;
79
79
  }
80
+ }
80
- }```
81
+ ```
81
82
  if文とfor文もまだ少し理解できてません。
82
83
  このコードを簡素化か修正できたらおねがいします。

2

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

2018/07/24 09:34

投稿

manmanJ
manmanJ

スコア19

title CHANGED
File without changes
body CHANGED
@@ -8,9 +8,9 @@
8
8
  using System.Collections.Generic;
9
9
  using UnityEngine;
10
10
 
11
+ public class menu02 : MonoBehaviour
12
+ {
11
13
 
12
- public class Menu01 : MonoBehaviour
13
- {
14
14
  [SerializeField] UnityEngine.UI.Text textbox01;
15
15
  [SerializeField] UnityEngine.UI.Text textbox02;
16
16
  [SerializeField] UnityEngine.UI.Text textbox03;
@@ -18,55 +18,65 @@
18
18
  [SerializeField] UnityEngine.UI.Image image02;
19
19
  public int Game_01 = 0;
20
20
 
21
+ // Use this for initialization
21
22
  void Start()
22
- { }
23
- void Update()
24
- {
23
+ {
25
24
 
25
+ }
26
+
27
+ // Update is called once per frame
26
- if (Game_01 < 1)
28
+ void Update()
29
+ {
30
+ //入力判定のみ行う。実際の表示・非表示は別メソッドへ
31
+ if (Input.GetButtonDown("メニュー"))
27
32
  {
33
+ //非表示中なら表示、そうでない場合は非表示処理を呼ぶ
34
+ if (textbox01.text == "")
35
+ {
36
+ Show();
37
+ }
38
+ else
39
+ {
40
+ Hide();
41
+ }
42
+ }
43
+ if (Input.GetButtonDown("Jump"))
44
+ {
45
+ //問答無用で非表示
46
+ Hide();
47
+ }
48
+ }
28
49
 
50
+ //表示する処理
29
- var duration = 0F;
51
+ private void Show()
52
+ {
30
- textbox01.text = "";
53
+ textbox01.text = "メニュー";
54
+ textbox01.enabled = true;
31
- textbox02.text = "";
55
+ textbox02.text = "メンバー";
56
+ textbox02.enabled = true;
32
- textbox03.text = "";
57
+ textbox03.text = "閉じる";
58
+ textbox03.enabled = true;
59
+ image01.CrossFadeColor(targetColor: Color.red, duration: 0f, ignoreTimeScale: true, useAlpha: true);
33
- image01.CrossFadeAlpha(0, duration, true);
60
+ image01.enabled = true;
61
+ image02.CrossFadeColor(targetColor: Color.yellow, duration: 0f, ignoreTimeScale: true, useAlpha: true);
34
- image02.CrossFadeAlpha(0, duration, true);
62
+ image02.enabled = true;
63
+ image02.CrossFadeColor(targetColor: Color.red, duration: 1f, ignoreTimeScale: true, useAlpha: true);
64
+ }
35
65
 
36
-
66
+ //非表示にする処理
37
- if (Input.GetButtonDown("メニュー"))
67
+ private void Hide()
38
-
39
- {
68
+ {
40
-
41
-
42
- Game_01 += 1;
43
-
44
- if (Game_01 > 0)
45
- {
46
- textbox01.text = "メニュー";
69
+ textbox01.text = "";
70
+ textbox01.enabled = false;
47
- textbox02.text = "メンバー";
71
+ textbox02.text = "";
72
+ textbox02.enabled = false;
48
- textbox03.text = "閉じる";
73
+ textbox03.text = "";
49
- image01.CrossFadeColor(targetColor: Color.red, duration: duration, ignoreTimeScale: true, useAlpha: true);
50
- image02.CrossFadeColor(targetColor: Color.yellow, duration: duration, ignoreTimeScale: true, useAlpha: true);
51
- image02.CrossFadeColor(targetColor: Color.red, duration: 1f, ignoreTimeScale: true, useAlpha: true);
74
+ textbox03.enabled = false;
52
-
53
- if (Input.GetButtonDown("Jump"))
75
+ image01.CrossFadeAlpha(0, 0f, true);
54
- {
55
- Game_01 -= 1;
76
+ image01.enabled = false;
56
- }
57
-
58
- if (Input.GetButtonDown("メニュー"))
77
+ image02.CrossFadeAlpha(0, 0f, true);
59
- {
60
- Game_01 -= 1;
78
+ image02.enabled = false;
61
- }
62
- }
63
- else { }
64
- }
65
-
66
- }
67
- else { }
68
79
  }
69
- }
70
- ```
80
+ }```
71
81
  if文とfor文もまだ少し理解できてません。
72
82
  このコードを簡素化か修正できたらおねがいします。

1

コードの記入もれ

2018/07/24 09:31

投稿

manmanJ
manmanJ

スコア19

title CHANGED
File without changes
body CHANGED
@@ -2,7 +2,7 @@
2
2
  ポーズ画面の項目が一瞬うつるだけになります
3
3
 
4
4
 
5
- ### 該当のソースコード
5
+ ```ここに言語を入力
6
6
 
7
7
  using System.Collections;
8
8
  using System.Collections.Generic;
@@ -66,4 +66,7 @@
66
66
  }
67
67
  else { }
68
68
  }
69
- }
69
+ }
70
+ ```
71
+ if文とfor文もまだ少し理解できてません。
72
+ このコードを簡素化か修正できたらおねがいします。