// (c) Copyright HutongGames, LLC 2010-2018. All rights reserved. namespace HutongGames.PlayMaker.Actions { [ActionCategory(ActionCategory.UI)] [Tooltip("Gets the normalized value (between 0 and 1) of a UI Slider component.")] public class UiSliderGetNormalizedValue : ComponentAction { [RequiredField] [CheckForComponent(typeof(UnityEngine.UI.Slider))] [Tooltip("The GameObject with the UI Slider component.")] public FsmOwnerDefault gameObject; [RequiredField] [UIHint(UIHint.Variable)] [Tooltip("The normalized value (between 0 and 1) of the UI Slider.")] public FsmFloat value; [Tooltip("Repeats every frame")] public bool everyFrame; private UnityEngine.UI.Slider slider; public override void Reset() { gameObject = null; value = null; everyFrame = false; } public override void OnEnter() { var go = Fsm.GetOwnerDefaultTarget(gameObject); if (UpdateCache(go)) { slider = cachedComponent; } DoGetValue(); if (!everyFrame) { Finish(); } } public override void OnUpdate() { DoGetValue(); } private void DoGetValue() { if (slider != null) { value.Value = slider.normalizedValue ; } } } }