Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: joshua121 on January 14, 2017, 12:55:02 PM

Title: Help with modifying custom action?
Post by: joshua121 on January 14, 2017, 12:55:02 PM
Hi,

I found this action in the forums and it targets the exposure of the procedural skybox. The only problem with it is that it only sets the exposure with a static number and does not have the option of using a variable.

I would like to modify the code to allow for the use of a float variable for the exposure.

I do not know much of anything about code, and though I've been trying to figure this out for hours I've had no luck. Any help would be greatly appreciated.

Here is the code.

Code: [Select]
using UnityEngine;

namespace HutongGames.PlayMaker.Actions
{
[ActionCategory("Skybox")]
[Tooltip("Allows Adjustment of Procedural Skybox")]
public class SkyBoxAdjust : FsmStateAction
{


public Material ProceduralSkyBox;
public bool everyFrame;
public float exposure;

public override void Reset()
{

ProceduralSkyBox = null;
everyFrame = false;

}

public override void OnEnter()
{
if (ProceduralSkyBox != null && exposure != null)
{
ProceduralSkyBox.SetFloat

("_Exposure",exposure);
}

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

public override void OnUpdate()
{
if (ProceduralSkyBox != null && exposure != null)
{
ProceduralSkyBox.SetFloat

("_Exposure",exposure);
}
}

}
}
Title: Re: Help with modifying custom action?
Post by: Chizzler on January 14, 2017, 03:32:23 PM
Alright, I can't promise this'll work as i don't have much coding experience either. It's not throwing up any errors in the console though, and lets me input a variable. Give it a try and let me know =)

Code: [Select]
using UnityEngine;

namespace HutongGames.PlayMaker.Actions
{
[ActionCategory("Skybox")]
[Tooltip("Allows Adjustment of Procedural Skybox")]
public class SkyBoxAdjust : FsmStateAction
{


public Material ProceduralSkyBox;
public bool everyFrame;
[RequiredField]
public FsmFloat exposure;

public override void Reset()
{

ProceduralSkyBox = null;
everyFrame = false;
exposure = null;

}

public override void OnEnter()
{
if (ProceduralSkyBox != null && exposure != null)
{
ProceduralSkyBox.SetFloat

("_Exposure",exposure.Value);
}

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

public override void OnUpdate()
{
if (ProceduralSkyBox != null && exposure != null)
{
ProceduralSkyBox.SetFloat

("_Exposure",exposure.Value);
}
}

}
}
Title: Re: Help with modifying custom action?
Post by: jeanfabre on March 01, 2017, 12:46:42 AM
Hi,

 Have you tried "SetMaterialFloat", you can set the exposure property with that action I think, did you tried and it didn't work?

 Bye,

 Jean