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 /
avatar image
0
Question by Abraxasalive2 · Jul 26, 2018 at 05:39 PM · timeline

Issue Creating Playables, Trying to create Track and clip at runtime

Hello everyone; Need some help with something i'm working on, the idea is that i want to create timeline tracks and clips at Runtime. (in a start function for example)

As it stands i can create a track at runtime but the clip keeps passing me a null reference regardless of how i generate it. Can someone tell me what's going on?

 [SerializeField] GameObject m_TestContainer;
 [SerializeField] PlayableDirector m_Director;
 [SerializeField] PlayableGraph m_Graph;
 [SerializeField] TimelineAsset m_Asset;
 [SerializeField] TransformTweenTrack m_TweenTrack;
 [SerializeField] TransformTweenMixerBehaviour m_TweenMixer;
 [SerializeField] TransformTweenClip m_Clip;
 [SerializeField] Animator m_Animator;

 private void Start()
 {
     m_Director = m_TestContainer.GetComponent<PlayableDirector>();
     m_Animator = m_TestContainer.GetComponent<Animator>();

     m_Asset = (TimelineAsset)m_Director.playableAsset;
     m_Graph = PlayableGraph.Create("Custom_Graph");
     m_Graph.SetTimeUpdateMode(DirectorUpdateMode.GameTime);
     Debug.Log("PlayableGraph - PlayableCount = " + m_Graph.GetPlayableCount());
     Debug.Log("PlayableGraph - Outputcount = " + m_Graph.GetOutputCount());

     m_Asset.CreateTrack<TransformTweenTrack>(m_TweenTrack, "TransformTweenTrack");
     //m_Director.RebuildGraph();
 }






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

1 Reply

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

Answer by Abraxasalive2 · Jul 26, 2018 at 09:01 PM

Solved the issue,

my "m_track" was null, so the solution was

 [SerializeField] PlayableDirector m_Director;
 [SerializeField] Animator m_Animator;
 [SerializeField] TimelineAsset m_Timeline;
 [SerializeField] PlayableGraph m_PlayableGraph;
 [SerializeField] Basic_Animation_ControllerTrack m_Track;
 [SerializeField] TimelineClip m_Clip;
 [SerializeField] GameObject m_Obj;
 [SerializeField] ScriptPlayable<Basic_Animation_ControllerMixerBehaviour> m_Mixer;
 [SerializeField] double time;

 private void Start()
 {
     m_Director = this.gameObject.GetComponent<PlayableDirector>();
     m_Animator = this.gameObject.GetComponent<Animator>();
     m_PlayableGraph = PlayableGraph.Create("Custom_Graph");
     m_Timeline = (TimelineAsset)m_Director.playableAsset;
     m_PlayableGraph.SetTimeUpdateMode(DirectorUpdateMode.GameTime);
     PropertyName name = nameof(m_Obj);
     m_Track = m_Timeline.CreateTrack<Basic_Animation_ControllerTrack>(m_Track, "Custom_AnimationTrack");
     m_Mixer = (ScriptPlayable<Basic_Animation_ControllerMixerBehaviour>)m_Track.CreateTrackMixer(m_PlayableGraph, m_Obj, 0);
     m_Clip = m_Track.CreateClip<Basic_Animation_ControllerClip>();
     m_Timeline.CreatePlayable(m_PlayableGraph, m_Obj);
     m_Clip.duration = 1;
     Basic_Animation_ControllerClip Clip = (Basic_Animation_ControllerClip)m_Clip.asset;

Once i had that now it's just solving how to assign Exposed References at runtime

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

88 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

Related Questions

Unity 5.5 Playing inside an animation forward and backwards. 0 Answers

how do you get the PlayableDirector component in unity c# 1 Answer

timeline not play in mobile 0 Answers

How do you get curve values on an animation clip playing from a timeline? 0 Answers

Why does the Animation Track control the track bindings position, 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