Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by niconicx · Jun 09, 2012 at 04:49 PM · guicollidersmain menu

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

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Is it possible to suspend GUIs after running fade-in scripts? 1 Answer

Best way to create a Main Menu 1 Answer

physics.OverlapSphere colliders 1 Answer

How do I make the usual options buttons? 1 Answer

Changing start scene gui size main menu 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges