hello all
So the issue I’ve run into is that I have an object that I’ve defined in a .js as a class. Here’s a dummy class to describe this issue:
class Box
{
public var contents : float = 1.0;
function Box()
{
}
function GetContents()
{
return(contents);
}
}
Now, in another script, I have an array of these objects:
public var boxes : Box[] = new Box[10]; //10 is arbitrary
During the Update() cycle of this script containing the array, I cycle through each "Box" and call this function:
function Update()
{
for(var i = 0; i < boxes.length; i++)
{
var tmpBox : Box = boxes*;*
*print(tmpBox.GetContents());*
*}*
*}*
**
*Most of the time when I do this, everything functions normally in terms of actually executing this function. My issue now is that while I'm asking Unity to call that function, the program never goes into it.*
*Consider:*
**
*function Update()*
*{*
*for(var i = 0; i < boxes.length; i++)*
*{*
_var tmpBox : Box = boxes*;*_
_*print("getting the contents now..."); //added this line*_
_*print(tmpBox.GetContents());*_
_*print("you should see contents"); //and this one*_
_*}*_
_*}*_
_**_
_*I SHOULD see this as my output:*_
_**_
_*"getting the contents now..."*_
_*1.0*_
_*"you should see contents"*_
_**_
_*But what I actually get is just:*_
_**_
_*"getting the contents now..."*_
_*"you should see contents"*_
_**_
_*The function "GetContents()" never runs.*_
_*Anyone have any ideas as to what this could be? Any clarifications needed about the problem?*_
_*EDIT::*_
_*One other note I forgot, I can access the variables in said class, just not the functions. I can change box.contents, but box.GetContents() doesn't execute*_