70 lines
1.4 KiB
C#
70 lines
1.4 KiB
C#
// (c) Copyright HutongGames, LLC 2010-2015. All rights reserved.
|
|
|
|
using UnityEngine;
|
|
|
|
namespace HutongGames.PlayMaker.Actions
|
|
{
|
|
[ActionCategory("RectTransform")]
|
|
[Tooltip("Get the normalized position in the parent RectTransform that the upper right corner is anchored to.")]
|
|
public class RectTransformGetAnchorMax : BaseUpdateAction
|
|
{
|
|
[RequiredField]
|
|
[CheckForComponent(typeof(RectTransform))]
|
|
[Tooltip("The GameObject target.")]
|
|
public FsmOwnerDefault gameObject;
|
|
|
|
[Tooltip("The anchorMax")]
|
|
[UIHint(UIHint.Variable)]
|
|
public FsmVector2 anchorMax;
|
|
|
|
[Tooltip("The x component of the anchorMax")]
|
|
[UIHint(UIHint.Variable)]
|
|
public FsmFloat x;
|
|
|
|
[Tooltip("The y component of the anchorMax")]
|
|
[UIHint(UIHint.Variable)]
|
|
public FsmFloat y;
|
|
|
|
|
|
RectTransform _rt;
|
|
|
|
public override void Reset()
|
|
{
|
|
base.Reset();
|
|
gameObject = null;
|
|
anchorMax = null;
|
|
x = null;
|
|
y = null;
|
|
|
|
}
|
|
|
|
public override void OnEnter()
|
|
{
|
|
GameObject go = Fsm.GetOwnerDefaultTarget(gameObject);
|
|
if (go != null)
|
|
{
|
|
_rt = go.GetComponent<RectTransform>();
|
|
}
|
|
|
|
DoGetValues();
|
|
|
|
if (!everyFrame)
|
|
{
|
|
Finish();
|
|
}
|
|
}
|
|
|
|
public override void OnActionUpdate()
|
|
{
|
|
DoGetValues();
|
|
}
|
|
|
|
void DoGetValues()
|
|
{
|
|
|
|
if (!anchorMax.IsNone) anchorMax.Value = _rt.anchorMax;
|
|
if (!x.IsNone) x.Value = _rt.anchorMax.x;
|
|
if (!y.IsNone) y.Value = _rt.anchorMax.y;
|
|
}
|
|
}
|
|
} |