PlayMaker Updates & Downloads > Share New Actions

Set Mixer Float Value(s)

<< < (2/5) > >>

jeanfabre:
Hi,

 I would edit the post yes and remove attachements and make direct links to the files, as well as mentioning they are accessible on Ecosystem.

https://github.com/PlayMakerEcosystem/PlayMakerCustomActions_U5/tree/master/Assets/PlayMaker%20Custom%20Actions/AudioMixer


 Bye,

 Jean

tropical:
Alright,
I've edited my first post.
Thanks Jean!

jeanfabre:
Hi,

 Thanks a lot

also, make sure for new content that you add also a new tag __PLAYMAKER__ as it will be needed soon for detecting playmaker content amongst other assets.


Bye,

 Jean

Gua:
Is there a way to get AudioMixer float value?

tropical:

--- Quote from: Gua on September 22, 2017, 07:29:08 AM ---Is there a way to get AudioMixer float value?

--- End quote ---

Hello Gua!

Yes, there is (https://docs.unity3d.com/ScriptReference/Audio.AudioMixer.GetFloat.html). However, I don't think there is such a PM-action in the PM package / the ecosystem yet.

The respective action could look like this:


--- Code: ---// (c) Copyright HutongGames, LLC 2010-2015. All rights reserved.
// original actions from Tropical: http://hutonggames.com/playmakerforum/index.php?topic=11218.msg52963#msg52963
/*--- __ECO__ __PLAYMAKER__ __ACTION__ ---*/


using UnityEngine;
using UnityEngine.Audio;
using HutongGames.PlayMaker;

namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Audio)]
[ActionTarget(typeof(AudioMixer), "theMixer")]
[Tooltip("Gets the float value of an exposed parameter for a Unity Audio Mixer. Prior to calling SetFloat and after ClearFloat has been called on this parameter the value returned will be that of the current snapshot or snapshot transition.")]
public class AudioMixerGetFloatValue : FsmStateAction
{
[RequiredField]
[ObjectType(typeof(AudioMixer))]
[Tooltip("The Audio Mixer with the exposed parameter.")]
public FsmObject theMixer;

[RequiredField]
[Tooltip("The name of the exposed parameter.")]
[Title("Name of Parameter")]
public FsmString exposedFloatName;

[RequiredField]
[UIHintAttribute(UIHint.Variable)]
[Tooltip("Store the Float value in a variable")]
public FsmFloat storeFloatValue;

public bool everyFrame;

public override void Reset()
{
theMixer = null;
exposedFloatName = null;
storeFloatValue = null;
everyFrame = false;
}

public override void OnEnter()
{
DoGetMixerFloatValue();

if (!everyFrame)
Finish();
}

public override void OnUpdate()
{
DoGetMixerFloatValue();
}

public void DoGetMixerFloatValue()
{
var _TheMixer = theMixer.Value as AudioMixer;
var _ExposedFloatName = exposedFloatName.Value;

if (_TheMixer!=null && !string.IsNullOrEmpty(_ExposedFloatName))
{
var _storeFloatValue = 0F;
_TheMixer.GetFloat (_ExposedFloatName, out _storeFloatValue);
storeFloatValue.Value = _storeFloatValue;
}
}
}
}
--- End code ---

The above code should work  (if you need the action right now...), no errors when testing - though I don't know if it's 'perfect'.

@Jean: The code contains the ECO/PLAYMAKER/ACTION flags (just copied the 3 top lines from the AudioMixerSetFloatValue-action). I haven't put any actions on the ecosystem myself yet. Maybe you could do that, once again :), if you consider the code adequate. Thanks.

Best regards
tropical

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version