// (c) Copyright HutongGames, LLC 2010-2015. All rights reserved. using UnityEngine; namespace HutongGames.PlayMaker.Actions { [ActionCategory("RectTransform")] [Tooltip("Get the normalized position in this RectTransform that it rotates around.")] public class RectTransformGetPivot : BaseUpdateAction { [RequiredField] [CheckForComponent(typeof(RectTransform))] [Tooltip("The GameObject target.")] public FsmOwnerDefault gameObject; [Tooltip("The pivot")] [UIHint(UIHint.Variable)] public FsmVector2 pivot; [Tooltip("The x component of the pivot")] [UIHint(UIHint.Variable)] public FsmFloat x; [Tooltip("The y component of the pivot")] [UIHint(UIHint.Variable)] public FsmFloat y; RectTransform _rt; public override void Reset() { base.Reset(); gameObject = null; pivot = null; x = null; y = null; } public override void OnEnter() { GameObject go = Fsm.GetOwnerDefaultTarget(gameObject); if (go != null) { _rt = go.GetComponent(); } DoGetValues(); if (!everyFrame) { Finish(); } } public override void OnActionUpdate() { DoGetValues(); } void DoGetValues() { if (!pivot.IsNone) pivot.Value = _rt.pivot; if (!x.IsNone) x.Value = _rt.pivot.x; if (!y.IsNone) y.Value = _rt.pivot.y; } } }