Tanoda
DrawLine.cs
Go to the documentation of this file.
1using System.Collections.Generic;
2using UnityEngine;
5
6public class DrawLine : MonoBehaviour, IDragHandler, IBeginDragHandler, IEndDragHandler
7{
8 private UILineRenderer line;
9 private LineObject lineObj;
10
11 public void OnBeginDrag(PointerEventData eventData)
12 {
13 Controller.Instance.StartConnection(eventData.rawPointerPress.name,
14 Controller.Instance.GetActionByInOut(eventData.rawPointerPress.name).gameObject.name);
15 }
16
17 public void OnDrag(PointerEventData eventData)
18 {
19 Controller.Instance.DragConnection(eventData.position);
20 }
21
22 public void OnEndDrag(PointerEventData eventData)
23 {
24 var results = new List<RaycastResult>();
25 EventSystem.current.RaycastAll(eventData, results);
26 try
27 {
28 if (results[0].gameObject.tag.Equals("ACTION_INPUT"))
29 Controller.Instance.EndConnection(results[0].gameObject.name,
30 Controller.Instance.GetActionByInOut(results[0].gameObject.name).gameObject.name);
31 else
33 }
34 catch (System.ArgumentOutOfRangeException) //Csak editorban fordulhat elő
35 {
37 }
38 }
39
40 public void OnPointerClick(PointerEventData eventData)
41 {
42 Debug.Log("click");
43 }
44}
UnityEngine.Debug Debug
Definition: TanodaServer.cs:19
void DragConnection(Vector2 position)
Definition: Controller.cs:812
void EndConnection(string inputID, string actionID)
Definition: Controller.cs:760
ActionObject GetActionByInOut(string id)
Definition: Controller.cs:925
static Controller Instance
Definition: Controller.cs:16
void StartConnection(string outputID, string actionID)
Definition: Controller.cs:753
void OnDrag(PointerEventData eventData)
Definition: DrawLine.cs:17
void OnBeginDrag(PointerEventData eventData)
Definition: DrawLine.cs:11
void OnPointerClick(PointerEventData eventData)
Definition: DrawLine.cs:40
void OnEndDrag(PointerEventData eventData)
Definition: DrawLine.cs:22
Credit Erdener Gonenc - @PixelEnvision.