public virtual void OnPointerClick(PointerEventData eventData)
 {
     // if somehow there ends up being more than two connector types
     // it might be better to refactor this functionality into the sub classes
     if (eventData.button == PointerEventData.InputButton.Left)
     {
         if (Canvas.CurrentTool == SPTool.Pointer)
         {
             if (this.ConnectedEdge == null)
             {
                 // We're starting a new edge
                 Canvas.StartEdge(this);
                 Canvas.CurrentTool = SPTool.DrawEdge;
             }
         }
         else if (Canvas.CurrentTool == SPTool.DrawEdge)
         {
             // We're finishing an edge
             try
             {
                 Canvas.FinishEdge(this);
                 Canvas.RestorePreviousTool();
             }
             catch (ArgumentException)
             {
                 // tried to connect to the wrong connector type
                 // don't need to do anything here
             }
         }
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Linked to each of the three segments using Unity inspector
        /// </summary>
        public void OnPointerClick(BaseEventData eventData)
        {
            var pointerEventData = (PointerEventData)eventData;

            if (pointerEventData.button == PointerEventData.InputButton.Right)
            {
                if (!Finalised)
                {
                    // Cancel drawing edge
                    Assert.AreEqual(this, Canvas.CurrentEdge);
                    Canvas.CurrentEdge.Delete();
                    Canvas.RestorePreviousTool();
                }
                else
                {
                    if (!this.Immutable)
                    {
                        // Delete edge
                        Delete();
                    }
                }
            }
        }