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 id.unity.com 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

    ClickOn

    Joined:
    Nov 7, 2019
    Posts:
    1
    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:
    Code (CSharp):
    1. public class TestBehaviour : PlayableBehaviour
    2.  
    3. {
    4.     private TimelineAsset testAsset;
    5.     private Sprite testImage;
    6.  
    7.     // Called when the owning graph starts playing
    8.     public override void OnGraphStart(Playable playable)
    9.     {
    10.         Debug.Log($"graph start");
    11.         Test();
    12.     }
    13.  
    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:{testAsset.name}");
    19.         Debug.Log($"TestSprite1:{testImage.name}");
    20.     }
    21.  
    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:{testImage.name}");
    27.         Debug.Log($"TestSprite2:{testAsset.name}");
    28.      
    29.     }
    30. }
    Result:
    upload_2021-3-11_15-49-32.png