Answer the question
In order to leave comments, you need to log in
I do not know why it gives an error cs1585? String(32,9)?
using UnityEngine;
using UnityEngine.InputSystem;
namespace InfimaGames.LowPolyShooterPack
{
///
/// Time Manager.
///
public class TimeHandler : MonoBehaviour
{
public InputAction
[Header("Settings")]
[Tooltip("Value the time scale gets updated by every time.")]
[SerializeField]
///
/// Determines if the time is stopped.
///
///
/// Current Time Scale.
///
///
/// Updates The Time Scale.
///
public float increment = 0.1f;
public bool paused;
public float current = 1.0f;
///
public void Scale()
{
//Update Time Scale.
Time.timeScale = current;
}
///
/// Change Time Scale.
///
public void Change(float value = 1.0f)
{
//Save Value.
current = value;
//Update.
Scale();
}
///
/// Increase Time Scale Value.
///
private void Increase(float value = 1.0f)
{
//Change.
Change(Mathf.Clamp01(current + value));
}
///
/// Pause.
///
private void Pause()
{
//Pause.
paused = true;
//pause.
Time.timeScale = 0.0f;
}
///
/// Toggle Pause.
///
private void Toggle()
{
//Toggle Pause.
if (paused)
Unpause();
else
pause();
}
///
/// Unpause.
///
private void Unpause()
{
//Unpause.
paused=false;
//Unpause.
change(current);
}
///
/// Increase Time Scale Event.
///
public virtual void OnIncrease(InputAction.CallbackContext context)
{
//Switch.
switch(context.phase)
{
//Performed.
case InputActionPhase.Performed:
//Increase.
increase(increment);
break;
}
}
///
/// Increase Time Scale Event.
///
public virtual void OnDecrease(InputAction.CallbackContext context)
{
//Switch.
switch(context.phase)
{
//Performed.
case InputActionPhase.Performed:
//Increase.
increase(-increment);
break;
}
}
///
/// Toggle TimeScale Stop.
///
public virtual void OnToggle(InputAction.CallbackContext context)
{
//Switch.
switch(context.phase)
{
//Performed.
case InputActionPhase.Performed:
//Toggle.
toggle();
break;
}
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question