前提
音楽ゲームのリザルト画面を作っています。
Scoreの値が80以上でGood、60以下でBadと画像を表示させたいです。
現在エラーでセミコロンが足りないと出ます。
セミコロンを入れるように指示された場所の意味が分からず教えて頂きたいです。
調べたところ、単純な文法エラーでもこれが出るらしいのですが、初心者なので分からず困っています。
実現したいこと
エラーを取り除き、if文を機能させたいです。
発生している問題・エラーメッセージ
Assets\Script\Scoretext.cs(47,27): error CS1002: ; expected
該当のソースコード
C#
1using System; 2using System.Collections; 3using System.Collections.Generic; 4using UnityEngine; 5using UnityEngine.UI; 6using TMPro; 7 8public GameObject Good; 9public GameObject Bad; 10 11public class Scoretext : MonoBehaviour 12{ 13 //スコア加算したいtextと紐付ける 14 public float Score; 15 public TextMeshProUGUI scorecounttext; 16 int Score = 0; 17 18 //Scoretextにアクセスして実行する 19 internal static void SetScoretext() 20 { 21 throw new NotImplementedException(); 22 } 23 24 // Start is called before the first frame update 25 void Start() 26 { 27 //0からスタートする 28 Score = 0; 29 //オブジェクトを非アクティブにする 30 this.gameObject.SetActive(false); 31 //96秒後にOpen関数を実行する 32 Invoke("Open", 20); 33 } 34 35 // Update is called once per frame 36 void Update() 37 { 38 //textのフォーマットを設定する 39 scorecounttext.text = string.Format("{0}", Score); 40 41 if (Score >= 80) 42 { 43 Good.GetComponent<Image>(); 44 Good.SetActive(true); 45 } 46 47 else (Score <= 60) 48 { 49 Bad.GetComponent<Image>(); 50 Bad.SetActive(true); 51 } 52 53 } 54 55 void Open() 56 { 57 //オブジェクトをアクティブにする 58 this.gameObject.SetActive(true); 59 } 60}
試したこと
if文の表記が間違えているのかと思い調べましたが分かりませんでした。
スクリプトを何度書き直してもif文の部分のみにエラーが出ます。
補足情報(FW/ツールのバージョンなど)
Unity 2021.3.14f1
Visual Studio 2019
回答2件
下記のような回答は推奨されていません。
このような回答には修正を依頼しましょう。