Sign up Calendar Latest Topics
 
 
 


Reply
  Author   Comment  
James

Junior Member
Registered:
Posts: 29
Reply with quote  #1 
Hey guys

I am developing a game for android and iphone.
any ways i checked the game with a few difrrent devices and the text have a diffrent size + location...

anyone knows how to fix it? how to make it more or less the same in all the devices?..


Thanks
0
FD_Games

Avatar / Picture

Junior Member
Registered:
Posts: 29
Reply with quote  #2 
use textmeshes instead of guitext or 3dtext's to solve this issue I believe
0
Martin

Avatar / Picture

Administrator
Registered:
Posts: 2,230
Reply with quote  #3 
Yeah we've used 3DText's mostly before and it works well. On most screens it looks correct and the cool thing is that 3DTexts can be easily moved around the screen visually without needing to touch the code.

In unity just go to here to create one:
Screen Shot 2014-08-04 at 12.36.55 AM.png 

You can apply different fonts and text sizes.

Usually when I add a UI element to a game, for example a high score text. I just make sure to move it well inside the frame. So don't put it right on the edge because on some screens it might be cut off. A good way to check this is to just go down the different screen sizes in unity and see if the text appears correctly:

Screen Shot 2014-08-04 at 12.39.11 AM.png 

Hope this helps [smile]

Let us know how it goes.

Martin



0
James

Junior Member
Registered:
Posts: 29
Reply with quote  #4 

Quote:
Originally Posted by Martin
Yeah we've used 3DText's mostly before and it works well. On most screens it looks correct and the cool thing is that 3DTexts can be easily moved around the screen visually without needing to touch the code.

In unity just go to here to create one:
Screen Shot 2014-08-04 at 12.36.55 AM.png 

You can apply different fonts and text sizes.

Usually when I add a UI element to a game, for example a high score text. I just make sure to move it well inside the frame. So don't put it right on the edge because on some screens it might be cut off. A good way to check this is to just go down the different screen sizes in unity and see if the text appears correctly:

Screen Shot 2014-08-04 at 12.39.11 AM.png 

Hope this helps [smile]

Let us know how it goes.

Martin




Okay but i am using a script for a score 
the code:    GUI.Label(Rect(10, 10, 100, 30), " " + ScoreSaver, style);

so how can i change it to a 3dtext?
(hope you understand..)

Thanks

0
Martin

Avatar / Picture

Administrator
Registered:
Posts: 2,230
Reply with quote  #5 
Hi James. Sorry for the late reply. Hope you're doing well.

I don't think you can change it to a 3DText in code, you'll need to create a 3DText game object from the menu inside unity. Then once it's created you can change the score in the code. For example:


var scoreTextMesh : TextMesh;

function UpdateScore()
{
      scoreTextMesh.text = ScoreSaver.ToString();
}


Let me know if this is what you mean.

Chat soon
Martin
0
EpicStudios

Senior Member
Registered:
Posts: 195
Reply with quote  #6 
Code:

void OnGUI () {

float originalWidth = 1024;
float originalHeight = 768;

Vector2 ratio = new Vector2(Screen.width/originalWidth , Screen.height/originalHeight);
Matrix4x4 guiMatrix = Matrix4x4.identity;
guiMatrix.SetTRS(new Vector3(1, 1, 1), Quaternion.identity, new Vector3(ratio.x, ratio.y, 1));
GUI.matrix = guiMatrix;

GUI.Label(new Rect(.5f * originalWidth - 50, .175f * originalHeight - 25, 100, 50), "CENTERED", font);

if(GUI.Button(new Rect(.25f * originalWidth, .2f * originalHeight, .5f * originalWidth, .075f * originalHeight), "CENTERED", button)){

}

// other gui stuff

GUI.matrix = Matrix4x4.identity;
}


Instead of making reference to Screen.width and Screen.height use orginalWidth and originalHeight and it will scale perfectly. Good luck.
0
James

Junior Member
Registered:
Posts: 29
Reply with quote  #7 

Quote:
Originally Posted by Martin
Hi James. Sorry for the late reply. Hope you're doing well.

I don't think you can change it to a 3DText in code, you'll need to create a 3DText game object from the menu inside unity. Then once it's created you can change the score in the code. For example:

 var scoreTextMesh : TextMesh; function UpdateScore() { scoreTextMesh.text = ScoreSaver.ToString(); }


Let me know if this is what you mean.

Chat soon
Martin


Thanks! thats really helped me.

All i had to do is to change the variable so i managed to solve it thanks.


0
Previous Topic | Next Topic
Print
Reply

Quick Navigation:

Easily create a Forum Website with Website Toolbox.