playMaker

Author Topic: Set Shadow Resolution  (Read 186 times)

terri

  • Sr. Member
  • ****
  • Posts: 349
    • View Profile
    • terrivellmann.tumblr.com
Set Shadow Resolution
« on: July 07, 2017, 11:36:30 AM »
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: 349
    • View Profile
    • terrivellmann.tumblr.com
Re: Set Shadow Resolution
« Reply #1 on: July 07, 2017, 11:42:38 AM »
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, 11:44:48 AM by terri »