well i get an erro that says “unexpected symbol ‘model’” why does it not recognize the game object …
the script is in C#:
using UnityEngine;
using System.Collections;
public class ChangeingRoom : MonoBehaviour {
private int _charModelIndex =0;
private CharacterAssets ca;
private string _charModelName = "Blue Trainer";
private GameObject model;
// Use this for initialization
void Start () {
ca = GameObject.Find("CharacterAssetManager").GetComponent<CharacterAssets>();
InstantiateCharacterModel();
}
void OnGUI(){
ChangeCharacterMesh();
if(GUI.Button(new Rect(Screen.width*.5f-95,Screen.height-35,30,30), "<")
model.transform.Rotate(Vector3.up*Time.deltaTime*100);
if(GUI.Button(new Rect(Screen.width*.5f+65,Screen.height-35,30,30), ">")
model.transform.Rotate(Vector3.down *Time.deltaTime*100);
}
private void ChangeCharacterMesh(){
if(GUI.Button(new Rect(Screen.width / 2 - 60,Screen.height - 35, 120,30),_charModelName)){
_charModelIndex++;
InstantiateCharacterModel();
}
}
private void InstantiateCharacterModel() {
switch(_charModelIndex){
case 1:
_charModelName = "Green Trainer";
break;
case 2 :
_charModelName = "Red Trainer";
break;
case 3 :
_charModelName = "White Trainer";
break;
default :
_charModelIndex = 0;
_charModelName = "Blue Trainer";
break;
}
if(transform.childCount > 0)
for(int cnt = 0; cnt < transform.childCount; cnt++)
Destroy(transform.GetChild(cnt).gameObject);
model = Instantiate(ca.characterMesh[_charModelIndex], transform.position, Quaternion.identity) as GameObject;
model.transform.parent = transform;
model.transform.rotation = transform.rotation;
//model.animation["idle1"].wrapMode = WrapMode.Loop;
//model.animation.Play("idle1");
}
}