private void DrawToolsButtons()
 {
     using (var hor = new EditorGUILayout.HorizontalScope())
     {
         var style = EditorStyles.toolbarButton;
         if (GUILayout.Button("AutoRecord", style))
         {
             foreach (var item in targetItem.ChildNodes)
             {
                 List <LinkPort> otherPorts;
                 if (LinkUtil.FindTriggerNodes(item, out otherPorts))
                 {
                     for (int i = 0; i < otherPorts.Count; i++)
                     {
                         var otherPort = otherPorts[i];
                         TryRecordConnect(item, otherPort);
                     }
                 }
             }
         }
         if (GUILayout.Button("LoadRecord", style))
         {
             if (Selection.instanceIDs != null && Selection.instanceIDs.Length == 2)
             {
             }
         }
         if (GUILayout.Button("ClampRot", style))
         {
             if (Selection.activeGameObject != null)
             {
                 var selected = Selection.activeGameObject;
                 if (selected == null)
                 {
                     return;
                 }
                 LinkUtil.ClampRotation(selected.transform);
             }
         }
     }
 }
        private void InitReorderLists()
        {
            portLists = new ReorderableList[linkPorts.Length];
            for (int i = 0; i < portLists.Length; i++)
            {
                var port = linkPorts[i];
                port.connectAble.Sort();

                portLists[i] = new ReorderableList(port.connectAble, typeof(LinkInfo));
                portLists[i].drawHeaderCallback = (rect) => {
                    var nameRect  = new Rect(rect.x + 15, rect.y, rect.width * 0.4f, EditorGUIUtility.singleLineHeight);
                    var idRect    = new Rect(rect.x + rect.width * 0.4f, rect.y, rect.width * 0.3f, EditorGUIUtility.singleLineHeight);
                    var rangeRect = new Rect(rect.x + rect.width * 0.55f, rect.y, 60, EditorGUIUtility.singleLineHeight);

                    EditorGUI.LabelField(nameRect, string.Format("目标({0}:{1})", port.name, port.NodeID));
                    EditorGUI.LabelField(idRect, "端口");
                    EditorGUI.BeginChangeCheck();
                    port.Range = GUI.HorizontalSlider(rangeRect, port.Range, 0.1f, 2);
                    if (EditorGUI.EndChangeCheck())
                    {
                        port.Range = (float)System.Math.Round(port.Range, 2);
                    }
                    var btnRect = new Rect(rect.x + rect.width - buttonWidth * 2f, rect.y, buttonWidth, EditorGUIUtility.singleLineHeight);

                    if (GUI.Button(btnRect, "Record"))
                    {
                        List <LinkPort> otherPorts;
                        if (LinkUtil.FindTriggerNodes(port, out otherPorts))
                        {
                            if (otherPorts != null && otherPorts.Count > 0)
                            {
                                var window = EditorWindow.GetWindow <LinkWindow>();
                                window.InitPortGroup(port, otherPorts.ToArray());
                            }
                        }
                    }
                    btnRect.x += buttonWidth;
                    if (GUI.Button(btnRect, "Link"))
                    {
                        if (Selection.activeGameObject != null)
                        {
                            var linkport = Selection.activeGameObject.GetComponentInParent <LinkPort>();
                            if (linkport != null)
                            {
                                var linkItem = linkport.GetComponentInParent <LinkItem>();
                                var linkInfo = port.connectAble.Find(x => x.itemName == linkItem.Name && x.nodeId == linkport.NodeID);
                                if (linkInfo != null)
                                {
                                    LinkUtil.ResetTargetTranform(targetItem, linkItem, linkInfo.relativePos, linkInfo.relativeDir);
                                }
                            }
                            else
                            {
                                EditorUtility.DisplayDialog("温馨提示", "请选择目标端口后重试", "确认");
                            }
                        }
                    }
                };
                portLists[i].drawElementCallback = (rect, index, isactive, isfoces) =>
                {
                    var linkInfo = port.connectAble[index];
                    var nameRect = new Rect(rect.x, rect.y, rect.width * 0.3f, EditorGUIUtility.singleLineHeight);
                    EditorGUI.LabelField(nameRect, linkInfo.itemName);
                    var idRect = new Rect(rect.x + rect.width * 0.4f, rect.y, rect.width * 0.3f, EditorGUIUtility.singleLineHeight);
                    EditorGUI.LabelField(idRect, linkInfo.nodeId.ToString());
                    var rangeRect = new Rect(rect.x + rect.width * 0.55f, rect.y, 60, EditorGUIUtility.singleLineHeight);
                    EditorGUI.LabelField(rangeRect, port.Range.ToString());
                };
            }
        }