playMaker

Author Topic: Timeline Set Duration  (Read 2699 times)

tomraegan

  • Playmaker Newbie
  • *
  • Posts: 14
Timeline Set Duration
« on: August 18, 2018, 06:25:37 PM »
Hi!

https://hutonggames.com/playmakerforum/index.php?topic=15465.15

This thread contains Timeline actions. It includes a Get Duration, which grabs the duration of the timeline without an issue. I want to change the duration of the timeline and then Set Duration. Set Duration does not yet exist as an action.

I was wondering if someone could help me by creating a Set Duration?

Here is the code for Get Duration:

Code: [Select]
// (c) Copyright HutongGames, LLC 2010-2017. All rights reserved.
/*--- __ECO__ __PLAYMAKER__ __ACTION__ ---*/

using System;
using UnityEngine;
using UnityEngine.Playables;

namespace HutongGames.PlayMaker.Actions
{
[ActionCategory("Timeline")]
[Tooltip("Get the current timelines duration. This action requires Unity 2017.1 or above.")]

public class  getTimelineDuration : FsmStateAction
{
[RequiredField]
[CheckForComponent(typeof(PlayableDirector))]
[Tooltip("The game object to hold the unity timeline components.")]
public FsmOwnerDefault gameObject;

[Tooltip("Returns the current timeline duration in seconds as a float.")]
[UIHint(UIHint.Variable)]
public FsmFloat duration;
private double _duration;

[Tooltip("Check this box to preform this action every frame.")]
public FsmBool everyFrame;

private PlayableDirector timeline;

public override void Reset()
{

gameObject = null;
everyFrame = false;
duration = null;
}

public override void OnEnter()
{
var go = Fsm.GetOwnerDefaultTarget(gameObject);
timeline = go.GetComponent<PlayableDirector>();

timelineAction();

if (!everyFrame.Value)
{
Finish();
}

}

public override void OnUpdate()
{

timelineAction();

}

void timelineAction()
{
var go = Fsm.GetOwnerDefaultTarget(gameObject);
if (go == null || timeline == null)
{
return;
}

_duration = timeline.duration;
duration.Value = (float)_duration;
}

}
}

Thanks!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Timeline Set Duration
« Reply #1 on: August 20, 2018, 03:10:48 AM »
Hi,

 The timeline duration is a get only, you can not set it.

 What are you trying to achieve?

 Bye,

 Jean

tomraegan

  • Playmaker Newbie
  • *
  • Posts: 14
Re: Timeline Set Duration
« Reply #2 on: August 21, 2018, 05:18:58 AM »
Thanks for the reply, jeanfabre. I rely heavily on your support of these forums.

I'm trying to set the speed of the timeline, replicating what I believe (but am not sure of) is contained inside this line of code:

Code: [Select]
playableDirector.playableGraph.GetRootPlayable(0).SetSpeed
My goal is to be able to increase and decrease the speed at which timelines play in realtime.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Timeline Set Duration
« Reply #3 on: August 22, 2018, 05:31:46 AM »
Hi,

 that's ok, I am here for that :)

I have pushed a new action on the Ecosystem called SetPlayableSpeed

It works on my tests, let me know if all is well on your end.


 Bye,

Jean



tomraegan

  • Playmaker Newbie
  • *
  • Posts: 14
Re: Timeline Set Duration
« Reply #4 on: August 22, 2018, 05:43:27 PM »
Hi,

 that's ok, I am here for that :)

I have pushed a new action on the Ecosystem called SetPlayableSpeed

It works on my tests, let me know if all is well on your end.


 Bye,

Jean




Works perfectly.

Thanks kindly. Such great support on these boards.