Hey There,
I’ve have spent some time writing an Achievement script using GUI.Drawtexture for a game I’m working on at University. An I have run into some trouble an I’m hoping someone here may be able to help me. Essentially, the script I have renders a GUI.Drawtexture when a specific condition is made, though when two conditions are achieved at the same time the script will only draw one of the textures instead of one after the other or both at the same time. Any help would be great and thank you in Advanced.
Here is the code I am currently working on (I’m using Javascript):
Also, the youGotAchivement, is called in another script.
#pragma strict
var textureH : int = 150; // Texture Height
var textureW : int = 100; // Texture Width
var textures: Texture2D[];; // 2D Texture Array for Challanges
static var youGotAchievement01 : boolean; // Turns on/off Achievement - Hold Combo for 10 Seconds
static var youGotAchievement02 : boolean; // Turns on/off Achievement - Remain Untouched for 5 Seconds
static var youGotAchievement03 : boolean; // Turns on/off Achievement - Kill 5 Enemies in 2 Seconds
private var originalWidth = 2560.0; // define here the original resolution
private var originalHeight = 1440.0; // you used to create the GUI contents
private var scale : Vector3;
function Start ()
{
Destroy (gameObject, 3);
}
function OnGUI()
{
scale.x = Screen.width/originalWidth; // calculate hor scale
scale.y = Screen.height/originalHeight; // calculate vert scale
scale.z = 1;
var svMat = GUI.matrix; // save current matrix
// substitute matrix - only scale is altered from standard
GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, scale);
if(youGotAchievement01 == true)
{
GUI.DrawTexture(new Rect(Screen.width / originalWidth + (originalWidth ) - 150,Screen.height / originalHeight + (originalHeight ) - 100,textureH, textureW), textures[0]); // enable texture
}
if(youGotAchievement02 == true)
{
GUI.DrawTexture(new Rect(Screen.width / originalWidth + (originalWidth ) - 150,Screen.height / originalHeight + (originalHeight ) - 100,textureH, textureW), textures[1]); // enable texture
}
if(youGotAchievement03 == true)
{
GUI.DrawTexture(new Rect(Screen.width / originalWidth + (originalWidth) - 150,Screen.height / originalHeight + (originalHeight ) - 100,textureH, textureW), textures[2]); // enable texture
}
GUI.matrix = svMat; // restore matrix
}
Say the player unlocks 2 achievements at the same time, I want to have it so that one achievement will pop up for the set time, then followed by the other achievement that was unlocked.
– Trent_GD