Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Audiosource reseting for no reason...

Discussion in 'Editor & General Support' started by sburgoon, Aug 4, 2016.

  1. sburgoon

    sburgoon

    Joined:
    Jan 29, 2012
    Posts:
    38
    Hey everyone,

    I am having a really weird problem. An audiosource in my game is randomly resetting its time to 0 in the middle of playing.

    Code (CSharp):
    1. curClip_prev.clip = curClip.clip;
    2. curClip_prev.Play();
    3. curClip_prev.time = Mathf.Min(curClip.time, curClip_prev.clip.length - 0.0000001f);
    After that I set curClip to a new clip and start it from the beginning. This is all part of a semi complicated music controller to handle transitioning between start clips and looping clips and whatnot. This pattern works in general, and after this runs everything is correct (curClip_prev.time is what I would expect). In fact, on the next Update loop (this is done in Update) curClip_prev.time is still correct, but on the one following that it has magically reset to 0 even though its not looping, and wasn't at the end of the clip.

    Any ideas/anyone run into this before? Seems to be happening outside of my code entirely, which is making this really difficult to fix.

    -Sean
     
  2. sburgoon

    sburgoon

    Joined:
    Jan 29, 2012
    Posts:
    38
    As usual, I figured out the issue after posting the question. This only happens if the load-type of the clip is Streaming. Other loadtypes work fine. I'm guessing there is something screwy with the streaming mode that can cause a reset when doing something like I'm doing.
     
  3. wkaj

    wkaj

    Unity Technologies

    Joined:
    May 18, 2012
    Posts:
    50
    Are you streaming from WWW?