前提
UnityでAndroidのビルドをしようとすると、以下のようにエラーが出ます。
エラーについて何度も検索し、実践しましたが、直りませんでした。
発生している問題・エラーメッセージ(一部)
C#
1Assets\My\Scripts\CoinManager.cs(16,34): error CS0103: The name 'EditorUserSettings' does not exist in the current context 2↑どうやらEditorUserSettingsというものがないといわれているが、 3unityに実際に存在しており、ビルド以外では使える。
該当のソースコード
C#
1ソースコードusing System.Collections; 2using System.Collections.Generic; 3using UnityEngine; 4using UnityEditor; 5using UnityEngine.UI; 6 7public class CoinManager : MonoBehaviour 8{ 9 public Text CoinText; 10 public int coin; 11 private const string FIRST_STARTUP_KEY = "FIRST_STARTUP_KEY"; 12 // Start is called before the first frame update 13 void Start() 14 { 15 CoinText = GetComponent<Text>(); 16 if (string.IsNullOrEmpty(EditorUserSettings.GetConfigValue(FIRST_STARTUP_KEY))) 17 { 18 EditorUserSettings.SetConfigValue(FIRST_STARTUP_KEY, FIRST_STARTUP_KEY);//初回起動フラグ設定 19 Debug.Log("初回起動だよ!"); 20 PlayerPrefs.SetInt("Coin", 1000); 21 } 22 else 23 { 24 coin = PlayerPrefs.GetInt("Coin"); 25 } 26 } 27 28 // Update is called once per frame 29 void Update() 30 { 31 coin = PlayerPrefs.GetInt("Coin"); 32 CoinText.text = PlayerPrefs.GetInt("Coin").ToString(); 33 if(Input.GetKey(KeyCode.F11)) 34 { 35 Debug.Log("初回起動だよ!"); 36 PlayerPrefs.SetInt("Coin", 1000); 37 } 38 } 39 public void CoinManagement(int number) 40 { 41 if (PlayerPrefs.GetInt("Coin") >= Mathf.Abs(number)) 42 { 43 PlayerPrefs.SetInt("Coin", (PlayerPrefs.GetInt("Coin") + number)); 44 } 45 } 46}``` 47 48### 試したこと 49エラーコードでそれぞれ検索→実践→効果なし 50「unity Android Build できない」で検索→該当記事無し 51 52### 補足情報(FW/ツールのバージョンなど) 53 54unityのバージョン:2021.2.18f1 55コードアプリ:VisualStudio2022