Help me pls
1 script error :Chat.js(16,12): BCE0019: ‘AddLineToChat’ is not a member of ‘Object’.
var GlobalChat;
var TextTyping: String= "";
var Name:String="Adam";
function Start(){
GlobalChat=GameObject.Find("GlobalChat").GetComponent("ArrayChatTest");
}
function OnGUI () {
TextTyping = GUI.TextField (Rect (10, Screen.height-22, 500, 22), TextTyping,90);
}
function Update(){
if(Input.GetKeyDown(KeyCode.Return)){
if(TextTyping!=""){
GlobalChat.AddLineToChat(Name,TextTyping);
TextTyping="";
}
}
}
and 2 script error :
Test.js(20,14): BCE0004: Ambiguous reference ‘Label’: UnityEngine.GUI.Label(UnityEngine.Rect, UnityEngine.GUIContent), UnityEngine.GUI.Label(UnityEngine.Rect, UnityEngine.Texture), UnityEngine.GUI.Label(UnityEngine.Rect, String).
private var SaidStuff=new Array();
private var scrollPosition : Vector2 = Vector2.zero;
function Start(){
AddLineToChat("","Welcome to my chat test!");
AddLineToChat("","type /Help for some basic commands");
}
function OnGUI () {
var ViewPort=(25*(SaidStuff.length-4));
if(ViewPort<0){
ViewPort=0;
}
scrollPosition = GUI.BeginScrollView (Rect (10,Screen.height-150,420,100),scrollPosition, Rect (0, 0, 400,100+ViewPort),false,true);
var HeightOfBox=(25*(SaidStuff.length-4));
if(HeightOfBox<0){
HeightOfBox=0;
}
GUI.Box(Rect(0,0,400,100+HeightOfBox)," ");
for(var i : int =0; i<SaidStuff.length; i++){
GUI.Label(Rect(0,(25*i),400,23),SaidStuff[i]);
}
GUI.EndScrollView();
}
function AddLineToChat(Name:String,Text : String){
SaidStuff.Push(Text);
if(Text=="/Help"){
DisplayHelp();
}
if(Text=="/Top"){
scrollPosition=Vector2.zero;
} else{
var LowestSpot:Vector2=Vector2(0,25*(SaidStuff.length-4));
if(LowestSpot.y<0){
LowestSpot.y=0;
}
scrollPosition=LowestSpot;
}
if(Text=="/Clear"){
SaidStuff.length=0;
AddLineToChat("","Cleared chat");
}
}
function DisplayHelp(){
AddLineToChat(""," ");
AddLineToChat("","Here are some commands!");
AddLineToChat("","/Clear to clear your chat history");
AddLineToChat("","/Top to go back to the top");
}