i just figured that i can't use yield in a class that is derived from the object like this:
class CLabels extends Object{
var startPoint : Vector3;
var endPoint : Vector3;
var labelRect : Rect;
var rPosx : int;
var rPosy : int;
var rWidth : int;
var rHeight : int;
var target : Transform;
var cam : MainCamera;
var lineMaterial : Material;
function DrawLabel(currentTarget : Transform){
Start();
CalculateLinePositions();
OnGUI();
OnPostRender();
MonitorRectState();
} //END OF DRAW FUNCTION
//OTHER FUNCTIONS HERE
}
basically what i was trying is to make a class that will draw label on top of selected object. it draws line from the object to the rectangle that holds information about the object. everything works fine, i should say worked fine, until i wanted to make the function that will slide the rectangle to the side when it is located on top of the object, so it doesnt obscure it. so what now? how to use coroutines?
also i am new in writing classes, i dont know if i am doing it the right way. i dont have a constructor, i dont know how to use it. also i am calling OnGUI and OnPostRender from within functions that i wrote. i dont know is that the way to do it...
thanks!
also i noticed that when i want to use image button inside the class like this:
var image : Texture2D
...
if(GUI.Button(Rect(200,200,40,40),image)){
//do something;
}
it doesnt work, if i do the same thing in the usual script that is attached to the camera i get the button image... go figure..i know i am doing something wrong but i dont know what exactly...