From 98ecbf19c2da3d5208e28b6340dc67ab79f96363 Mon Sep 17 00:00:00 2001 From: chrisgregan Date: Mon, 19 Oct 2015 13:34:25 +0100 Subject: [PATCH] Added Set Slider Value command #297 --- .../UI/Scripts/Commands/SetSliderValue.cs | 42 +++++++++++++++++++ .../Scripts/Commands/SetSliderValue.cs.meta | 12 ++++++ Assets/Tests/UI/TextTests.unity | 2 +- 3 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 Assets/Fungus/UI/Scripts/Commands/SetSliderValue.cs create mode 100644 Assets/Fungus/UI/Scripts/Commands/SetSliderValue.cs.meta diff --git a/Assets/Fungus/UI/Scripts/Commands/SetSliderValue.cs b/Assets/Fungus/UI/Scripts/Commands/SetSliderValue.cs new file mode 100644 index 00000000..cb4478ff --- /dev/null +++ b/Assets/Fungus/UI/Scripts/Commands/SetSliderValue.cs @@ -0,0 +1,42 @@ +using UnityEngine; +using UnityEngine.UI; +using System.Collections; + +namespace Fungus +{ + + [CommandInfo("UI", + "Set Slider Value", + "Sets the value property of a slider object")] + public class SetSliderValue : Command + { + [Tooltip("Target slider object to set the value on")] + public Slider slider; + + [Tooltip("Float value to set the slider value to.")] + public FloatData value; + + public override void OnEnter() + { + slider.value = value; + + Continue(); + } + + public override Color GetButtonColor() + { + return new Color32(235, 191, 217, 255); + } + + public override string GetSummary() + { + if (slider == null) + { + return "Error: Slider object not selected"; + } + + return slider.name + " = " + value.GetDescription(); + } + } + +} \ No newline at end of file diff --git a/Assets/Fungus/UI/Scripts/Commands/SetSliderValue.cs.meta b/Assets/Fungus/UI/Scripts/Commands/SetSliderValue.cs.meta new file mode 100644 index 00000000..d94fc643 --- /dev/null +++ b/Assets/Fungus/UI/Scripts/Commands/SetSliderValue.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 2d82f2f1b848347c19a48abd65541523 +timeCreated: 1444656241 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Tests/UI/TextTests.unity b/Assets/Tests/UI/TextTests.unity index 7b43a529..0f186dc9 100644 --- a/Assets/Tests/UI/TextTests.unity +++ b/Assets/Tests/UI/TextTests.unity @@ -940,7 +940,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!114 &396899563 MonoBehaviour: m_ObjectHideFlags: 0