こんにちは
Unity FadeManager にエラーが発生します。
どのように直せば良いでしょうか
教えてください。
よろしくお願いします。
Unityバージョン2019.4.7f1 Mac
①エラー表示
Assets/Unity-FadeManager-master/Assets/naichilab/FadeManager/Scripts/FadeManager.cs(19,5): error CS1585: Member modifier 'public' must precede the member type and name
①の翻訳
Assets / Unity-FadeManager-master / Assets / naichilab / FadeManager / Scripts / FadeManager.cs(19,5):エラーCS1585:メンバーの修飾子 'public'は、メンバーのタイプと名前の前に置く必要があります
...............................................................
エラーが発生しるFadeManagerのコード
using
1using UnityEngine.SceneManagement; 2//using System; 3//using System.Linq; 4using System.Collections; 5using System.Collections.Generic; 6 7/// <summary> 8/// シーン遷移時のフェードイン・アウトを制御するためのクラス . 9/// </summary> 10public class FadeManager : MonoBehaviour 11{ 12 13 #region Singleton 14 15 private static FadeManager instance; 16 17 public static FadeManager Instance 18 { 19 get 20 { 21 if (instance == null) 22 { 23 instance = (FadeManager)FindObjectOfType(typeof(FadeManager)); 24 25 if (instance == null) 26 { 27 Debug.LogError(typeof(FadeManager) + "is nothing"); 28 } 29 } 30 31 return instance; 32 } 33 } 34 35 #endregion Singleton 36 37 /// <summary> 38 /// デバッグモード . 39 /// </summary> 40 public bool DebugMode = true; 41 /// <summary>フェード中の透明度</summary> 42 private float fadeAlpha = 0; 43 /// <summary>フェード中かどうか</summary> 44 private bool isFading = false; 45 /// <summary>フェード色</summary> 46 public Color fadeColor = Color.black; 47 48 49 public void Awake() 50 { 51 if (this != Instance) 52 { 53 Destroy(this.gameObject); 54 return; 55 } 56 57 DontDestroyOnLoad(this.gameObject); 58 } 59 60 public void OnGUI() 61 { 62 63 // Fade . 64 if (this.isFading) 65 { 66 //色と透明度を更新して白テクスチャを描画 . 67 this.fadeColor.a = this.fadeAlpha; 68 GUI.color = this.fadeColor; 69 GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), Texture2D.whiteTexture); 70 } 71 72 if (this.DebugMode) 73 { 74 if (!this.isFading) 75 { 76 //Scene一覧を作成 . 77 //(UnityEditor名前空間を使わないと自動取得できなかったので決めうちで作成) . 78 List<string> scenes = new List<string>(); 79 scenes.Add("SampleScene"); 80 //scenes.Add ("SomeScene1"); 81 //scenes.Add ("SomeScene2"); 82 83 84 //Sceneが一つもない . 85 if (scenes.Count == 0) 86 { 87 GUI.Box(new Rect(10, 10, 200, 50), "Fade Manager(Debug Mode)"); 88 GUI.Label(new Rect(20, 35, 180, 20), "Scene not found."); 89 return; 90 } 91 92 93 GUI.Box(new Rect(10, 10, 300, 50 + scenes.Count * 25), "Fade Manager(Debug Mode)"); 94 GUI.Label(new Rect(20, 30, 280, 20), "Current Scene : " + SceneManager.GetActiveScene().name); 95 96 int i = 0; 97 foreach (string sceneName in scenes) 98 { 99 if (GUI.Button(new Rect(20, 55 + i * 25, 100, 20), "Load Level")) 100 { 101 LoadScene(sceneName, 1.0f); 102 } 103 GUI.Label(new Rect(125, 55 + i * 25, 1000, 20), sceneName); 104 i++; 105 } 106 } 107 } 108 109 110 111 } 112 113 /// <summary> 114 /// 画面遷移 . 115 /// </summary> 116 /// <param name='scene'>シーン名</param> 117 /// <param name='interval'>暗転にかかる時間(秒)</param> 118 public void LoadScene(string scene, float interval) 119 { 120 StartCoroutine(TransScene(scene, interval)); 121 } 122 123 /// <summary> 124 /// シーン遷移用コルーチン . 125 /// </summary> 126 /// <param name='scene'>シーン名</param> 127 /// <param name='interval'>暗転にかかる時間(秒)</param> 128 private IEnumerator TransScene(string scene, float interval) 129 { 130 //だんだん暗く . 131 this.isFading = true; 132 float time = 0; 133 while (time <= interval) 134 { 135 this.fadeAlpha = Mathf.Lerp(0f, 1f, time / interval); 136 time += Time.deltaTime; 137 yield return 0; 138 } 139 140 //シーン切替 . 141 SceneManager.LoadScene(scene); 142 143 //だんだん明るく . 144 time = 0; 145 while (time <= interval) 146 { 147 this.fadeAlpha = Mathf.Lerp(1f, 0f, time / interval); 148 time += Time.deltaTime; 149 yield return 0; 150 } 151 152 this.isFading = false; 153 } 154} 155コード
エラーが発生するゲーム画面のスクリプト下記
using
1using System.Collections; 2 3using UnityEngine.SceneManagement; 4 5public class TitleManager : MonoBehaviour { 6 7 // Use this for initialization 8 void Start () { 9 10 } 11 12 // Update is called once per frame 13 void Update () { 14 15 } 16 17 //スタートボタンを押した 18 public void PushStartButton() 19 { 20 //ステージ選択シーンへ 21 FadeManager.Instance.LoadScene("StageSelectScene", 1.5f); //変更 22 23 } 24} 25 26コード
...........................................................
//ステージ選択シーンへ
FadeManager.Instance.LoadScene("StageSelectScene", 1.5f);
のLoadSceneが赤くなっており、下記の指摘のような文面が出ます。
CS0121: 次のメソッドまたはプロパティ間で呼び出しが不適切です: 'FadeManager.LoadScene(string, float)' と 'FadeManager.LoadScene(string, float)'
.............................................................
参考サイト
https://materializer.co/lab/blog/139
関係あるか不明ですがUnityバージョン4.5ではエラー発生しませんでした。
4、7にしたらエラー発生しました。
................................................................
追加情報
赤い波線部分写真添付します。
回答1件
あなたの回答
tips
プレビュー