Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 Dan_G · Sep 29, 2020 at 06:27 PM · referencetimelinetrackingclip

How to reference a TrackAsset or PlayableAsset

Hi,

I have some scenes that are being loaded through a Master Timeline (I created a custom Track, PlayableAsset and PlayableBehaviour). These scenes have a sub-timeline that i am also loading in the aforementioned Master Timeline, using a ControlTrack.

I wonder how can I get a reference to the ControlTrack (or the clip on this track) that contains my sub-timeline. I am currently taking it by it´s name (code below) but ideally i would like to make a public ControlTrack property on my PlayableBehaviour that loads the scenes so it has a reference to its own timeline... although it seems impossible to drag & drop a clip or track from the Timeline to a reference slot!

      TimelineAsset playable = mainPlayableDirector.playableAsset as TimelineAsset;
             // Look for the Control Track of the loaded scene.
             foreach (PlayableBinding binding in playable.outputs)
             {
                 if(binding.sourceObject)
                 {
                     if (binding.sourceObject.GetType() == typeof(ControlTrack))
                     {
                         ControlTrack tmpControlTrack = (ControlTrack)binding.sourceObject;
                           // If our Control Track exists, assign the TIMELINE object to all its clips                            if (tmpControlTrack.name == "TIMELINE " + scene.name)
                         {
                             controlTrack = tmpControlTrack;
                         }
                     }
                 }
             }


Anyone knows a better way of doing this? I thought about using controlTrack.GetInstanceID() and store them on a Dictionary using the scene name as the key or something like that, but i don´t really like the solution...

Thanks! D

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

2 Replies

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

Answer by seant_unity · Sep 29, 2020 at 07:48 PM

You can use TimelineAsset.GetOutputTracks() to walk the list of tracks in the timeline asset. And if you want drag and drop, you can change the hideFlags on the Tracks themselves to show up as subassets on your timeline file - like recorded animation clips do. (e.g. track.hideFlags &= ~HideFlags.HideInHierarchy).

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
avatar image
0

Answer by Dan_G · Sep 30, 2020 at 05:17 PM

Hi @seant_unity , I just changed my code and I am now using TimelineAsset.GetOutputTracks() to go through all the tracks in my timeline asset. It works better than my approach above! However, my problem persists. I still have to filter the ControlTracks in the Timeline by its name, which is a very weak solution as anyone can accidentally change the track´s name. I tried to store the InstanceID or HashCode somewhere to have a solid reference to the ControlTrack, but they change every time i close and open Unity...

Regarding the drag & drop solution, i think I didn´t explained myself well. Ideally, I would like to find a solution where i can create an ExposedReference on my CustomClip (extends from PlayableAsset) and then reference or assign (doingdrag & drop?) a ControlTrack or ControlPlayableAsset. This way i will have my CustomClip well coupled with the ControlTrack or ControlPlayableAsset that contains it´s subtimeline (remember the CustomClip just loads a scene that contains a sub-timeline). The issue is that i cannot reference any ControlTrack or Clip as i cannot drag & drop them to any ExposedReference slot...

Any suggestion? I hope i explained myself better this time :) PS: I think i did not fully understand the hideFlags solution... can you please elaborate if it is pertinent?

 foreach (TrackAsset track in playable.GetOutputTracks())
         {
             if (track.GetType() == typeof(ControlTrack))
             {
                 // If our Control Track exists, we assign the TIMELINE object to all its clips
                 if (track.name == "TIMELINE " + scene.name)
                 {
                     controlTrack = (ControlTrack)track;
                 }
             }
             
         }
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 seant_unity · Sep 30, 2020 at 06:21 PM 1
Share

You don't need an exposed reference for ControlTracks, or ControlPlayableAssets as they are assets (i.e. ScriptableObjects). ExposedReferences are for accessing a scene object from an asset file. Just a regular variable (e..g public ControlTrack controlTrack) will do fine.

The problem is they are hidden in the project window. If you run a script to unhide them, foreach (ControlTrack track in playable.GetOutputTracks().OfType()) { track.hideFlags &= ~HideFlags.HideInHierarchy(); EditorUtility.SetDirty(track); } AssetDatabase.SaveAssets(); then in the project window, the playable file will have a foldout and the control tracks will be listed. From there you can drag and drop them to the inspector.

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

141 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 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

Peculiar Bleed-through of Exposed References on different Timeline Tracks 2 Answers

Change TimeLine clip display name based on parameters 3 Answers

Force a timeline clip to a fixed duration 2 Answers

Customize Timeline Clip background 0 Answers

Positioning timeline clip by script 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