Exemple #1
0
        void CreateConnect()
        {
            RecordInout();

            ConnectAble nodeArecored = node_A.connectAble.Find((x) => x.itemName == item_B.itemInfo.name && x.nodeId == node_B.Info.nodeID);
            ConnectAble nodeBrecored = node_B.connectAble.Find((x) => x.itemName == item_A.itemInfo.name && x.nodeId == node_A.Info.nodeID);

            //已经记录过
            if (nodeArecored == null)
            {
                nodeArecored = new ConnectAble();
                node_A.connectAble.Add(nodeArecored);
            }
            if (nodeBrecored == null)
            {
                nodeBrecored = new ConnectAble();
                node_B.connectAble.Add(nodeBrecored);
            }

            RecoreNameAndID(nodeArecored, nodeBrecored);
            RecordTransform(nodeArecored, nodeBrecored, item_A.transform, item_B.transform);

            EditorUtility.SetDirty(node_A);
            EditorUtility.SetDirty(node_B);
            EditorUtility.DisplayDialog("通知", "Complete", "确认");
        }
Exemple #2
0
 void RecoreNameAndID(ConnectAble nodeArecored, ConnectAble nodeBrecored)
 {
     nodeArecored.itemName = item_B.itemInfo.name;
     nodeBrecored.itemName = item_A.itemInfo.name;
     nodeArecored.nodeId   = node_B.Info.nodeID;
     nodeBrecored.nodeId   = node_A.Info.nodeID;
 }
Exemple #3
0
        void RecordTransform(ConnectAble nodeArecored, ConnectAble nodeBrecored, Transform ourItem, Transform otherItem)
        {
            nodeArecored.relativePos = otherItem.InverseTransformPoint(ourItem.position);
            nodeArecored.relativeDir = otherItem.InverseTransformDirection(ourItem.forward); //Quaternion.Inverse(ourItem.rotation) * otherItem.rotation;

            nodeBrecored.relativePos = ourItem.InverseTransformPoint(otherItem.position);
            nodeBrecored.relativeDir = ourItem.InverseTransformDirection(otherItem.forward);// Quaternion.Inverse(otherItem.rotation) * ourItem.rotation;
        }
Exemple #4
0
        private void LoadConnect()
        {
            ConnectAble nodeArecored = node_A.connectAble.Find((x) => x.itemName == item_B.itemInfo.name && x.nodeId == node_B.Info.nodeID);

            if (nodeArecored != null)
            {
                item_A.transform.position = item_B.transform.TransformPoint(nodeArecored.relativePos);
                item_A.transform.forward  = item_B.transform.TransformDirection(nodeArecored.relativeDir);
            }
        }
 public void ResetTransform()
 {
     if (ConnectedNode != null)
     {
         ConnectAble connect = connectAble.Find(x => { return(x.itemName == ConnectedNode.Body.Name && x.nodeId == ConnectedNode.Info.nodeID); });
         if (connect != null)
         {
             Body.ResetBodyTransform(ConnectedNode.Body, connect.relativePos, connect.relativeDir);
         }
     }
 }