문제

I started looking at the tutorials for Unity, but there is one thing that I do not understand. I changed the variable myInt in function Start to myInt1, however I get an error Unknown Identifier: 'myInt1'. Am I supposed to declare the variable first? Does #pragma strict have anything to do with it?

#pragma strict

var myInt : int = 5;


function Start (){ 
myInt = MultiplyByTwo(myInt);     
Debug.Log(myInt);                  
}



function MultiplyByTwo (number : int) : int      
{
var ret : int;
ret = number * 2;
return ret;                                
도움이 되었습니까?

해결책

In the Update function myInt1 is trying to look for a variable that does not exist, thus you must make both the variable at the top myInt1 aswell.

Also learn C# it is very similar and much more efficient!

다른 팁

Yes, you need to declare the variable first.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top