Domanda

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;                                
È stato utile?

Soluzione

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!

Altri suggerimenti

Yes, you need to declare the variable first.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top