コード例 #1
0
        public static void DrawConnectionPoint(ConnectionOutPoint point, int index, float spacing, Action <ConnectionOutPoint> onClickOut,
                                               Action <ConnectionOutPoint> onRemove)
        {
            if (!_setup)
            {
                Init();
            }
            var height = (point.Owner.Rect.height * ((index + 1) * spacing));

            point.Rect.y = point.Owner.Rect.y + height - point.Rect.height * 0.5f;
            point.Rect.x = point.Owner.Rect.x + point.Owner.Rect.width - 8f;
            if (GUI.Button(point.Rect, "", _outPointStyle))
            {
                onClickOut?.Invoke(point);
            }
            var labelRect = new Rect(point.Rect);

            GUI.Label(labelRect, " " + index.ToString(), _nodeTextStyle);
            var buttonRect = new Rect(point.Rect);

            if (point.Owner.OutPoints.Count <= point.Owner.OutputMin)
            {
                return;
            }
            buttonRect.x -= point.Rect.width + 1;
            if (GUI.Button(buttonRect, "-", _nodeTextStyle))
            {
                onRemove?.Invoke(point);
            }
        }
コード例 #2
0
        private void RemoveConnectionPoint(ConnectionOutPoint point)
        {
            //_graph.ClearConnectsWith(point);
//            for (int i = _graph.Connections.Count - 1; i >= 0; i--) {
//                if (_graph.Connections[i].GetIn() == point || _graph.Connections[i].GetOut() == point) {
//                    _graph.Connections.RemoveAt(i);
//                }
//            }
            point.Owner.OutPoints.Remove(point);
            EditorUtility.SetDirty(point.Owner);
        }
コード例 #3
0
 private void OnClickOutPoint(ConnectionOutPoint outPoint)
 {
     _selectedOutPoint = outPoint;
     if (_selectedInPoint != null)
     {
         if (_selectedOutPoint.Owner != _selectedInPoint.Owner)
         {
             CreateConnection();
             ClearConnectionSelection();
         }
         else
         {
             ClearConnectionSelection();
         }
     }
 }
コード例 #4
0
 private void OnClickRemoveConnection(ConnectionOutPoint outPnt)
 {
     outPnt.Target   = null;
     outPnt.TargetId = -1;
 }
コード例 #5
0
 private void ClearConnectionSelection()
 {
     _selectedInPoint  = null;
     _selectedOutPoint = null;
 }