- Home /
error CS1525! having problems with Save scripts and following BurgZergArcade!
I were following BurgZergArcade on youtube when doing the "save character data" tutorial when I got an error sayin:
Assets/Scripts/GameSettings.cs(29,31): error CS1525: Unexpected symbol `PlayerCharacter'
this is what my scripts looks like:
CharacterGeneratorScript:
using UnityEngine; using System.Collections; using System; //used for the Enum class
 
               public class CharacterGeneratorScript : MonoBehaviour { private PlayerCharacter _toon; private const int STARTING_POINTS = 350; private const int MIN_STARTING_ATTRIBUTE_VALUE = 10; private const int STARTING_VALUE = 50; private int pointsLeft;
  public GUIStyle myStyle;
 public GameObject playerPrefab;
 // Use this for initialization
 void Start () {
     GameObject pc = Instantiate(playerPrefab, Vector3.zero, Quaternion.identity) as GameObject;
     pc.name = "pc";
 // _toon = new PlayerCharacter(); // _toon.Awake(); _toon = pc.GetComponent<PlayerCharacter>();
      pointsLeft = STARTING_POINTS;
     for(int cnt = 0; cnt < Enum.GetValues(typeof(AttributeName)).Length; cnt++) {
         _toon.GetPrimaryAttribute(cnt).BaseValue = STARTING_VALUE;
         pointsLeft -= (STARTING_VALUE - MIN_STARTING_ATTRIBUTE_VALUE);
     }
     _toon.StatUpdate();
 }
 // Update is called once per frame
 void Update () {
 }
 void OnGUI() {
     DisplayName();
     DisplayAttributeText();
     DisplayVitalText();
     DisplaySkillText();
     DisplayPointsLeft();
     DisplayAttributes();
     DisplayVitals();
     DisplaySkills();
     DisplayCreateButton();
 }
 private void DisplayName() {
     GUI.Label(new Rect(10, 10, 50, 25), "Name:");
     _toon.Name = GUI.TextField(new Rect(65, 10, 200, 25), _toon.Name);
 }
     private void DisplayAttributeText() {
         GUI.Label(new Rect(10, 40, 60, 25), "Attributes:");
 }
     private void DisplayVitalText() {
         GUI.Label(new Rect(10, 255, 200, 25), "Vitals:");
 }
     private void DisplaySkillText() {
         GUI.Label(new Rect(10, 395, 150, 25), "Defence and Offence:");
 }
 private void DisplayAttributes () {
     for(int cnt = 0; cnt < Enum.GetValues(typeof(AttributeName)).Length; cnt++) {
         GUI.Label(new Rect(10, 60 + (cnt * 25), 100, 25), ((AttributeName)cnt).ToString(), myStyle);
         GUI.Label(new Rect(115, 60 + (cnt * 25), 30, 25), _toon.GetPrimaryAttribute(cnt).AdjustedBaseValue.ToString());
         if(GUI.Button(new Rect(150, 60 + (cnt * 25), 25, 25), "-", myStyle)) {
             if(_toon.GetPrimaryAttribute(cnt).BaseValue > MIN_STARTING_ATTRIBUTE_VALUE) {
                 _toon.GetPrimaryAttribute(cnt).BaseValue--;
                 pointsLeft++;
                 _toon.StatUpdate();
             }
         }
         if(GUI.Button(new Rect(180, 60 + (cnt * 25), 25, 25), "+", myStyle)) {
             if(pointsLeft > 0) {
                 _toon.GetPrimaryAttribute(cnt).BaseValue++;
                 pointsLeft--;
                 _toon.StatUpdate();
             }
         }
     }
 }
 private void DisplayVitals() {
     for(int cnt = 0; cnt < Enum.GetValues(typeof(VitalName)).Length; cnt++) {
         GUI.Label(new Rect(10, 100 + ((cnt + 7) * 25), 100, 25), ((VitalName)cnt).ToString(), myStyle);
         GUI.Label(new Rect(115, 100 + ((cnt + 7) * 25), 30, 25), _toon.GetVital(cnt).AdjustedBaseValue.ToString());
     }
 }
 private void DisplaySkills() {
         for(int cnt = 0; cnt < Enum.GetValues(typeof(SkillName)).Length; cnt++) {
         GUI.Label(new Rect(10, 250 + ((cnt + 7) * 25), 100, 25), ((SkillName)cnt).ToString(), myStyle);
         GUI.Label(new Rect(115, 250 + ((cnt + 7) * 25), 30, 25), _toon.GetSkill(cnt).AdjustedBaseValue.ToString());
     }
 }
 private void DisplayPointsLeft() {
     GUI.Label(new Rect(300, 10, 100, 25), "Points Left: " + pointsLeft.ToString());
 }
 private void DisplayCreateButton() {
     if(GUI.Button(new Rect(400, 10, 110, 25), "Create Character", myStyle)) {
         GameSettings gsScript = GameObject.Find("_GameSettings").GetComponent<GameSettings>();
         //change the cur value of the vitals to the max modified value of that vital
         gsScript.SaveCharacterData();
         Application.LoadLevel("rpg first try");
     }
 }
 } 
And GameSettings:
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();
     GameObject pc = GameObject.Find("pc")
     PlayerCharacter pcClass = pc.GetComponent<PlayerCharacter>();
     PlayerPrefs.SetString("Player Name", pcClass.Name);
     for(int cnt = 0; cnt < Enum.GetValues(typeof(AttributeName)).Length; cnt++) {
         PlayerPrefs.SetInt(((AttributeName)cnt).ToString() + " - BaseValue", 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() + " - BaseValue" , pcClass.GetVital(cnt).BaseValue);
         PlayerPrefs.SetInt(((VitalName)cnt).ToString() + " - Exp To Level" , pcClass.GetVital(cnt).ExpToLevel);
         PlayerPrefs.SetInt(((VitalName)cnt).ToString() + " - Cur Value" , pcClass.GetVital(cnt).CurValue);
     }
 }
 public void LoadCharacterData() {
 }
 } 
Where did I go wrong ?? D':
Answer by Peter G · Feb 05, 2011 at 06:49 PM
Make sure PlayerController.cs is compiled first.
how can I do that when the game isnt done yet?? and I cant recall BurgZerg doing that in his videos
Your answer
 
 
             Follow this Question
Related Questions
Really Simple C# Errors I Can't Figure Out 1 Answer
Unexpected symbol `model' 4 Answers
errors with zxing barcode scanner 1 Answer
Error CS1519! Base Character script error from BurgZerg Arcade 2 Answers
error CS1525: Unexpected symbol `)' 2 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                