var testimg : Texture2D;
public class Panel {
var visible : boolean;
var image : Texture2D;
var x : int;
var y : int;
function Panel (timage : Texture2D ,tx : int,ty : int){
this.visible = true;
this.image = timage;
this.x = tx;
this.y = ty;
}
function register () {
if (this.visible == true){
GUI.DrawTexture(Rect(10,10,60,60),this.image, ScaleMode.ScaleToFit, true, 10.0f); //Testwise
}
}
}
var test_pan = new Panel (testimg,10,10); // testimg = NULL ?
//test_pan.image = testimg //With this piece of code it works just fine, so why it is not loaded through the constructor function?
function OnGUI () {
test_pan.register();
}
I dont know why test_pan.image = NULL, although the testimg is given through the function, hope it’s just a silly mistake.
Well… since it’s not exactly written correctly, lets start testing testimg… then test test_pan…
public class Panel {
var visible : boolean;
var image : Texture2D;
var x : int;
var y : int;
function Panel (timage : Texture2D ,tx : int,ty : int){
visible = true;
image = timage;
x = tx;
y = ty;
}
function register () {
if (this.visible == true){
GUI.DrawTexture(Rect(10,10,60,60),this.image, ScaleMode.ScaleToFit, true, 10.0f); //Testwise
}
}
}
var testimg : Texture2D;
var test_pan : Panel;
function Start(){
print(testimg);
test_pan = new Panel (testimg,10,10); // testimg = NULL ?
print(test_pan.image);
//test_pan.image = testimg //With this piece of code it works just fine, so why it is not loaded through the constructor function?
}
function OnGUI () {
test_pan.register();
}
Sorry, writing on a start() function doesn’t solved the problem. Besides the order was right even before…
Again:
why does the constructor test_pan = new Panel (testimg,10,10) does not import the image file? The intergervalues (10,10) are importet just fine. Defining the .image tag seperatly with test_pan.image = testimg; works also just fine-