Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by ThaiThao · Dec 14, 2011 at 03:12 AM · c#unexpectedsymbol

Unexpected Symbol '_toon = new PlayerChar'

Well i have been following BergZerg tutorial for a while now and have been doing what he has been tell us to.. also mess around with his codes for a bit.. but then i got an error that's telling me _toon is a unexpected symbol? I had already created a script called PlayerChar... so what's the problem here?

using UnityEngine; using System.Collections; using System; //used for the Enum class

public class CharGen: MonoBehaviour { private PlayerChar _toon; private const int STARTING_POINTS = 350; private const int MIN_STARTING_ATTRIBUTE_VALUE = 10; private const int START_VALUE = 50; private int pointsLeft;

 private const int OFFSET = 5;
 private const int LINE_HIEGHT = 20;
 
 private const int STAT_LABEL_WIDTH = 100;
 private const int BASEVALUE_LABEL_WIDTH = 30;
 private const int BUTTON_WIDTH = 20;
 private const int BUTTON_HIEGHT = 20;
 
 private int statStartingPos = 40;
 
 
 public GUISkin mySkin;
 
 public GameObject playerPrefab;

 // Use this for initialization
 void Start () {
     GameObject pc = Instantiate(playerPrefab, Vector3.zero,    Quaternion.identity) as GameObject;
     
     pc.name = "playerchar"
     
     _toon = new PlayerChar();
     _toon.Awake();

     
     pointsLeft = STARTING_POINTS;
     
 for(int cnt = 0; cnt < Enum.GetValues(typeof(AttributeName)).Length; cnt++)    {
     _toon.GetPrimaryAttribute(cnt).BaseValue = START_VALUE;    
     pointsLeft -= (START_VALUE - MIN_STARTING_ATTRIBUTE_VALUE);
 }
 
         _toon.StatUpdate();
 
 }
 
 // Update is called once per frame
 void Update () {

 
 }
 
 void OnGUI()    {
     GUI.skin = mySkin;
     DisplayName();
     DisplayPointsLeft();
     DisplayAttribute();
     DisplayVital();
     DisplaySkill();
     
     DisplayCreateButton();
     
 }
     
 private void DisplayName()    {
     GUI.Label(new Rect(10, 10, 50, 25),    "Name:");
     _toon.Name = GUI.TextField(new Rect(65, 10, 100, 25),    _toon.Name);
     
 }
 
 private void DisplayAttribute()    {
     for(int cnt = 0; cnt < Enum.GetValues(typeof(AttributeName)).Length; cnt++)    {
         GUI.Label(new Rect(    OFFSET,                                                     //z
                                         statStartingPos + (cnt * LINE_HIEGHT),         //y
                                         STAT_LABEL_WIDTH,                                 //width
                                         LINE_HIEGHT                                                //height
                                     ), ((AttributeName)cnt).ToString());
         
         GUI.Label(new Rect(    STAT_LABEL_WIDTH + OFFSET,                     //x
                                         statStartingPos + (cnt * LINE_HIEGHT),         //y
                                         BASEVALUE_LABEL_WIDTH,                         //width
                                         LINE_HIEGHT                                                //height
                                     ), _toon.GetPrimaryAttribute(cnt).AddjustedBaseValue.ToString());
         
         if(GUI.Button(new Rect(    OFFSET + STAT_LABEL_WIDTH + BASEVALUE_LABEL_WIDTH,    //x
                                                 statStartingPos + (cnt * BUTTON_HIEGHT),                             //y
                                                 BUTTON_WIDTH,                                                                     //width
                                                 BUTTON_HIEGHT                                                                    //height
                                         ),    "-"))    {
             if( _toon.GetPrimaryAttribute(cnt).BaseValue > MIN_STARTING_ATTRIBUTE_VALUE)    {
                 _toon.GetPrimaryAttribute(cnt).BaseValue--;
                 pointsLeft++;
                         _toon.StatUpdate();
         }
         }
         
         if(GUI.Button(new Rect(    OFFSET + STAT_LABEL_WIDTH + BASEVALUE_LABEL_WIDTH + BUTTON_WIDTH,    //x
                                                 statStartingPos + (cnt * BUTTON_HIEGHT ),                                                         //y
                                                 BUTTON_WIDTH,                                                                                                 //width
                                                 BUTTON_HIEGHT                                                                                                 //height
                                             ),    "+"))    {
             if(pointsLeft > 0)    {
                 _toon.GetPrimaryAttribute(cnt).BaseValue++;
                 pointsLeft--;
                         _toon.StatUpdate();
         }
     }
 }

}

 private void DisplayVital()    {
             for(int cnt = 0; cnt < Enum.GetValues(typeof(VitalName)).Length; cnt++)    {
         GUI.Label(new Rect(OFFSET, statStartingPos + ((cnt + 8) * LINE_HIEGHT), STAT_LABEL_WIDTH, LINE_HIEGHT), ((VitalName)cnt).ToString());
         GUI.Label(new Rect(OFFSET + STAT_LABEL_WIDTH, statStartingPos + ((cnt + 8) * LINE_HIEGHT), BASEVALUE_LABEL_WIDTH, LINE_HIEGHT), _toon.GetVital(cnt).AddjustedBaseValue.ToString());
     }
 }
 
 private void DisplaySkill()    {
     for(int cnt = 0; cnt < Enum.GetValues(typeof(SkillName)).Length; cnt++)    {
         GUI.Label(new Rect(OFFSET + STAT_LABEL_WIDTH + BASEVALUE_LABEL_WIDTH + BUTTON_WIDTH * 2 + OFFSET * 2, statStartingPos + (cnt * LINE_HIEGHT), STAT_LABEL_WIDTH, LINE_HIEGHT), ((SkillName)cnt).ToString());
         GUI.Label(new Rect(OFFSET + STAT_LABEL_WIDTH + BASEVALUE_LABEL_WIDTH + BUTTON_WIDTH * 2 + OFFSET * 2 + STAT_LABEL_WIDTH, statStartingPos + (cnt * LINE_HIEGHT), BASEVALUE_LABEL_WIDTH, LINE_HIEGHT), _toon.GetSkill(cnt).AddjustedBaseValue.ToString());
     }
 }
 
 private void DisplayPointsLeft()    {
     GUI.Label(new Rect(250, 10, 100, 25),    "Points Left:"    + pointsLeft.ToString());
 }
 
 private void DisplayCreateButton()    {
     GUI.Button(new Rect(Screen.width/ 2 - 50, statStartingPos + (11 * LINE_HIEGHT), 100, LINE_HIEGHT),    "Create");
 }

}

Comment
Add comment · Show 4
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image jahroy · Dec 14, 2011 at 03:20 AM 0
Share

You forgot the semi-colon on the previous line.

avatar image Julien-Lynge · Dec 14, 2011 at 10:55 PM 0
Share

@jahroy:

Could you add your comment as an answer ins$$anonymous$$d?

avatar image jahroy · Dec 14, 2011 at 11:10 PM 0
Share

Um... sure.

Not sure why it would matter to anyone other than ThaiThao, though.

avatar image Julien-Lynge · Dec 16, 2011 at 08:44 PM 0
Share

Agreed, but at least then it gets moved out of the 'Unanswered' queue. It would be nice if they would allow us to 'answer and delete' or some such ins$$anonymous$$d.

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by jahroy · Dec 14, 2011 at 11:10 PM

You forgot the semi-colon on the previous line.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Unexpected symbol 'void' C# 1 Answer

CS1525: 60,68 Unexpected symbol MatchMaxPlayers 1 Answer

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Larger Than Smaller than not working 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges