Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
1
Question by MikePOD · Jul 07, 2017 at 08:30 PM · buttonscene-loadingbuttons

Why does using Buttons slow down scene loading?

So, I'm trying to load the next scene by pressing a button on screen. Earlier, I had it so when the user presses enter, the scene will load, but after realizing that wouldn't work too smoothly on iPads, I decided to switch to buttons. But the button method makes the next scene nearly two minutes to load, while the press Enter method was nearly instantaneous. Anyone have any idea why that is? //Press Enter method

 if (Input.GetKeyDown(KeyCode.Tab))
         {
             //If there's a space in the word, display a message and don't progress
             if (input.text.Contains(" "))
                 warningWord.text = "Words cannot contain spaces!";
             //If the word is valid...
             else if (!string.IsNullOrEmpty(input.text))
             {
                 //Display no error message
                 warningWord.text = ("");
                 //Set the string to the inputfield's contents
                 wordToSpell = input.text;
                 //Show the list of already typed words
                 typedWords.text = typedWords.text + "\n" + input.text;
                 //clear the input field
                 input.text = "";
                 //Set the word to all caps in order to keep it simple
                 wordToSpell = wordToSpell.ToUpper();
                 //Add the word to the list of words
                 wordList.Add(wordToSpell);
             }
 
             
         }
         //If the Return (Enter) key is pressed...
         if (Input.GetKeyDown(KeyCode.Return))
         {
             //If the user hasn't entered any words, display a message and don't progress
             if (wordList.Count == 0)
                 warningWord.text = ("You haven't entered any words!");
             //If the user has not selected a difficulty, display a message and don't progress
             if (!easy.isOn && !medium.isOn && !hard.isOn)
                 warningDifficulty.text = ("You haven't selected a difficulty!");
             //If a difficulty is selected and there are words that have been entered...
             if ((easy.isOn || medium.isOn || hard.isOn) && wordList.Count > 0)
             {
                 //Set the backup list to the real list
                 backupList = new List<string>(wordList);
                 //Set the difficulties depending on the selected bubbles
                 if (easy.isOn)
                     PlayerPrefs.SetString("difficulty", "easy");
                 else if (medium.isOn)
                     PlayerPrefs.SetString("difficulty", "medium");
                 else if (hard.isOn)
                     PlayerPrefs.SetString("difficulty", "hard");
                 //Make the canvas invisible as to hide the text boxes in the later scenes
                 canvas.gameObject.SetActive(false);
                 //Load the game
                 SceneManager.LoadScene(1);
             }
             
         }

//Button method

 void Update()
     {
         //As long as a difficulty is selected, don't display an error message
         if (easy.isOn || medium.isOn || hard.isOn)
             warningDifficulty.text = "";
         //If the enter word button is pressed...
         enterWord.onClick.AddListener(EnterButton);
         //If the start game button is pressed...
         startGame.onClick.AddListener(StartButton);
     }
     void EnterButton()
     {
         //If there's a space in the word, display a message and don't progress
         if (input.text.Contains(" "))
             warningWord.text = "Words cannot contain spaces!";
         //If the word is valid...
         else if (!string.IsNullOrEmpty(input.text))
         {
             //Display no error message
             warningWord.text = ("");
             //Set the string to the inputfield's contents
             wordToSpell = input.text;
             //Show the list of already typed words
             typedWords.text = typedWords.text + "\n" + input.text;
             //clear the input field
             input.text = "";
             //Set the word to all caps in order to keep it simple
             wordToSpell = wordToSpell.ToUpper();
             //Add the word to the list of words
             wordList.Add(wordToSpell);
         }
     }
     void StartButton()
     {
         //If the user hasn't entered any words, display a message and don't progress
         if (wordList.Count == 0)
             warningWord.text = ("You haven't entered any words!");
         //If the user has not selected a difficulty, display a message and don't progress
         if (!easy.isOn && !medium.isOn && !hard.isOn)
             warningDifficulty.text = ("You haven't selected a difficulty!");
         //If a difficulty is selected and there are words that have been entered...
         if ((easy.isOn || medium.isOn || hard.isOn) && wordList.Count > 0)
         {
             //Set the backup list to the real list
             backupList = new List<string>(wordList);
             //Set the difficulties depending on the selected bubbles
             if (easy.isOn)
                 PlayerPrefs.SetString("difficulty", "easy");
             else if (medium.isOn)
                 PlayerPrefs.SetString("difficulty", "medium");
             else if (hard.isOn)
                 PlayerPrefs.SetString("difficulty", "hard");
             //Make the canvas invisible as to hide the text boxes in the later scenes
             canvas.gameObject.SetActive(false);
             //Load the game
             SceneManager.LoadScene(1);
         }
     }`



Comment
Add comment · Show 1
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 Paratrooper82 · Jun 07, 2018 at 08:18 PM 0
Share

I wish I figured this out too. I can't seem to find any answers. I used to load my scene with the letter "f" when I was next to my level door.

I just switched that to .onClick.AddListener ... And it literally takes two $$anonymous$$utes to load a scene, whereas clicking "f" was instant.

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

77 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Detect if player wants to pause or to jump 3 Answers

Runtime UI button creation: can't make an "OnClick" where I call a function from another script while sending a parameter. 2 Answers

How to detect a button being released? 1 Answer

How to make UI buttons so my player can move along certain lines 0 Answers

Hi, button.onClick.AddListener makes nothing no error, no adding any listener. Please help 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