Join our Discord Channel
// (c) Copyright HutongGames, LLC 2010-2011. All rights reserved.using UnityEngine;namespace HutongGames.PlayMaker.Actions{ [ActionCategory(ActionCategory.Input)] [Tooltip("Gets the XY Positions of the mouse and stores it in a Float Variables.")] public class GetMouseXY : FsmStateAction { [RequiredField] [UIHint(UIHint.Variable)] public FsmFloat storeResultX; [UIHint(UIHint.Variable)] public FsmFloat storeResultY; public bool normalize; public bool everyFrame; public override void Reset() { storeResultX = null; storeResultY = null; normalize = true; everyFrame = false; } public override void OnEnter() { DoGetMouseXY(); if (!everyFrame) { Finish(); } } public override void OnUpdate() { DoGetMouseXY(); } void DoGetMouseXY() { if (storeResultX != null) { float xpos = Input.mousePosition.x; if (normalize) xpos /= Screen.width; storeResultX.Value = xpos; } if (storeResultY != null) { float ypos = Input.mousePosition.y; if (normalize) ypos /= Screen.height; storeResultY.Value = ypos; } } }}