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 aVittone · Mar 05, 2012 at 07:23 PM · loadlevelreset

Resetting a Level from within itself

We are having problems loading a level with Application.LoadLevel("levelName"); if that level has been previously loaded already. Particle systems don't play (although I can see them in the inspector), as well as animations.

Is there some other function for loading a level that really and truly loads a "pure" level as though it has never been played? It seems like Application.LoadLevel("name"); also does some destructive things as it "unloads" the current level that permanently changes settings in that level during one playthrough.

EDIT:

I have begun working on a test case to see if I can get a repro.

I created an empty scene, and created a particle system in that scene. I didn't edit any settings in the particle emitter component. I created a new animation for that particle system in which it moves up and down out of view for a few seconds, and then loops back around.

I created this script, and attached it to an empty game object. This scripts reloads a specified level after the timer runs out. In my level, I have set the "Level To Load" as the current level.

 using UnityEngine;

using System.Collections;

[System.Serializable] public class Test_Loader : MonoBehaviour {

 public string levelToLoad;
 public float timerDuration;
 
 private float timer;
 
 // Use this for initialization
 void Start () {
     timer = timerDuration;
     Debug.Log("Timer = " + timer);
 }
 
 // Update is called once per frame
 void Update () {
     timer -= Time.fixedDeltaTime;
     
     if(timer <= 0)
         loadLevel(levelToLoad);
 }
 
 public void loadLevel(string level)
 {
     Debug.Log("Loading " + levelToLoad);
     Application.LoadLevel(level);
 }

}

So far, everything works as expected. I am now going to modify this script to trigger the animation to play on level load, and remove the looping wrapping and the play automatically flags.

Comment
Add comment · Show 4
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 Alec-Slayden · Mar 05, 2012 at 07:34 PM 0
Share

Are you using the legacy particle system?

avatar image aVittone · Mar 05, 2012 at 07:53 PM 0
Share

No. But even if I were it wouldn't matter. It's not just particles. It's animations as well. Both imported and motion tracked. Application.LoadLevel is doing something as it unloads the current level and loads the requested one that doesn't get reset if that unloaded level is then loaded via the same call.

avatar image Alec-Slayden · Mar 05, 2012 at 08:06 PM 0
Share

I understand your frustration. I only ask because I'm trying to recreate your problem as close as possible, which I have not experienced myself.

avatar image aVittone · Mar 05, 2012 at 08:12 PM 0
Share

Yeah, I'm sorry. I'm so used to people "answering" questions without actually reading the question. I just sort of expect it. You're right though, I should demonstrate some repro. Let me work on a simple test case and post it here.

1 Reply

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

Answer by aVittone · Mar 05, 2012 at 09:49 PM

I figured it out.

I was loading the levels from within a menu that set Time.timescale = 0 when it was visible (to pause the game).

Well, Time.TimeScale never got reset to 1. Hah. In my loadlevel function (that calls application.loadlevel, among other things) I set timescale back to 1 for happy fun times.

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 Alec-Slayden · Mar 05, 2012 at 09:52 PM 0
Share

I had that same issue earlier in one of my games actually, not sure why I didn't think to mention it. Glad you got it solved!

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Starting/Triggering events based on hover time 0 Answers

reset the level? 5 Answers

Reset The Scene ? 2 Answers

How can I restart a single-scene game? 1 Answer

"Reset Level", Application.LoadLevel 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