hello, i’m using unity to do my university project…
i used GUI.Button to do all and very thing worked well
…
i used GUI Skin Empty(i remove all images)
but…
in some where else when i call GUI.Label nothing work well, but one i change it to GUI.Button it work well…
Please take a look:
Variable
var gSkin:GUISkin;
var gSkinEmpty:GUISkin;
var questionFont:Font;
var backGround :Texture2D;
var qMark :Texture2D;
var aMark :Texture2D;
var markSizeWidth:int=12;
var markSizeHeight:int=24;
var sideOffset:int=65;
var questionListLinesOffset:int=25;
var answerListLinesOffset:int=25;
var questions:QuestionAnswer[]=new QuestionAnswer[1];
private var oldScreenWidthSize:int;
private var oldScreenHeightSize:int;
private var nextQuestionOffset=0;
private var nextAnswerOffset=0;
private var indexQuestionPage=-1;
class QuestionAnswer
{
public var Question:Texture2D;
public var currectAnswerIndex:int;
public var Answers:Texture2D[]=new Texture2D[4];
}
Function
function DrawQuestions()
{
GUI.skin=gSkinEmpty;
GUI.skin.font=questionFont;
var i=0;
if (indexQuestionPage==-1)
{
for(i=0;i<questions.Length;i++)
{
if (questions[i].Question)
{
nextQuestionOffset=i*questionListLinesOffset;
if(GUI.Button(Rect(this.GetComponent("GUITexture").pixelInset.x+this.GetComponent("GUITexture").pixelInset.width-sideOffset,this.GetComponent("GUITexture").pixelInset.y+120+nextQuestionOffset,markSizeWidth,markSizeHeight),qMark))
{
indexQuestionPage=i;
}
if(GUI.Button(Rect(this.GetComponent("GUITexture").pixelInset.x+this.GetComponent("GUITexture").pixelInset.width-sideOffset-(markSizeWidth+questions[i].Question.width),this.GetComponent("GUITexture").pixelInset.y+120+nextQuestionOffset,questions[i].Question.width,questions[i].Question.height),questions[i].Question))
{
indexQuestionPage=i;
}
}
}
}
else
{
var nextAnswerOffsetApplyed=0;
GUI.Button(Rect(this.GetComponent("GUITexture").pixelInset.x+this.GetComponent("GUITexture").pixelInset.width-sideOffset,this.GetComponent("GUITexture").pixelInset.y+120,markSizeWidth,markSizeHeight),qMark);
GUI.Button(Rect(this.GetComponent("GUITexture").pixelInset.x+this.GetComponent("GUITexture").pixelInset.width-sideOffset-(markSizeWidth+questions[indexQuestionPage].Question.width),this.GetComponent("GUITexture").pixelInset.y+120,questions[indexQuestionPage].Question.width,questions[indexQuestionPage].Question.height),questions[indexQuestionPage].Question);
for(i=0;i<questions[indexQuestionPage].Answers.Length;i++)
{
if (questions[indexQuestionPage].Answers[i])
{
nextAnswerOffset+=answerListLinesOffset+questions[indexQuestionPage].Answers[i].height;
if(GUI.Button(Rect(this.GetComponent("GUITexture").pixelInset.x+this.GetComponent("GUITexture").pixelInset.width-sideOffset,this.GetComponent("GUITexture").pixelInset.y+120+nextAnswerOffset,markSizeWidth,markSizeHeight),aMark))
{
//check asnwer...
//apply scores...
//back to first page
}
if(GUI.Button(Rect(this.GetComponent("GUITexture").pixelInset.x+this.GetComponent("GUITexture").pixelInset.width-sideOffset-(markSizeWidth+questions[indexQuestionPage].Answers[i].width),this.GetComponent("GUITexture").pixelInset.y+120+nextAnswerOffset,questions[indexQuestionPage].Answers[i].width,questions[indexQuestionPage].Answers[i].height),questions[indexQuestionPage].Answers[i]))
{
//same as top
//check asnwer...
//apply scores...
//back to first page
}
}
}
}
}
the out put i get:
first page, every things perfect:
second, i used GUI.Label , second page (question show small and with long distance…) other item (answers) don’t shown
third, i used GUI.Button , second page (question is shown as it should be…) other item still don’t shown


