x


Using 2D GUIs in a 3D Terrain for a Main Menu

Okay, so I'm making a Main Menu using 2D GUIs in a 3D Terrain to make it look more interesting like this one (but i don't know if the GUIs like the textboxes there are 2D. but i guess they are 2D LOL). Now I use iTween to navigate throughout the map because I placed the parts of the menu in the different places on the map (like the Start Game GUI will show in the mountain, the Option GUI in the river, etc.)

Now the problem is I'm having a hard time to combine 2D and 3D at the same time. I know that 2D GUIs will stick infront of your screen that's why I was trying to make them fade in when I need them and fade them out if I don't need them using colliders. I used a linking variable to validate if the camera(w/ a collider) entered a collider(w/ trigger) to know if the specified GUI will fade in. But somehow it doesn't work.

Here's my Trigger Collider Script:

var fadeVar = 0;

function OnTriggerEnter (other : Collider) {

Debug.Log("Trigger Entered!);
fadeVar = 1;

}

function GetResult(){
    return fadeVar;
}

As you can see I made a variable named fadeVar to determine if the gameObject with a collider entered the trigger. Then made a function to retrieve the value. Then here is my fade in/out script:

var guiObject : GUITexture; 

var fadeTime = 1.0; 

enum Fadelng {In, Out} 

private var linkTest : fadeTest;
var boolTest = 0;

function Awake(){

    linkTest = FindObjectOfType(fadeTest);
    if(!linkTest)
    {
       Debug.Log("No link to fadeTest!");
    }

    boolTest = linkTest.GetResult();
}


function Start() { 
// This is where the fade in/out script was really placed in the script i had.
   //yield FadeGUITexture(guiObject, fadeTime, Fadelng.In); 
   //yield WaitForSeconds(1.0);
   //FadeGUITexture(guiObject, fadeTime, Fadelng.Out);
  }


 function Update() {

     if(boolTest == 1)
    {
       Debug.Log("Entered");
      //yield FadeGUITexture(guiObject, fadeTime, Fadelng.In); 
//i just tested to put the fade-in in the update to check if it validates it even if its in the Update()

}

 }



function FadeGUITexture (guiObject : GUITexture, timer : float, fadeType : Fadelng) { 

   var start = fadeType == Fadelng.In? 0.0 : 1.0; 
   var end = fadeType == Fadelng.In? 1.0 : 0.0; 
   var i = 0.0; 
   var step = 1.0/timer; 

   while (i < 1.0) { 
            i += step * Time.deltaTime; 
        guiObject.color.a = Mathf.Lerp(start, end, i)*.5; 
        yield; 
   } 

}

Okay so I had that fade in/out script in the internet and I was just tweaking it to make some changes to suit what I was supposed to be needing for my game. I tried to link the trigger script(I really don't know if it works but I just had my ideas on linking from the 3DPlatformTutorial) to get the validation if the object entered the trigger. The fade in/out effect was originally placed in the start function but I saw that if you would place it in the Start() then it will automatically fade in and won't validate the boolTest. I tried to put it in the Update() so that it will check the boolTest as soon as it touches the trigger but I'm having an error like: "Update function can't be coroutine".

Sorry for the very long post. I just want to give you all the things I know about my problem. I'm just starting to learn game scripting so forgive me. XD

more ▼

asked Jun 09 '12 at 04:49 PM

niconicx gravatar image

niconicx
0 2 2

(comments are locked)
10|3000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3673
x280
x41

asked: Jun 09 '12 at 04:49 PM

Seen: 476 times

Last Updated: Jun 09 '12 at 04:49 PM