internal static void DrawBottomPanel(Object target, IEnumerable <Object> targets) { Event e = Event.current; if (e != null) { if (e.type == EventType.MouseDown) { if (e.button == 2) { if (e.alt) { AutoReferencer.FindReferences(targets); e.Use(); return; } SelectionHelper.ToggleGameObjcetActiveSelf(); e.Use(); } } } if (s_BottomPanelContents == null) { s_BottomPanelContents = new BottomPanelContents(); } EditorGUILayout.BeginHorizontal(); { //if (GUILayout.Button(s_BottomPanelContents.calc)) //{ // Process.Start(new ProcessStartInfo("calc.exe ")); //} if (GUILayout.Button(s_BottomPanelContents.findRef)) { AutoReferencer.FindReferences(targets); } if (GUILayout.Button(s_BottomPanelContents.calledByEditor, "ButtonLeft")) { AutoReferencer.CalledByEditor(targets); } if (GUILayout.Button(s_BottomPanelContents.calledByEditorc, "ButtonRight")) { TextEditor te = new TextEditor(); te.text = @" #if UNITY_EDITOR private void CalledByEditor() { } #endif "; te.OnFocus(); te.Copy(); } } EditorGUILayout.EndHorizontal(); }
internal static void DrawBottomPanel(Object target, IEnumerable <Object> targets) { Event e = Event.current; if (e != null) { if (e.type == EventType.MouseDown) { if (e.button == 2) { if (e.alt) { AutoReferencer.FindReferences(targets); e.Use(); return; } SelectionHelper.ToggleGameObjcetActiveSelf(); e.Use(); } } } if (s_BottomPanelContents == null) { s_BottomPanelContents = new BottomPanelContents(); } EditorGUILayout.BeginHorizontal(); { if (GUILayout.Button(s_BottomPanelContents.findRef)) { AutoReferencer.FindReferences(targets); } if (GUILayout.Button(s_BottomPanelContents.name)) { //sb用来生成代码并复制到剪贴板 StringBuilder sb = new StringBuilder(128); foreach (Object item in targets) { Transform t = item as Transform; Image img = t.GetComponent <Image>(); //优先给Image命名 if (img && img.sprite) { Undo.RecordObject(t.gameObject, "Rename"); t.name = "img" + img.sprite.name; sb.Append("public Image ").Append(t.name).AppendLine(";"); continue; } Component[] coms = t.GetComponents <Component>(); //没有Image的话 if (coms.Length > 1) //只有Transform的话排除 { Undo.RecordObject(t.gameObject, "Rename"); string strType = coms[1].GetType().Name; string strValue = strType[0].ToString().ToLower() + strType.Substring(1); t.name = strType; sb.Append("public ").Append(strType).Append(" ").Append(strValue).AppendLine(";"); } } GUIUtility.systemCopyBuffer = sb.ToString(); } if (GUILayout.Button(s_BottomPanelContents.calledByEditor, "ButtonLeft")) { AutoReferencer.CalledByEditor(targets); } if (GUILayout.Button(s_BottomPanelContents.calledByEditorc, "ButtonRight")) { GUIUtility.systemCopyBuffer = @" #if UNITY_EDITOR private void CalledByEditor() { } #endif "; } } EditorGUILayout.EndHorizontal(); }