初心者です。「UnityではじめるC#4」という本を片手に脱出ゲームのスクリプトを組んでいます。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class GameManager : MonoBehaviour
{
//定数定義:壁方向 public const int WALL_FRONT = 1; //前 public const int WALL_RIGHT = 2; //右 public const int WALL_BACK = 3; //後 public const int WALL_LEFT = 4; //左 public GameObject panelWalls; //壁全体 public GameObject buttonMessage; //ボタン:メッセージ public GameObject buttonMessageText;//メッセージテキスト private int wallNo; //現在の向いている方向 // Use this for initialization void Start() { wallNo = WALL_FRONT; //スタート時点では前を向く } // Update is called once per frame void Update() { //メモをタップ public void PushButtonMemo(){ DisplayMessage("エッフェル塔と書いてある。"); } //メッセージをタップ public void PushButtomMessage(){ buttonMessage.SetActive (false); //メッセージを消す } //右(>)ボタンを押した public void PushButtonRight(){ wallNo++; // 方向を1つ右に // 「左」の1つ右は「前」 if (wallNo > WALL_LEFT) { wallNo = WALL_FRONT; } DisplayWall(); //壁画面更新 } //左(<)ボタンを押した public void PushButtonLeft() { wallNo--; // 方向を1つ左に // 「前」の1つ左は「左」 if (wallNo < WALL_FRONT) { wallNo = WALL_LEFT; } DisplayWall(); //壁画面更新 } //メッセージを表示 void DisplayMessage(string mes) { buttonMessage.SetActive(true); buttonMessageText.GetComponent<Text> ().text = mes;
}
//向いている方向の壁を表示 void DisplayWall() { switch (wallNo) { case WALL_FRONT: panelWalls.transform.localPosition = new Vector3(0.0f, 0.0f, 0.0f); break; case WALL_RIGHT: panelWalls.transform.localPosition = new Vector3(-1000.0f, 0.0f, 0.0f); break; case WALL_BACK: panelWalls.transform.localPosition = new Vector3(-2000.0f, 0.0f, 0.0f); break; case WALL_LEFT: panelWalls.transform.localPosition = new Vector3(-3000.0f, 0.0f, 0.0f); break; } } }
}
この中の
//メモをタップ
public void PushButtonMemo(){
DisplayMessage("エッフェル塔と書いてある。");
}
PushButtonMemoの部分で「CS8025 機能ローカル関数
はC#4では対応できません。7.0以上の言語バージョンをお使いください。」と出てきます。
スクリプト作業をしているとこのエラーがしょっちゅう出てきます。
プロパティのビルド部分で言語バージョンを変えられるらしいという情報もありましたが、どこの事だかまったくわかりません。
よければアドバイスをお願いします。
また、CS0106 修飾子public
がこの項目に対して有効ではありません。というエラーもよく出ます。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/07/13 07:29