Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using UnityEngine.UI;
- namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityInput
- {
- [TaskCategory("Basic/Input")]
- [TaskDescription("Stores the mouse clicked object.")]
- public class DetectClickedObject : Action
- {
- [Tooltip("The stored result")]
- public SharedGameObject storeResult;
- [Tooltip("ObjectName")]
- public SharedString ObjectName;
- [Tooltip("Tagrestriction")]
- public string tagname = "Player1";
- public override TaskStatus OnUpdate()
- {
- if (Input.GetMouseButtonDown(0))
- {
- var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
- RaycastHit hit;
- if (Physics.Raycast(ray, out hit, 100))
- {
- if (hit.collider.tag == tagname)
- {
- storeResult = GameObject.Find(hit.collider.name);
- GameObject.Find("ChoosenAssistantButton").GetComponentInChildren<Text>().text = hit.collider.name;
- ObjectName = hit.collider.name;
- //GlobalVariables.Instance.SetVariable("AssistantChosenObj", storeResult);
- Debug.Log(hit.collider.name);
- }
- }
- }
- return TaskStatus.Success;
- }
- public override void OnReset()
- {
- storeResult = null;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement