From a17e6183e344e66b8cefa9f606f2d45d4e699cc3 Mon Sep 17 00:00:00 2001 From: JenChieh Date: Sun, 3 Sep 2023 20:42:17 -0700 Subject: [PATCH] feat(UI): Add time scale slider --- .../Scripts/UI/Slider/JCS_SoundSlider.cs | 2 +- .../Scripts/UI/Slider/JCS_TimeScaleSlider.cs | 38 +++++++++++++++++++ .../UI/Slider/JCS_TimeScaleSlider.cs.meta | 11 ++++++ .../UI/Slider/JCS_TimeScaleSlider.md | 3 ++ 4 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 Assets/JCSUnity/Scripts/UI/Slider/JCS_TimeScaleSlider.cs create mode 100644 Assets/JCSUnity/Scripts/UI/Slider/JCS_TimeScaleSlider.cs.meta create mode 100644 docs/ScriptReference/UI/Slider/JCS_TimeScaleSlider.md diff --git a/Assets/JCSUnity/Scripts/UI/Slider/JCS_SoundSlider.cs b/Assets/JCSUnity/Scripts/UI/Slider/JCS_SoundSlider.cs index 1a88c43a..b66c5812 100644 --- a/Assets/JCSUnity/Scripts/UI/Slider/JCS_SoundSlider.cs +++ b/Assets/JCSUnity/Scripts/UI/Slider/JCS_SoundSlider.cs @@ -28,7 +28,7 @@ public class JCS_SoundSlider : MonoBehaviour [SerializeField] private JCS_SoundSettingType mSoundType = JCS_SoundSettingType.NONE; - /* Setter/Getter */ + /* Setter & Getter */ public Slider slider { get { return this.mSlider; } } public JCS_SoundSettingType SoundType { get { return this.mSoundType; } } diff --git a/Assets/JCSUnity/Scripts/UI/Slider/JCS_TimeScaleSlider.cs b/Assets/JCSUnity/Scripts/UI/Slider/JCS_TimeScaleSlider.cs new file mode 100644 index 00000000..dbbc0bdc --- /dev/null +++ b/Assets/JCSUnity/Scripts/UI/Slider/JCS_TimeScaleSlider.cs @@ -0,0 +1,38 @@ +/** + * $File: JCS_TimeScaleSlider.cs $ + * $Date: 2023-09-03 14:19:04 $ + * $Revision: $ + * $Creator: Jen-Chieh Shen $ + * $Notice: See LICENSE.txt for modification and distribution information + * Copyright (c) 2023 by Shen, Jen-Chieh $ + */ +using UnityEngine; +using UnityEngine.UI; + +namespace JCSUnity +{ + /// + /// Slider component to control time scale value. + /// + [RequireComponent(typeof(Slider))] + public class JCS_TimeScaleSlider : MonoBehaviour + { + /* Variables */ + + private Slider mSlider = null; + + /* Setter & Getter */ + + /* Functions */ + + private void Awake() + { + this.mSlider = this.GetComponent(); + } + + private void Update() + { + Time.timeScale = mSlider.value; + } + } +} diff --git a/Assets/JCSUnity/Scripts/UI/Slider/JCS_TimeScaleSlider.cs.meta b/Assets/JCSUnity/Scripts/UI/Slider/JCS_TimeScaleSlider.cs.meta new file mode 100644 index 00000000..408018db --- /dev/null +++ b/Assets/JCSUnity/Scripts/UI/Slider/JCS_TimeScaleSlider.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0784d507fb722d94e8550526b679d5b3 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/docs/ScriptReference/UI/Slider/JCS_TimeScaleSlider.md b/docs/ScriptReference/UI/Slider/JCS_TimeScaleSlider.md new file mode 100644 index 00000000..97c64fe5 --- /dev/null +++ b/docs/ScriptReference/UI/Slider/JCS_TimeScaleSlider.md @@ -0,0 +1,3 @@ +# JCS_TimeScaleSlider + +Slider component to control time scale value.