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
-1
Question by michu86 · Apr 15, 2011 at 10:53 AM · syntax-errorcs1525

Unexpected symbol `model'

using UnityEngine; using System.Collections;

public class ChangingRoom : MonoBehaviour { private int _charModeIndex = 0; private CharacterAsset ca; private string _charModeName = "x6"; private GameObject model;

 // Use this for initialization
 void Start () {
     ca = GameObject.Find("Character Asset Manager").GetComponent<CharacterAsset>();
     InstantiateCharacterModel();


 }
 void OnGUI(){
 ChageCharacterMash();
 if(GUI.Button( new Rect( Screen.width * .5f - 95, Screen.height * 5f , 30, 30), "<")
     model.transform.Rotate(Vector3.up * Time.deltaTime * 100);
 if(GUI.Button( new Rect( Screen.width * .5f  + 65, Screen.height * 5f , 30, 30), ">")
     model.transform.Rotate(Vector3.down * Time.deltaTime * 100);
     }

 private void ChageCharacterMash(){
 if(GUI.Button(new Rect(Screen.width / 2 - 60, Screen.height - 35,120,30),_charModeName)){
     _charModeIndex++;
     InstantiateCharacterModel();
 }

} private void InstantiateCharacterModel(){ switch(_charModeIndex){ case 1: _charModeName = "camaro"; break; default: _charModeIndex = 0; _charModeName = "x6"; break;

     }
     if(transform.childCount > 0)
         for(int cnt = 0; cnt < transform.childCount ; cnt++)
             Destroy(transform.GetChild(cnt).gameObject);
     GameObject model = Instantiate(ca.characterMesh[_charModeIndex],transform.position,Quaternion.identity) as GameObject;

     model.transform.parent = transform;
     model.transform.rotation = transform.rotation;
 }

}

Comment
Add comment · Show 3
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 Wibbs 1 · Apr 15, 2011 at 11:04 AM 1
Share

Can you please format your post so the code displays correctly using the button with the 1's and 0's on it. We also need the specific error message you are getting if we are going to be able to help. Also, what are these scripts attached to?

avatar image Bunny83 · Apr 15, 2011 at 11:07 AM 1
Share

This is a page for developers to ask questions about unity that are of interest to at least one other person. It's a wiki of good questions and not a post-my-code-and-get-syntax-errors-fixed-page. You didn't even take the time to write a real question and you didn't manage to highlicht your code properly. -1

avatar image TowerOfBricks · Apr 15, 2011 at 02:46 PM 0
Share
  • for previous comments, -1 for the question.

4 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Mike 3 · Apr 15, 2011 at 11:07 AM

You're missing a closing parenthesis at the end of each of the button lines in OnGUI.

Add in an ) at the end of each of those lines and it should fix it

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
avatar image
1

Answer by marceloroca · Apr 15, 2011 at 11:08 AM

using UnityEngine;

class Test02 : MonoBehaviour { private GameObject model;

 private string _charModeName;

 private int _charModeIndex;

 private CharacterAsset ca;

 // Use this for initialization
 void Start()
 {
     ca = GameObject.Find("Character Asset Manager").GetComponent<CharacterAsset>();
     InstantiateCharacterModel();
 }

 void OnGUI()
 {
     ChageCharacterMash();
     if (GUI.Button(new Rect(Screen.width * .5f - 95, Screen.height * 5f, 30, 30), "<"))
     {
         model.transform.Rotate(Vector3.up * Time.deltaTime * 100);
     }
     if (GUI.Button(new Rect(Screen.width * .5f + 65, Screen.height * 5f, 30, 30), ">"))
     {
         model.transform.Rotate(Vector3.down * Time.deltaTime * 100);
     }
 }

 private void ChageCharacterMash()
 {
     if (GUI.Button(new Rect(Screen.width / 2 - 60, Screen.height - 35, 120, 30), _charModeName))
     {
         _charModeIndex++;
         InstantiateCharacterModel();
     }
 }
 private void InstantiateCharacterModel()
 {
     switch (_charModeIndex)
     {
         case 1: _charModeName = "camaro"; break;
         default: _charModeIndex = 0; _charModeName = "x6"; break;

     }

     if (transform.childCount > 0)
         for (int cnt = 0; cnt < transform.childCount; cnt++)
             Destroy(transform.GetChild(cnt).gameObject);

     GameObject model = Instantiate(ca.characterMesh[_charModeIndex], transform.position, Quaternion.identity) as GameObject;

     model.transform.parent = transform;
     model.transform.rotation = transform.rotation;
 }

 private class CharacterAsset : MonoBehaviour
 {
     public Object[] characterMesh;
 }

}

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
avatar image
-1

Answer by michu86 · Apr 15, 2011 at 11:07 AM

for what the cons?????

Comment
Add comment · Show 1 · 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
avatar image Bunny83 · Apr 15, 2011 at 11:15 AM 0
Share

Should that be a comment? or what? Don't post comments as answers

avatar image
-1

Answer by michu86 · Apr 15, 2011 at 11:20 AM

NullReferenceException: Object reference not set to an instance of an object ChangingRoom.InstantiateCharacterModel () (at Assets/script/ChangingRoom.cs:54) ChangingRoom.ChageCharacterMash () (at Assets/script/ChangingRoom.cs:38) ChangingRoom.OnGUI () (at Assets/script/ChangingRoom.cs:22)

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

No one has followed this question yet.

Related Questions

Really Simple C# Errors I Can't Figure Out 1 Answer

errors with zxing barcode scanner 1 Answer

error CS1525! having problems with Save scripts and following BurgZergArcade! 1 Answer

error CS1525: Unexpected symbol `)' 2 Answers

How To Read Error Messages CS1525 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