質問編集履歴

3

追加

2020/08/14 02:58

投稿

jo1jo2jo3
jo1jo2jo3

スコア45

test CHANGED
File without changes
test CHANGED
@@ -429,3 +429,39 @@
429
429
  関係あるか不明ですがUnityバージョン4.5ではエラー発生しませんでした。
430
430
 
431
431
  4、7にしたらエラー発生しました。
432
+
433
+
434
+
435
+
436
+
437
+ ................................................................
438
+
439
+ 追加情報
440
+
441
+ 赤い波線部分写真添付します。
442
+
443
+
444
+
445
+
446
+
447
+ ![![イメージ説明](16a827ed769b1998304e331290de5ad2.png)説明](d6664d7e9d62bed0ca7f47116abc41fb.png)](73130f13488236d8b902cc8970840344.png)
448
+
449
+
450
+
451
+ ![イメージ説明](300ebf7a4267123d18bfe2d1a8477652.png)
452
+
453
+
454
+
455
+ ![イメージ説明](065e722ac6a4acc4fa435ef9e6a61461.png)
456
+
457
+
458
+
459
+ ![イメージ説明](75a57d89b421ef487a7dc634bdec4c37.png)
460
+
461
+
462
+
463
+ ![イメージ説明](a4be05b41c7c200e1e83e34a174d80ec.png)
464
+
465
+
466
+
467
+ ![イメージ説明](1033d0b2eef59d301f18ac484582d0c2.png)

2

編集

2020/08/14 02:58

投稿

jo1jo2jo3
jo1jo2jo3

スコア45

test CHANGED
File without changes
test CHANGED
@@ -10,7 +10,7 @@
10
10
 
11
11
 
12
12
 
13
- バージョンUnity4.7f1 Mac
13
+ Unityバージョン2019.4.7f1 Mac
14
14
 
15
15
 
16
16
 
@@ -34,6 +34,10 @@
34
34
 
35
35
  using UnityEngine.SceneManagement;
36
36
 
37
+ //using System;
38
+
39
+ //using System.Linq;
40
+
37
41
  using System.Collections;
38
42
 
39
43
  using System.Collections.Generic;
@@ -52,11 +56,51 @@
52
56
 
53
57
 
54
58
 
55
-
56
-
57
-
58
-
59
- Singleton
59
+ #region Singleton
60
+
61
+
62
+
63
+ private static FadeManager instance;
64
+
65
+
66
+
67
+ public static FadeManager Instance
68
+
69
+ {
70
+
71
+ get
72
+
73
+ {
74
+
75
+ if (instance == null)
76
+
77
+ {
78
+
79
+ instance = (FadeManager)FindObjectOfType(typeof(FadeManager));
80
+
81
+
82
+
83
+ if (instance == null)
84
+
85
+ {
86
+
87
+ Debug.LogError(typeof(FadeManager) + "is nothing");
88
+
89
+ }
90
+
91
+ }
92
+
93
+
94
+
95
+ return instance;
96
+
97
+ }
98
+
99
+ }
100
+
101
+
102
+
103
+ #endregion Singleton
60
104
 
61
105
 
62
106
 
@@ -68,17 +112,17 @@
68
112
 
69
113
  public bool DebugMode = true;
70
114
 
71
- /// <summary>フェード中の透明度</summary>
115
+ /// <summary>フェード中の透明度</summary>
72
-
116
+
73
- private float fadeAlpha = 0;
117
+ private float fadeAlpha = 0;
74
-
118
+
75
- /// <summary>フェード中かどうか</summary>
119
+ /// <summary>フェード中かどうか</summary>
76
-
120
+
77
- private bool isFading = false;
121
+ private bool isFading = false;
78
-
122
+
79
- /// <summary>フェード色</summary>
123
+ /// <summary>フェード色</summary>
80
-
124
+
81
- public Color fadeColor = Color.black;
125
+ public Color fadeColor = Color.black;
82
126
 
83
127
 
84
128
 
@@ -86,262 +130,280 @@
86
130
 
87
131
  public void Awake()
88
132
 
89
- {
90
-
91
- if (this != Instance) {
92
-
93
- Destroy (this.gameObject);
94
-
95
- return;
96
-
97
- }
98
-
99
-
100
-
101
- DontDestroyOnLoad (this.gameObject);
133
+ {
134
+
135
+ if (this != Instance)
136
+
137
+ {
138
+
139
+ Destroy(this.gameObject);
140
+
141
+ return;
142
+
143
+ }
144
+
145
+
146
+
147
+ DontDestroyOnLoad(this.gameObject);
148
+
149
+ }
150
+
151
+
152
+
153
+ public void OnGUI()
154
+
155
+ {
156
+
157
+
158
+
159
+ // Fade .
160
+
161
+ if (this.isFading)
162
+
163
+ {
164
+
165
+ //色と透明度を更新して白テクスチャを描画 .
166
+
167
+ this.fadeColor.a = this.fadeAlpha;
168
+
169
+ GUI.color = this.fadeColor;
170
+
171
+ GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), Texture2D.whiteTexture);
172
+
173
+ }
174
+
175
+
176
+
177
+ if (this.DebugMode)
178
+
179
+ {
180
+
181
+ if (!this.isFading)
182
+
183
+ {
184
+
185
+ //Scene一覧を作成 .
186
+
187
+ //(UnityEditor名前空間を使わないと自動取得できなかったので決めうちで作成) .
188
+
189
+ List<string> scenes = new List<string>();
190
+
191
+ scenes.Add("SampleScene");
192
+
193
+ //scenes.Add ("SomeScene1");
194
+
195
+ //scenes.Add ("SomeScene2");
196
+
197
+
198
+
199
+
200
+
201
+ //Sceneが一つもない .
202
+
203
+ if (scenes.Count == 0)
204
+
205
+ {
206
+
207
+ GUI.Box(new Rect(10, 10, 200, 50), "Fade Manager(Debug Mode)");
208
+
209
+ GUI.Label(new Rect(20, 35, 180, 20), "Scene not found.");
210
+
211
+ return;
212
+
213
+ }
214
+
215
+
216
+
217
+
218
+
219
+ GUI.Box(new Rect(10, 10, 300, 50 + scenes.Count * 25), "Fade Manager(Debug Mode)");
220
+
221
+ GUI.Label(new Rect(20, 30, 280, 20), "Current Scene : " + SceneManager.GetActiveScene().name);
222
+
223
+
224
+
225
+ int i = 0;
226
+
227
+ foreach (string sceneName in scenes)
228
+
229
+ {
230
+
231
+ if (GUI.Button(new Rect(20, 55 + i * 25, 100, 20), "Load Level"))
232
+
233
+ {
234
+
235
+ LoadScene(sceneName, 1.0f);
236
+
237
+ }
238
+
239
+ GUI.Label(new Rect(125, 55 + i * 25, 1000, 20), sceneName);
240
+
241
+ i++;
242
+
243
+ }
244
+
245
+ }
246
+
247
+ }
248
+
249
+
250
+
251
+
252
+
253
+
254
+
255
+ }
256
+
257
+
258
+
259
+ /// <summary>
260
+
261
+ /// 画面遷移 .
262
+
263
+ /// </summary>
264
+
265
+ /// <param name='scene'>シーン名</param>
266
+
267
+ /// <param name='interval'>暗転にかかる時間(秒)</param>
268
+
269
+ public void LoadScene(string scene, float interval)
270
+
271
+ {
272
+
273
+ StartCoroutine(TransScene(scene, interval));
274
+
275
+ }
276
+
277
+
278
+
279
+ /// <summary>
280
+
281
+ /// シーン遷移用コルーチン .
282
+
283
+ /// </summary>
284
+
285
+ /// <param name='scene'>シーン名</param>
286
+
287
+ /// <param name='interval'>暗転にかかる時間(秒)</param>
288
+
289
+ private IEnumerator TransScene(string scene, float interval)
290
+
291
+ {
292
+
293
+ //だんだん暗く .
294
+
295
+ this.isFading = true;
296
+
297
+ float time = 0;
298
+
299
+ while (time <= interval)
300
+
301
+ {
302
+
303
+ this.fadeAlpha = Mathf.Lerp(0f, 1f, time / interval);
304
+
305
+ time += Time.deltaTime;
306
+
307
+ yield return 0;
308
+
309
+ }
310
+
311
+
312
+
313
+ //シーン切替 .
314
+
315
+ SceneManager.LoadScene(scene);
316
+
317
+
318
+
319
+ //だんだん明るく .
320
+
321
+ time = 0;
322
+
323
+ while (time <= interval)
324
+
325
+ {
326
+
327
+ this.fadeAlpha = Mathf.Lerp(1f, 0f, time / interval);
328
+
329
+ time += Time.deltaTime;
330
+
331
+ yield return 0;
332
+
333
+ }
334
+
335
+
336
+
337
+ this.isFading = false;
338
+
339
+ }
340
+
341
+ }
342
+
343
+ コード
344
+
345
+ ```
346
+
347
+
348
+
349
+ エラーが発生するゲーム画面のスクリプト下記
350
+
351
+ ```using UnityEngine;
352
+
353
+ using System.Collections;
354
+
355
+
356
+
357
+ using UnityEngine.SceneManagement;
358
+
359
+
360
+
361
+ public class TitleManager : MonoBehaviour {
362
+
363
+
364
+
365
+ // Use this for initialization
366
+
367
+ void Start () {
368
+
369
+
102
370
 
103
371
  }
104
372
 
105
373
 
106
374
 
107
- public void OnGUI ()
108
-
109
- {
110
-
111
-
112
-
113
- // Fade .
114
-
115
- if (this.isFading) {
116
-
117
- //色と透明度を更新して白テクスチャを描画 .
118
-
119
- this.fadeColor.a = this.fadeAlpha;
120
-
121
- GUI.color = this.fadeColor;
122
-
123
- GUI.DrawTexture (new Rect (0, 0, Screen.width, Screen.height), Texture2D.whiteTexture);
124
-
125
- }
126
-
127
-
128
-
129
- if (this.DebugMode) {
130
-
131
- if (!this.isFading) {
132
-
133
- //Scene一覧を作成 .
134
-
135
- //(UnityEditor名前空間を使わないと自動取得できなかったので決めうちで作成) .
136
-
137
- List<string> scenes = new List<string> ();
138
-
139
- scenes.Add ("SampleScene");
140
-
141
- //scenes.Add ("SomeScene1");
375
+ // Update is called once per frame
142
-
143
- //scenes.Add ("SomeScene2");
376
+
144
-
145
-
146
-
147
-
148
-
149
- //Sceneが一つもない .
150
-
151
- if (scenes.Count == 0) {
377
+ void Update () {
152
-
153
- GUI.Box (new Rect (10, 10, 200, 50), "Fade Manager(Debug Mode)");
378
+
154
-
155
- GUI.Label (new Rect (20, 35, 180, 20), "Scene not found.");
379
+
156
-
157
- return;
158
-
159
- }
160
-
161
-
162
-
163
-
164
-
165
- GUI.Box (new Rect (10, 10, 300, 50 + scenes.Count * 25), "Fade Manager(Debug Mode)");
166
-
167
- GUI.Label (new Rect (20, 30, 280, 20), "Current Scene : " + SceneManager.GetActiveScene ().name);
168
-
169
-
170
-
171
- int i = 0;
172
-
173
- foreach (string sceneName in scenes) {
174
-
175
- if (GUI.Button (new Rect (20, 55 + i * 25, 100, 20), "Load Level")) {
176
-
177
- LoadScene (sceneName, 1.0f);
178
-
179
- }
180
-
181
- GUI.Label (new Rect (125, 55 + i * 25, 1000, 20), sceneName);
182
-
183
- i++;
184
-
185
- }
186
-
187
- }
188
-
189
- }
190
-
191
-
192
-
193
-
194
-
195
-
196
380
 
197
381
  }
198
382
 
199
383
 
200
384
 
201
- /// <summary>
202
-
203
- /// 画面遷移 .
385
+ //スタートボタンを押した
204
-
205
- /// </summary>
386
+
206
-
207
- /// <param name='scene'>シーン名</param>
208
-
209
- /// <param name='interval'>暗転にかかる時間(秒)</param>
210
-
211
- public void LoadScene (string scene, float interval)
387
+ public void PushStartButton()
212
-
388
+
213
- {
389
+ {
390
+
214
-
391
+ //ステージ選択シーンへ
392
+
215
- StartCoroutine(TransScene(scene, interval));
393
+ FadeManager.Instance.LoadScene("StageSelectScene", 1.5f); //変更
216
-
394
+
395
+
396
+
217
- }
397
+ }
218
-
219
-
220
-
221
- /// <summary>
222
-
223
- /// シーン遷移用コルーチン .
224
-
225
- /// </summary>
226
-
227
- /// <param name='scene'>シーン名</param>
228
-
229
- /// <param name='interval'>暗転にかかる時間(秒)</param>
230
-
231
- private IEnumerator TransScene (string scene, float interval)
232
-
233
- {
234
-
235
- //だんだん暗く .
236
-
237
- this.isFading = true;
238
-
239
- float time = 0;
240
-
241
- while (time <= interval) {
242
-
243
- this.fadeAlpha = Mathf.Lerp (0f, 1f, time / interval);
244
-
245
- time += Time.deltaTime;
246
-
247
- yield return 0;
248
-
249
- }
250
-
251
-
252
-
253
- //シーン切替 .
254
-
255
- SceneManager.LoadScene (scene);
256
-
257
-
258
-
259
- //だんだん明るく .
260
-
261
- time = 0;
262
-
263
- while (time <= interval) {
264
-
265
- this.fadeAlpha = Mathf.Lerp (1f, 0f, time / interval);
266
-
267
- time += Time.deltaTime;
268
-
269
- yield return 0;
270
-
271
- }
272
-
273
-
274
-
275
- this.isFading = false;
276
-
277
- }
278
398
 
279
399
  }
280
400
 
401
+
402
+
281
403
  コード
282
404
 
283
405
  ```
284
406
 
285
-
286
-
287
- エラーが発生するゲーム画面のスクリプト下記
288
-
289
- ```using UnityEngine;
290
-
291
- using System.Collections;
292
-
293
-
294
-
295
- using UnityEngine.SceneManagement;
296
-
297
-
298
-
299
- public class TitleManager : MonoBehaviour {
300
-
301
-
302
-
303
- // Use this for initialization
304
-
305
- void Start () {
306
-
307
-
308
-
309
- }
310
-
311
-
312
-
313
- // Update is called once per frame
314
-
315
- void Update () {
316
-
317
-
318
-
319
- }
320
-
321
-
322
-
323
- //スタートボタンを押した
324
-
325
- public void PushStartButton()
326
-
327
- {
328
-
329
- //ステージ選択シーンへ
330
-
331
- FadeManager.Instance.LoadScene("StageSelectScene", 1.5f); //変更
332
-
333
-
334
-
335
- }
336
-
337
- }
338
-
339
-
340
-
341
- コード
342
-
343
- ```
344
-
345
407
  ...........................................................
346
408
 
347
409
  //ステージ選択シーンへ

1

編集

2020/08/14 02:28

投稿

jo1jo2jo3
jo1jo2jo3

スコア45

test CHANGED
File without changes
test CHANGED
@@ -1,6 +1,6 @@
1
1
  こんにちは
2
2
 
3
- Unity FadeManager 使用時にエラーが発生します。
3
+ Unity FadeManager にエラーが発生します。
4
4
 
5
5
  どのように直せば良いでしょうか
6
6