playMaker

Author Topic: Change shadow distance at runtime?  (Read 871 times)

Silicon Power

  • Full Member
  • ***
  • Posts: 186
Change shadow distance at runtime?
« on: April 03, 2023, 09:57:58 PM »
Hi I need to change shadow distance at the runtime is there any action to do this for me?
« Last Edit: April 03, 2023, 10:07:28 PM by Silicon Power »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7623
    • jinxtergames
Re: Change shadow distance at runtime?
« Reply #1 on: April 04, 2023, 07:43:42 AM »
Hi.
I did a quick search and from what I understand you can't change it directly.

what might be possible is to setup different quality settings.
Then Set Quality Level (Ecosystem) to change

Silicon Power

  • Full Member
  • ***
  • Posts: 186
Re: Change shadow distance at runtime?
« Reply #2 on: April 04, 2023, 10:04:26 AM »
Hi.
I did a quick search and from what I understand you can't change it directly.

what might be possible is to setup different quality settings.
Then Set Quality Level (Ecosystem) to change

Thank you what about get quality? I need to get quality first

Christoph

  • Beta Group
  • Sr. Member
  • *
  • Posts: 254

Silicon Power

  • Full Member
  • ***
  • Posts: 186
Re: Change shadow distance at runtime?
« Reply #4 on: April 07, 2023, 12:33:36 PM »
Wouldn’t that be it?

https://forum.unity.com/threads/change-max-shadow-distance-at-runtime.1325874/

Hi thank you. Can you please make a playmaker action from this? I use default render pipleline

NolanBoisvert

  • Playmaker Newbie
  • *
  • Posts: 1
Re: Change shadow distance at runtime?
« Reply #5 on: April 13, 2023, 09:53:20 AM »
Thanks for the link.The shadow remains unchanged. While searching online for writing an essay draught since I don't know how to do it. I asked my friend and he told me to visit this site right here writinguniverse.com/essay-draft that will instructs me on how to do it. This helps me to complete my essay assignment on the time and I will write my essay easily.
« Last Edit: April 20, 2023, 02:58:56 AM by NolanBoisvert »

Christoph

  • Beta Group
  • Sr. Member
  • *
  • Posts: 254
Re: Change shadow distance at runtime?
« Reply #6 on: April 13, 2023, 02:00:46 PM »
Wouldn’t that be it?

https://forum.unity.com/threads/change-max-shadow-distance-at-runtime.1325874/

Hi thank you. Can you please make a playmaker action from this? I use default render pipleline
Sure. Here you go:

Code: [Select]
using UnityEngine;

namespace HutongGames.PlayMaker.Actions
{
[ActionCategory("QualitySettings")]
[Tooltip("Sets the Shadow Distance from the Project Quality Settings at runtime.")]
public class SetShadowDistance : FsmStateAction
{
[RequiredField]
[Tooltip("The Shadow Distance to set.")]
public FsmFloat shadowDistance;

[Tooltip("Repeat every frame while the state is active.")]
public bool everyFrame;

public override void Reset()
{
shadowDistance = 0f;
everyFrame = false;
}

public override void OnEnter()
{
DoSetShadowDistance();

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

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

public void DoSetShadowDistance()
        {
QualitySettings.shadowDistance = shadowDistance.Value;
}
}
}

Action is also attached so just drag it into your project. I tested it in my project and seems to work fine. I also added a 'everyframe' bool option so you could tween it if needed over time.

Cheers!