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 /
  • Help Room /
avatar image
0
Question by storyteller2899 · Oct 24, 2016 at 05:00 PM · unity 2dwarningconsole errorsobject pool

Playable was not Disposed

I'm having issues with my program. I have the game set up to manipulate time as the users "dies", the character is then re-spawned and time starts back up again. However shortly after time resumes the game (the background, the playable, and obstacles) freezes. I am using Unity 5.4. I am programming this though a class on Lynda.com and my code matches my instructors. The only thing different is that I am getting the warning: Assets/Scripts/ObjectPool.cs(13) : Playable was not Disposed.

The warning is showing up under the console tab in Unity. I am not sure how to fix it, and I was wondering if anyone could help. I used Visual Studio to program.

Here is my code for my time manager. using UnityEngine; using System.Collections;

 public class TimeManager : MonoBehaviour
 {
 
     public void ManipulateTime(float newTime, float duration)
     {
         if (Time.timeScale == 0)
             Time.timeScale = 0.1f;
 
         StartCoroutine(FadeTo(newTime, duration));
     }
 
     IEnumerator FadeTo(float value, float time)
     {
         for (float t = 0f; t < 1; t += Time.deltaTime / time)
         {
 
             Time.timeScale = Mathf.Lerp(Time.timeScale, value, t);
 
             if (Mathf.Abs(value - Time.timeScale) < .01f)
             {
                 Time.timeScale = value;
                yield return false;
             }
 
             yield return null;
 
         }
     }
 }
 

I also have code for my game manager which involves the time manager. using UnityEngine; using System.Collections;

 public class GameManager : MonoBehaviour {
 
     public GameObject playerPrefab;
 
     private bool gameStarted;
 
     private TimeManager timeManager;
     private GameObject player; 
     private GameObject floor;
     private Spawner spawner;
 
 
     void Awake()
     {
         floor = GameObject.Find ("Foreground");
         spawner = GameObject.Find ("Spawner").GetComponent<Spawner> ();
         timeManager = GetComponent<TimeManager> ();
 
     }
 
     // Use this for initialization
     void Start () {
 
         var floorHeight = floor.transform.localScale.y;
 
         var pos = floor.transform.position;
         pos.x = 0;
         pos.y = -((Screen.height / PixelPerfectCamera.pixelsToUnits) / 2) + (floorHeight / 2);
         floor.transform.position = pos;
 
         spawner.active = false;
 
         Time.timeScale = 0;
     }
     
     // Update is called once per frame
     void Update () {
         if (!gameStarted && Time.timeScale == 0)
         {
             if (Input.anyKeyDown)
             {
                 timeManager.ManipulateTime(1, 1f);
                 ResetGame();
             }
         }
     
     }
 
     void OnPlayerKilled()
     {
         spawner.active = false;
 
         var playerDestroyScript = player.GetComponent<DestroyOffScreen>();
         playerDestroyScript.DestoyCallback -= OnPlayerKilled;
 
        
         player.GetComponent<Rigidbody2D>().velocity = Vector2.zero;
         timeManager.ManipulateTime(0, 5.5f);
         gameStarted = false;
         
     }
         void ResetGame()
     {
         spawner.active = true;
 
         player = GameObjectUtil.Instantiate(playerPrefab, new Vector3(0, (Screen.height/PixelPerfectCamera.pixelsToUnits) / 2 +100, 0));
 
         var playerDestroyScript = player.GetComponent<DestroyOffScreen> ();
 
         playerDestroyScript.DestoyCallback += OnPlayerKilled;
 
         gameStarted = true;
     }
 
     
 }

I would greatly appreciate any help. Thank you.

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 hexagonius · Oct 26, 2016 at 08:33 AM 0
Share

You posted two scripts but missed the one with the error (ObjectPool.cs)

1 Reply

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

Answer by PartyWolf · Oct 26, 2016 at 08:32 AM

Hey @storyteller2899,

Had the exact same problem today, my crazy programmer housemate just came up with this solution.

IEnumerator FadeTo(float value, float time) { for (float t = 0; t < 1; t += Time.deltaTime / time) {

         Time.timeScale = Mathf.Lerp (Time.timeScale, value, t);

         if(Mathf.Abs(value - Time.timeScale) < .01f) {
             Time.timeScale = value;
             break;
         }
         yield return null;
     }

     yield return false;
 }

}

Blockquote

Hopefully this should work!

PS. I find this is a recurring thing in outdated lynda tutorials :P.

Comment
Add comment · 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

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

Warining by Application.loadedlevel 1 Answer

Sprites have discolored patches / color bleeding 0 Answers

How to use Rigidbody2D.MovePosition to move a kinematic object around looping waypoints? 1 Answer

How to make UI scale equally to camera? 1 Answer

true grid snapping in editor ? 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