Playmaker Forum
PlayMaker Updates & Downloads => Share New Actions => Topic started by: MUX on August 28, 2015, 07:18:43 AM
-
was in need of this today, an official action doesn't exist so i created one..
the bool variable is to allow the facility to quickly transition back if event is called again, the float is the time to transitions.
not used to sharing actions, any recommended improvements?
using UnityEngine;
using UnityEngine.Audio;
using HutongGames.PlayMaker;
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Audio)]
public class TransitionToSnapshot : FsmStateAction
{
[RequiredField]
[UIHint(UIHint.Variable)]
public FsmBool boolVariable;
[RequiredField]
public AudioMixerSnapshot AudioSnapshotA;
[RequiredField]
public AudioMixerSnapshot AudioSnapshotB;
[RequiredField]
[UIHint(UIHint.Variable)]
public FsmFloat TransitionTime;
public override void Reset()
{
boolVariable = null;
TransitionTime = null;
AudioSnapshotB = null;
AudioSnapshotA = null;
}
public override void OnEnter()
{
DoBoolOperator();
Finish();
}
void DoBoolOperator()
{
var Bool = boolVariable.Value;
var _TransitionTime = TransitionTime.Value;
if(!Bool){
AudioSnapshotB.TransitionTo(_TransitionTime);
} else {
AudioSnapshotA.TransitionTo(_TransitionTime);
}
boolVariable.Value = !boolVariable.Value;
}
}
}
-
Hi,
Great, one thing to typically improve the action:
audioSnapShot public properties should become FsmObject of type "audioSnapShot", then developer can reference that snapshot outside the fsm logic, in a variable, expose it in the inspector and work with it in variosu places, with the action as is currently, you end up with having to drag and drop on every action which is not ideal for clarity and long term flexibility and maintenance of your project.
If you're ok with this changes, let me know, when it's done and I'll put it on the ecosystem. Else I could do it so you understand what I mean?
Bye,
Jean
-
thanks jean, i will try to improve with your suggestion and resubmit.
think it would also be better if i leave the bool logic out of the action itself though to make it more straight forward, then the dev can set up a custom bool logic in there own fsm.
-
Hi,
I wonder why the TransitionTime variable in this Action (Version: August 28) has the [UIHint(UIHint.Variable)]-thing? I don't know much about all that, but I think it forces you to input a variable as the value and doesn't let you just type a number. Sorry, if I'm wrong.
Bye,
Jay
-
think you are right. Not used to writing custom actions, so modified something different and worked for my scenario.
sorry haven't yet had time to improve this action to make it more flexible!
-
Hi,
no worries, just give me a shout when you have, an dI'll post it on the Ecosystem (http://j.mp/1Esn1mF)
Bye,
Jean
-
nice work MUX, works!