Exemplo n.º 1
0
        void TryConnect()
        {
            //itemA = EditorGUILayout.ObjectField("元素A", itemA, typeof(InOutItemBehaiver), true) as InOutItemBehaiver;
            node_A = EditorGUILayout.ObjectField("A子节点", node_A, typeof(NodeItemBehaiver), true) as NodeItemBehaiver;
            //itemB = EditorGUILayout.ObjectField("元素B", itemB, typeof(InOutItemBehaiver), true) as InOutItemBehaiver;
            node_B = EditorGUILayout.ObjectField("B子节点", node_B, typeof(NodeItemBehaiver), true) as NodeItemBehaiver;

            if (node_A != null)
            {
                item_A = FindInoutItem(node_A);
            }

            if (node_B != null)
            {
                item_B = FindInoutItem(node_B);
            }

            if (node_A == null || node_B == null || item_A == null || item_B == null)
            {
                return;
            }
            using (var group = new EditorGUILayout.HorizontalScope())
            {
                if (GUILayout.Button("建立坐标关系"))
                {
                    CreateConnect();
                }
                if (GUILayout.Button("加载已经连接"))
                {
                    LoadConnect();
                }
            }
        }
Exemplo n.º 2
0
        InOutItemBehaiver FindInoutItem(NodeItemBehaiver node)
        {
            Transform parent = node.transform.parent;

            while (parent.GetComponent <InOutItemBehaiver>() == null)
            {
                parent = parent.parent;
            }
            return(parent.GetComponent <InOutItemBehaiver>());
        }
Exemplo n.º 3
0
 private bool FindInstallableNode(INodeItem item, out INodeItem node)
 {
     Collider[] colliders = Physics.OverlapSphere(item.Pos, sphereRange, LayerMask.GetMask(LayerConst.nodeLayer));
     if (colliders != null && colliders.Length > 0)
     {
         foreach (var collider in colliders)
         {
             NodeItemBehaiver tempNode = collider.GetComponent <NodeItemBehaiver>();
             //主被动动连接点,非自身点,相同名,没有建立连接
             if (tempNode.Body != item.Body && tempNode.Info.nodeName == item.Info.nodeName && tempNode.ConnectedNode == null)
             {
                 if (tempNode.connectAble.Find((x) => x.itemName == item.Body.Name && x.nodeId == item.Info.nodeID) != null)
                 {
                     node = tempNode;
                     return(true);
                 }
             }
         }
     }
     node = null;
     return(false);
 }