Hello,
I am currently creating a function called displayScore(). This function is located in my DisplayScore script and is called during OnGUI. I would like to know better ways to structure this code/idea. What capabilities should I keep in mind when designing a general displayScore script and what type of gameobject should it be a component of? I am assuming GUItext. I am pretty new to Unity. Any help would be awesome
I want this function to be able to accomplish this algorithm.
displayScore(Vector3 pos, Font myfont, Color RGBColor, int fontSize)
{
// get position for the score
// use a fancy font for the score
// change the color and size of that fancy font
// call a gui action to display score
}
This is what I have so far:
using UnityEngine;
using System.Collections;
public class DisplayHighScore : MonoBehaviour {
private Font font;
private GUIStyle gsNormal;
private Color RGBColor;
private int fontSize;
void Start(){
GameController.gameScore =0;
font = Resources.Load ("silent_reaction", typeof(Font)) as Font;
gsNormal = new GUIStyle();
gsNormal.alignment = TextAnchor.MiddleCenter;
gsNormal.fontStyle = FontStyle.Normal;
gsNormal.normal.textColor = Color.blue; //The color used to render the text.
gsNormal.font = font;//The font used for the text.
}
public static string score;
void OnGUI() {
// display score at location x,y, with 1 as the z depth
//function: displayScore()
displayScore();
/*score = GameController.gameScore.ToString();
guiText.text= score;
GUI.Label(new Rect (10, 10, 200, 20), score);*/
}
void displayScore(Vector3 pos, Font myfont,Color RGBColor, int fontSize)
{
GUI.Label(new Rect (10, 10, 200, 20), score);
}
}
Additional Questions: Should color be color32? I am still unsure of the difference.