void RecoreNameAndID(ConnectAble nodeArecored, ConnectAble nodeBrecored) { nodeArecored.itemName = item_B.name; nodeBrecored.itemName = item_A.name; nodeArecored.nodeId = node_B.NodeID; nodeBrecored.nodeId = node_A.NodeID; }
void CreateConnect() { RecordInout(); ConnectAble nodeArecored = node_A.connectAble.Find((x) => x.itemName == item_B.name && x.nodeId == node_B.NodeID); ConnectAble nodeBrecored = node_B.connectAble.Find((x) => x.itemName == item_A.name && x.nodeId == node_A.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", "确认"); }
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; }
private void LoadConnect() { ConnectAble nodeArecored = node_A.connectAble.Find((x) => x.itemName == item_B.name && x.nodeId == node_B.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.NodeID); }); if (connect != null) { Body.ResetBodyTransform(ConnectedNode.Body, connect.relativePos, connect.relativeDir); } } }