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. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

Weird use of timeline (I think). Just a single frame thing - how to do?

Discussion in 'Timeline' started by jerotas, Oct 6, 2018.

  1. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,555
    I basically want to be able to call a static method on my API from a particular frame on the timeline, passing in a string value (that the user can input into the timeline asset) to the static class method.

    My questions is, how is that done? All the blogs I've read about timeline seems to focus on things that morph over several frames and not a 1 frame event that does its own thing once it starts.

    Is that possible? If so, how?
     
  2. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    The simplest approach is to put in the OnEnable method of MonoBehaviour() and use an activation track in timeline on the corresponding GameObject.

    Or, you can create a custom clip and put your call in an override to PlayableBehaviour::OnBehaviourPlay(). See https://blogs.unity3d.com/2018/09/05/extending-timeline-a-practical-guide/ for a brief overview of scripting in timeline.
     
  3. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,555
    Thank you, the Activation Track is perfect and works!