using NodeCanvas.Framework; using ParadoxNotion.Design; using UnityEngine; namespace NodeCanvas.Tasks.Conditions { [Category("Input (Legacy System)")] public class CheckMousePick : ConditionTask { public ParadoxNotion.ButtonKeys buttonKey; [LayerField] public int layer; [BlackboardOnly] public BBParameter saveGoAs; [BlackboardOnly] public BBParameter saveDistanceAs; [BlackboardOnly] public BBParameter savePosAs; private RaycastHit hit; protected override string info { get { var finalString = buttonKey.ToString() + " Click"; if ( !string.IsNullOrEmpty(savePosAs.name) ) finalString += string.Format("\n(SavePos As {0})", savePosAs); if ( !string.IsNullOrEmpty(saveGoAs.name) ) finalString += string.Format("\n(SaveGo As {0})", saveGoAs); return finalString; } } protected override bool OnCheck() { if ( Input.GetMouseButtonDown((int)buttonKey) ) { if ( Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, Mathf.Infinity, 1 << layer) ) { saveGoAs.value = hit.collider.gameObject; saveDistanceAs.value = hit.distance; savePosAs.value = hit.point; return true; } } return false; } } }