playMaker

Author Topic: Set Shadow Resolution  (Read 2331 times)

terri

  • Sr. Member
  • ****
  • Posts: 386
    • terrivellmann.tumblr.com
Set Shadow Resolution
« on: July 07, 2017, 02:36:30 PM »
Been struggling with this, so checking if anyone else has a clue.

I'm building an options menu and want the player to able to set the shadow quality.

At first I was trying to use this:
https://docs.unity3d.com/ScriptReference/QualitySettings-shadowResolution.html
But after wasting some time it appears I should be using this:
https://docs.unity3d.com/540/Documentation/ScriptReference/Light-shadowResolution.html

( I say that because of the reply on this: https://feedback.unity3d.com/suggestions/allow-shadow-quality-to-be-changed-at-runtime-via-scripts )

However, I'm not sure how to actualy set the variable in code.
This was as far as I got:
Code: [Select]
using UnityEngine;

namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Lights)]
[Tooltip("Sets the Intensity of a Light.")]
public class SetLightShadowQuality : ComponentAction<Light>
{
[RequiredField]
[CheckForComponent(typeof(Light))]
public FsmOwnerDefault gameObject;

[ObjectType(typeof(LightShadowResolution))]
public FsmEnum shadowResolution;


public override void Reset()
{
gameObject = null;
shadowResolution = LightShadowResolution.Low;
}

public override void OnEnter()
{
var go = Fsm.GetOwnerDefaultTarget(gameObject);
    if (UpdateCache(go))
    {
                light.shadowResolution = (LightShadowResolution)shadowResolution.Value;
    }

    Finish();
   
}

}
}


terri

  • Sr. Member
  • ****
  • Posts: 386
    • terrivellmann.tumblr.com
Re: Set Shadow Resolution
« Reply #1 on: July 07, 2017, 02:42:38 PM »
Well of course a minute after posting I figured it out, I just needed to add "using UnityEngine.Rendering;"

Action is attached if anyone needs it.

If I'm mistaken and it is possible to set it through the Quality Settings I'd love to know how though!
« Last Edit: July 07, 2017, 02:44:48 PM by terri »