Search Unity

InputWeight across whole clip

Discussion in 'Timeline' started by StephenMorris, Oct 18, 2017.

  1. StephenMorris

    StephenMorris

    Joined:
    Mar 25, 2013
    Posts:
    35
    I'm trying to make a text clip increment upwards from 0 - n (100 in this case). Using the EaseIn duration, I can get it to do so via InputWeight, however, this only allows incrementation to 0.5 of the clip - what's the best way to getting this done over the length of the clip (essentially normalised time)?

    Code (CSharp):
    1.  trackBinding = playerData as TextMeshProUGUI;
    2.  
    3.         if (trackBinding == null)
    4.             return;
    5.  
    6.         int inputCount = playable.GetInputCount ();
    7.  
    8.         for (int i = 0; i < inputCount; i++)
    9.         {
    10.             float inputWeight = playable.GetInputWeight(i);
    11.             ScriptPlayable<NumberTweenerBehaviour> inputPlayable = (ScriptPlayable<NumberTweenerBehaviour>)playable.GetInput(i);
    12.             NumberTweenerBehaviour input = inputPlayable.GetBehaviour ();
    13.  
    14.             float newNumber = input.startNumber + (valueRange * inputWeight);
    15.  
    16.             // Use the above variables to process each frame of this playable.
    17.             trackBinding.SetText(Mathf.CeilToInt(newNumber).ToString());
    18.             Debug.Log("InputWeight: " + inputWeight);
    19.         }
    Any advice is highly appreciated!
     
  2. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    inputPlayable.GetTime() / inputPlayable.GetDuration() will give you the normalized time of the clip.
     
  3. StephenMorris

    StephenMorris

    Joined:
    Mar 25, 2013
    Posts:
    35
    Fantastic stuff Sean - many thanks