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

質問編集履歴

3

文追加

2015/06/19 07:00

投稿

Anet
Anet

スコア27

title CHANGED
File without changes
body CHANGED
@@ -11,4 +11,75 @@
11
11
  上に表示しているものを使います。
12
12
  この画像は個々に分かれている数字です。
13
13
 
14
- このスコアはUnityでシーン移行後に持ってきた変数の値を一発で表示するものです。
14
+ このスコアはUnityでシーン移行後に持ってきた変数の値を一発で表示するものです。
15
+
16
+ using System;
17
+ using UnityEngine;
18
+ using System.Collections;
19
+ using UnityEngine.UI;
20
+
21
+ public class TimeCounter : MonoBehaviour
22
+ {
23
+
24
+ [SerializeField]
25
+ private Image[] images = new Image[4];
26
+
27
+ [SerializeField]
28
+ private Sprite[] numberSprites = new Sprite[10];
29
+
30
+ private float latetime = 0;
31
+ public float timeCount { get; set; }
32
+ public static float timeresult;
33
+ public static float lateresult;
34
+
35
+ void Start()
36
+ {
37
+ SetTime(900);
38
+ }
39
+
40
+ void Update()
41
+ {
42
+ //if(Input.GetKeyDown(KeyCode.Y))
43
+ //{
44
+ // timeresult = timeCount;
45
+ // lateresult = latetime;
46
+ // FadeManager.Instance.LoadLevel("Result", 0.5f);
47
+ //}
48
+ }
49
+
50
+ public void SetTime(float time)
51
+ {
52
+ timeCount = time;
53
+ StartCoroutine(TimerStart());
54
+ }
55
+
56
+ void SetNumbers(int sec, int val1, int val2)
57
+ {
58
+ string str = String.Format("{0:00}", sec);
59
+ images[val1].sprite = numberSprites[Convert.ToInt32(str.Substring(0, 1))];
60
+ images[val2].sprite = numberSprites[Convert.ToInt32(str.Substring(1, 1))];
61
+ }
62
+
63
+ IEnumerator TimerStart()
64
+ {
65
+ while (timeCount > 0)
66
+ {
67
+ int sec = Mathf.FloorToInt(timeCount % 60);
68
+ SetNumbers(sec, 2, 3);
69
+ int minu = Mathf.FloorToInt((timeCount - sec) / 60);
70
+ SetNumbers(minu, 0, 1);
71
+ yield return new WaitForSeconds(1.0f);
72
+ timeCount -= 1.0f;
73
+ latetime += 1.0f;
74
+ }
75
+ TimeOver();
76
+ }
77
+
78
+ void TimeOver()
79
+ {
80
+ timeresult = timeCount;
81
+ lateresult = latetime;
82
+ FadeManager.Instance.LoadLevel("Result", 0.5f);
83
+ }
84
+ }
85
+ 上記のスクリプトのなかにあるtimeresultとlateresultを引っ張り出したいです。

2

文の修正

2015/06/19 07:00

投稿

Anet
Anet

スコア27

title CHANGED
File without changes
body CHANGED
@@ -11,4 +11,4 @@
11
11
  上に表示しているものを使います。
12
12
  この画像は個々に分かれている数字です。
13
13
 
14
- このスコアはUnityでシーン移行後に持ってきた値を一発で表示するものです。
14
+ このスコアはUnityでシーン移行後に持ってきた変数の値を一発で表示するものです。

1

文の変更

2015/06/19 04:40

投稿

Anet
Anet

スコア27

title CHANGED
File without changes
body CHANGED
@@ -9,4 +9,6 @@
9
9
  ![イメージ説明][WIDTH:600](23e5efdb817c6d51100a7387fa8eccf2.png)
10
10
 
11
11
  上に表示しているものを使います。
12
- この画像は個々に分かれている数字です。
12
+ この画像は個々に分かれている数字です。
13
+
14
+ このスコアはUnityでシーン移行後に持ってきた値を一発で表示するものです。