- Home /
Question by
dzone_adm · May 18, 2011 at 08:17 AM ·
inspectorclassesconstructor
Assiging a texture in the inspector for use in a Class.
Could someone help me with the following? I would like to be able to use the inspector to set the default settings of my class. In particular a texture used in the class.
class SpawnLabel {
var labelTexture : Texture2D;
var labelRect : Rect;
var labelTitle: String;
function spawnLabel (inRect, inTitle) {
labelRect = inRect;
labelTitle= inTitle;
}
function guiLabel(){
GUI.Label(labelRect, labelTitle, labelTexture);
}
}
Is there a way to set the labelTexture without sending it into the constructor every time I want to make an instance of this class?
labelTexture is not available in the inspector, neither can I define a texture outside the class and then go "labelTexture : Texture2D = textureDefinedOutsideClass;" What is the correct way to do this? Thanks in advance :)
Comment
Answer by Dreamer · May 18, 2011 at 08:40 AM
var textureDefinedOutsideClass:Texture2D;
class SpawnLabel {
var labelTexture : Texture2D;
var labelRect : Rect;
var labelTitle: String;
spawnLabel (inRect, inTitle) {
labelTexture = textureDefinedOutsideClass;
labelRect = inRect;
labelTitle= inTitle;
}
guiLabel{
GUI.Label(labelRect, labelTitle, labelTexture);
}
}