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 twmanar · Jul 07, 2014 at 04:43 PM · bugmenuscenesnew

switching scene, first one stops to work properly

Hi im new to unity (and programming!). i got a anoying problem and i would really need some help. When i first start the menu scene, everything works properly, then i go to another scene and work there, when i go back to start the first scene(menu) the gui button are invicible. This i know because i can still press it because i remember where it were

Those are the scripts script 1, used for the menu buttons: using UnityEngine; using System.Collections;

 public class Start : MonoBehaviour {
     bool showBox = false;
     // Use this for initialization
     void Start1 () {
     
     }
     
     // Update is called once per frame
     void Update () {
     
     }
 
     void OnGUI(){
 
             
         if (GUI.Button (new Rect (Screen.width / 2 - 50, Screen.height / 2 - 200, 200, 75), "<size=40>Start</size>")) {
             showBox = true;
                         
                 }
         if (showBox) {
             GUI.Box (new Rect (0, 0, 100, 25), "Loading...");
             Application.LoadLevel ("något");
                 }
         }
 
            
     }
 
 script 2, used for background image: 

 using UnityEngine;
 using System.Collections;
 
 public class BackgroundMeny : MonoBehaviour {
 
     public Texture2D BackgroundMenu;
     // Use this for initialization
     void Start () {
     
     }
     
     // Update is called once per frame
     void Update () {
     
     }
     void OnGUI()
     {
         GUI.DrawTexture(new Rect(0, 0, Screen.width , Screen.height  ), BackgroundMenu, ScaleMode.StretchToFill, true, 10.0F);
 
     }
 
 }
 

so currently i have to make a new button script everytime for my menu to work. is this a bug or what? All help would be appreciated

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by eeveelution8 · Aug 25, 2014 at 01:24 AM

Boy I have the perfect script for you,

 var ButtonID : int = 0;
 
 // ID of 1 = Quit button.
 // ID of 2 = Sceneloading button
 // ID of 3 = Unhides an object
 // ID of 4 = hides and object
 // ID of 5 = turns off parent, while turning on target(useful for switching between tabs)
 
 var ID2_Scene : String;
 var ID_object : GameObject;
 
 var ID5_target : GameObject;
 
 function OnMouseDown(){
 
     if(ButtonID == 1){
     Application.Quit();
     }
         if(ButtonID == 2){
         Application.LoadLevel(ID2_Scene);
         }
             if(ButtonID == 3){
             ID_object.SetActive(true);
             }
                 if(ButtonID == 4){
                 ID_object.SetActive(false);
                 }
                     if(ButtonID == 5){
                     gameObject.SetActive(false);
                     ID5_target.SetActive(true);
                     }
 }
 


if it's a quit button, enter '1' into ButtonID, and leave the rest alone.

if the button loads a scene, enter '2' into ButtonID, and put the nameof your level into "ID2_Scene"

and so on and so on.

Comment
Add comment · Show 1 · Share
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
avatar image twmanar · Aug 25, 2014 at 04:24 PM 0
Share

Wow , finaly an answer. Thanks! i think i solved this but i think this would work too and i'll probably replace it. :) I'm not really sure how to set your answer as "the answer" but thanks again!

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

How do I change scenes when pressing a "play" button? 2 Answers

How can i make the scene in my build the same as in my Editor? 2 Answers

how to make it die and make it permanent(true)? 1 Answer

What can i do when my built Scene differs from my scene in the Editor? 0 Answers

New created scene makes current scene brighten up 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