- Home /
 
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;
 }
  
               }  
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?
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 
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
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;
 }
  
               }  
Answer by michu86 · Apr 15, 2011 at 11:07 AM
for what the cons?????
Should that be a comment? or what? Don't post comments as answers
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)
Your answer