forked from Unity-Technologies/EntityComponentSystemSamples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSliderHandler.cs
More file actions
22 lines (20 loc) · 733 Bytes
/
Copy pathSliderHandler.cs
File metadata and controls
22 lines (20 loc) · 733 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
using System;
using Unity.Entities;
using UnityEngine;
using UnityEngine.UI;
public class SliderHandler : MonoBehaviour
{
public Text sliderValueText;
public void OnSliderChange()
{
float fixedFps = GetComponent<Slider>().value;
var fixedSimulationGroup = World.DefaultGameObjectInjectionWorld?.GetExistingSystemManaged<FixedStepSimulationSystemGroup>();
if (fixedSimulationGroup != null)
{
// The group timestep can be set at runtime:
fixedSimulationGroup.Timestep = 1.0f / fixedFps;
// The current timestep can also be retrieved:
sliderValueText.text = $"{(int) (1.0f / fixedSimulationGroup.Timestep)} updates/sec";
}
}
}