Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.

    Read our full announcement for more information and let us know if you have any questions.

Question Why the timeline asset loaded at OnGraphStart() is been destroyed?

Discussion in 'Timeline' started by ClickOn, Mar 11, 2021.

  1. ClickOn


    Nov 7, 2019
    I want jump to the second tineline when the first is end. I load the second timeline asset at
    OnGraphStart() method of the lastest timeline clip in the first timeline. But when the clip start,unity show "MissingReferenceException: The object of type 'TimelineAsset' has been destroyed but you are still trying to access it." Later, I test the Sprite-Type variable and find sprite can be accessed. Someone know about this? :(
    Code (CSharp):
    1. public class TestBehaviour : PlayableBehaviour
    3. {
    4.     private TimelineAsset testAsset;
    5.     private Sprite testImage;
    7.     // Called when the owning graph starts playing
    8.     public override void OnGraphStart(Playable playable)
    9.     {
    10.         Debug.Log($"graph start");
    11.         Test();
    12.     }
    14.     async void Test()
    15.     {
    16.         testAsset = (TimelineAsset)await GameEntry.Resource.LoadAssetAsync<PlayableAsset>(assetPath);
    17.         testImage = await GameEntry.Resource.LoadAssetAsync<Sprite>(spritePath);
    18.         Debug.Log($"TestAsset1:{}");
    19.         Debug.Log($"TestSprite1:{}");
    20.     }
    22.     // Called when the state of the playable is set to Play
    23.     public override void OnBehaviourPlay(Playable playable, FrameData info)
    24.     {
    25.         Debug.Log($"behaviour start");
    26.         Debug.Log($"TestAsset2:{}");
    27.         Debug.Log($"TestSprite2:{}");
    29.     }
    30. }