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 ReferenceWolf · Jun 29, 2021 at 04:39 PM · loading screen

How do I fix this issue with loading screen tips

I have been trying to make a script for loading scene tips in my game and I was wondering how to get the tips to reset. For example, I have 15 tips that play while the scene is loading, I want to know how to get the tip to go back to tip one. Im using different scenes for each of my tips which I know probably isnt the most efficient way but it seems to work. I am in unity version 2020.3.0f1 Here is the code I have at the moment using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement;

 public class next_tip : MonoBehaviour
 {
     public void PlayGame()
     {
         SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
     }

here is a screenshot of some of the scenes I have for tips alt text

capture.png (7.3 kB)
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

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Devster2020 · Jun 29, 2021 at 05:46 PM

Hello @ReferenceWolf Oh, the method you have chosen is one of the worst.

The best way to do this is to create a single "tip" scene and attach a script that has a list or array of tips, showing one every TOT seconds, and starting the loop over.

In this way:

 public class TipsManager : MonoBehaviour {
 
     [SerializeField] private Text tipsText;
     [SerializeField] private string[] tips;
     private int index;
 
     void Start(){
         this.index = 0;
         this.ShowTip();
     }
 
     private void ShowTip(){
         this.tipsText.Text = this.tips[this.index];
         StartCoroutine(this.WaitAndLoadTip());
     }
 
     private IEnumerator WaitAndLoadTip(){
         yield return new WaitForSeconds(3f);
         this.index++;
 
         if(this.index >= this.tips.Length)
             this.index = 0;
 
         this.ShowTip();
     }
 }


If you want to keep your method, and I don't recommend it, you have to create an index range between the first and last scene that shows the tips, and start the cycle again when you get to the last scene.

Comment
Add comment · Show 11 · 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 ReferenceWolf · Jun 29, 2021 at 06:15 PM 0
Share

Hi there @Devster2020 I put the code into unity that you gave me and in line 9, unity seems to have a problem with the word "Text". I know that this shouldnt be the case and i've seen this used in other scripts. Any ideas?

avatar image ReferenceWolf ReferenceWolf · Jun 29, 2021 at 06:25 PM 0
Share

hey there again, never $$anonymous$$d, sorry. I just forgot to put in "using UnityEngine.UI;"

avatar image Devster2020 ReferenceWolf · Jun 29, 2021 at 06:40 PM 0
Share

NP.. have you resolve the problem?

avatar image ReferenceWolf · Jun 29, 2021 at 06:50 PM 0
Share

Hey there @Devster2020 I'm really sorry to keep bothering you but now that I have added "using UnityEngine.UI" I get an error saying this "Assets\next_tip.cs(22,23): error CS1061: 'Text' does not contain a definition for 'Text' and no accessible extension method 'Text' accepting a first argument of type 'Text' could be found (are you missing a using directive or an assembly reference?)". I also have an error saying "Assets\next_tip.cs(23,9): error CS0103: The name 'StartCoroutine' does not exist in the current context". Is there any way you could help?

avatar image Devster2020 ReferenceWolf · Jun 29, 2021 at 07:00 PM 0
Share

Hi @ReferenceWolf, and sorry but smartphone's keyboard change sometimes the case.. text must be all lowercase.

For StartCoroutine, you need to add "using System.Collections"

avatar image ReferenceWolf Devster2020 · Jun 29, 2021 at 07:06 PM 0
Share

Hi there, @Devster2020, changing "Text" to all lowercases worked but "using System.Collections" was automatically at line 1 of my script when I made the script at the beginning. Is there any other fix? I'm very sorry for the inconveniences i've caused

Show more comments
avatar image
0

Answer by Nistroy · Jun 29, 2021 at 06:26 PM

Hi @ReferenceWolf ! So if I understood correctly you want to load the scenes until the last one and then go back to the first. So there is a very easy way to do this is to use the "%" sign. This will fire the rest of the division. So for example you have 15 scenes. If you are at the 7th it will be: "7/15: R = 7". Then when you are at the 15th scene the rest of "15/15" will be 0. Sorry if I express myself badly I'm French haha ^^. Note: If you only want to make the scene count active in BuildSettings instead of sceneCount write sceneCountInBuildSettings

 int _buildIndex = SceneManager.GetActiveScene().buildIndex + 1;
 int sceneIndexToLoad = _buildIndex % SceneManager.sceneCount;
 SceneManager.LoadScene(sceneIndexToLoad);

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 Devster2020 · Jun 29, 2021 at 06:39 PM 0
Share

This code will not work if in the future he will add another scene like "itemShop".. so I think is not a good idea..

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

120 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 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

Loading Screen 2 Answers

Level Loads properly in the editor but in the device builds when game is installed on machine. game quits instead of loading level 1 Answer

Initial Web Player loading bar does't move when loading. 0 Answers

Unity WebGL loading screen customization 1 Answer

Loading screen bar not loading. 1 Answer


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