|
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
(comments are locked)
|
|
I tried your code, and I get the correct output, "getting the contents now..." 1.0 "you should see contents" (in three lines). Are you sure your not doing something else screwing it up ? (Can't imagine what ...) I'm honestly not sure what is wrong. I've scoured the code looking for typos and what not, or maybe some weird null reference. One thing that is really odd is that I can access the variables within the class, like, if I did print(boxes[0].contents);, I would see 1.0. One major note is that this isn't the actual function, I was just using this to get my point across.
Mar 08 '12 at 10:22 PM
ignotuscaligo
Try just that, it works for me
#pragma strict
public class BacASableJS extends MonoBehaviour
{
public class Box
{
public var contents : float = 1.0;
function GetContents(){ return(contents); }
}
public var boxes : Box[] = new Box[10]; //10 is arbitrary
function Start()
{
for(var i = 0; i < boxes.length; i++)
boxes[i] = new Box();
}
/*function Update()
{
for(var i = 0; i < boxes.length; i++)
{
var tmpBox : Box = boxes[i];
print(tmpBox.GetContents());
}
}*/
function Update()
{
for(var i = 0; i < boxes.length; i++)
{
var tmpBox : Box = boxes[i];
print("getting the contents now..."); //added this line
print(tmpBox.GetContents());
print("you should see contents"); //and this one
}
}
}
Mar 08 '12 at 10:50 PM
Berenger
(comments are locked)
|
