I am getting this error “error CS1023: An embedded statement may not be declaration or labeled statement” in Unity and I can’t fix it. I am using this video (36. Unity3d Tutorial - Instantiating Our Character 4/5 - YouTube). So if you could can you please help me.
Thank you.
EDIT: The error is on line 77.
using UnityEngine;
using System.Collections;
using System;
public class GameSettings : MonoBehaviour {
void Awake(){
DontDestroyOnLoad(this);
}
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
public void SaveCharacterData(){
GameObject pc = GameObject.Find("pc");
PlayerCharacter pcClass = pc.GetComponent<PlayerCharacter>();
PlayerPrefs.DeleteAll();
PlayerPrefs.SetString("pc", pcClass.Name);
for(int cnt = 0; cnt < Enum.GetValues(typeof(AttributeName)).Length; cnt++) {
PlayerPrefs.SetInt(((AttributeName)cnt).ToString() + " - Base Value", pcClass.GetPrimaryAttribute(cnt).BaseValue);
PlayerPrefs.SetInt(((AttributeName)cnt).ToString() + " - Exp To Level", pcClass.GetPrimaryAttribute(cnt).ExpToLevel);
}
for(int cnt = 0; cnt < Enum.GetValues(typeof(VitalName)).Length; cnt++) {
PlayerPrefs.SetInt(((VitalName)cnt).ToString() + " - Base Value", pcClass.GetVital(cnt).BaseValue);
PlayerPrefs.SetInt(((VitalName)cnt).ToString() + " - Exp To Level", pcClass.GetVital(cnt).ExpToLevel);
PlayerPrefs.SetInt(((VitalName)cnt).ToString() + " - Current Value", pcClass.GetVital(cnt).CurValue);
PlayerPrefs.SetString(((VitalName)cnt).ToString() + " - Mods", pcClass.GetVital(cnt).GetModiyingAttributeString());
pcClass.GetVital(cnt).GetModiyingAttributeString();
}
for(int cnt = 0; cnt < Enum.GetValues(typeof(SkillName)).Length; cnt++) {
PlayerPrefs.SetInt(((SkillName)cnt).ToString() + " - Base Value", pcClass.GetSkill(cnt).BaseValue);
PlayerPrefs.SetInt(((SkillName)cnt).ToString() + " - Exp To Level", pcClass.GetSkill(cnt).ExpToLevel);
PlayerPrefs.SetString(((SkillName)cnt).ToString() + " - Mods", pcClass.GetSkill(cnt).GetModiyingAttributeString());
}
}
public void LoadCharacterData(){
GameObject pc = GameObject.Find("pc");
PlayerCharacter pcClass = pc.GetComponent<PlayerCharacter>();
pcClass.Name = PlayerPrefs.GetString("pc", "Name Me");
for(int cnt = 0; cnt < Enum.GetValues(typeof(AttributeName)).Length; cnt++) {
pcClass.GetPrimaryAttribute(cnt).BaseValue = PlayerPrefs.GetInt(((AttributeName)cnt).ToString() + " - Base Value", 0);
pcClass.GetPrimaryAttribute(cnt).ExpToLevel = PlayerPrefs.GetInt(((AttributeName)cnt).ToString() + " - Exp To Level", 0);
}
for(int cnt = 0; cnt < Enum.GetValues(typeof(VitalName)).Length; cnt++) {
pcClass.GetVital(cnt).BaseValue = PlayerPrefs.GetInt(((VitalName)cnt).ToString() + " - Base Value", 0);
pcClass.GetVital(cnt).ExpToLevel = PlayerPrefs.GetInt(((VitalName)cnt).ToString() + " - Exp To Level", 0);
string myMods = PlayerPrefs.GetString(((VitalName)cnt).ToString() + " - Mods","");
string[] mods = myMods.Split("|");
foreach(string s in mods)
string[] modStats = s.Split("_");
for(int x = 0; x < Enum.GetValues(typeof(AttributeName)).Length; x++) {
if(modStats[0] == ((AttributeName)x).ToString())
Debug.Log(modStats[0] + " = " ((AttributeName)x).ToString());
}
//pcClass.GetVital((int)VitalName.Health).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((int)AttributeName.Constitution), modStats[1]));
}
//PlayerPrefs.SetString(((VitalName)cnt).ToString() + " - Mods", pcClass.GetVital(cnt).GetModiyingAttributeString());
//pcClass.GetVital(cnt).CurValue = PlayerPrefs.GetInt(((VitalName)cnt).ToString() + " - Current Value", 0);
}
}