質問編集履歴
3
画像を追加しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -221,3 +221,5 @@
|
|
221
221
|
|
222
222
|
|
223
223
|
Unity 2018.2.8f1を使用しています。
|
224
|
+
|
225
|
+
インスペクターの画像です。![インスペクター](d18ec7a463ae49226bbc32005d7ca7ab.png)
|
2
ソースコードにコメントを追加しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -156,7 +156,7 @@
|
|
156
156
|
|
157
157
|
public void Update()
|
158
158
|
|
159
|
-
{
|
159
|
+
{ //この下は時間の表示に関するものなのでそこまで意味はないです。
|
160
160
|
|
161
161
|
if (started)
|
162
162
|
|
@@ -194,7 +194,7 @@
|
|
194
194
|
|
195
195
|
public void OnStarted()
|
196
196
|
|
197
|
-
{
|
197
|
+
{ //使う予定はありません
|
198
198
|
|
199
199
|
started = true;
|
200
200
|
|
1
変更したい変数があるソースコードを追加しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -110,6 +110,104 @@
|
|
110
110
|
|
111
111
|
|
112
112
|
|
113
|
+
さらに変更したい変数があるスクリプトも載せておきます。
|
114
|
+
|
115
|
+
```C#
|
116
|
+
|
117
|
+
using System.Collections;
|
118
|
+
|
119
|
+
using System.Collections.Generic;
|
120
|
+
|
121
|
+
using UnityEngine;
|
122
|
+
|
123
|
+
using UnityEngine.Networking;
|
124
|
+
|
125
|
+
using UnityEngine.UI;
|
126
|
+
|
127
|
+
using System;
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
public class TimeMuster : NetworkBehaviour {
|
132
|
+
|
133
|
+
//このクラスが付いたゲームオブジェクトは変更したい変数があるものです。
|
134
|
+
|
135
|
+
public float ElTime;
|
136
|
+
|
137
|
+
public Text TimeDisp;
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
[SyncVar]
|
142
|
+
|
143
|
+
public bool started = false; //変更したい変数
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
public void Start()
|
148
|
+
|
149
|
+
{
|
150
|
+
|
151
|
+
//OnStarted();
|
152
|
+
|
153
|
+
TimeDisp = GameObject.Find("NowTime").GetComponent<Text>();
|
154
|
+
|
155
|
+
}
|
156
|
+
|
157
|
+
public void Update()
|
158
|
+
|
159
|
+
{
|
160
|
+
|
161
|
+
if (started)
|
162
|
+
|
163
|
+
{
|
164
|
+
|
165
|
+
ElTime += Time.deltaTime;
|
166
|
+
|
167
|
+
int M = (int)Math.Floor(ElTime / 60d);
|
168
|
+
|
169
|
+
float S = ElTime - 60f * M;
|
170
|
+
|
171
|
+
string SSt = S.ToString("F2");
|
172
|
+
|
173
|
+
if(M == 0)
|
174
|
+
|
175
|
+
{
|
176
|
+
|
177
|
+
TimeDisp.text = SSt;
|
178
|
+
|
179
|
+
}
|
180
|
+
|
181
|
+
else
|
182
|
+
|
183
|
+
{
|
184
|
+
|
185
|
+
TimeDisp.text = M + ":" + SSt;
|
186
|
+
|
187
|
+
}
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
}
|
192
|
+
|
193
|
+
}
|
194
|
+
|
195
|
+
public void OnStarted()
|
196
|
+
|
197
|
+
{
|
198
|
+
|
199
|
+
started = true;
|
200
|
+
|
201
|
+
}
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
}
|
206
|
+
|
207
|
+
```
|
208
|
+
|
209
|
+
|
210
|
+
|
113
211
|
### 試したこと
|
114
212
|
|
115
213
|
|