Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2296f02

Browse files
add editor tool to copy selected gameobject names to clipboard as a list
1 parent 329f7d8 commit 2296f02

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// editor tool to copy names of selected GameObjects to clipboard as a list (so you can paste them in Excel or others..)
2+
3+
using UnityEngine;
4+
using UnityEditor;
5+
using System.Text;
6+
namespace UnityLibrary.Tools
7+
{
8+
public class CopyGameObjectNames : EditorWindow
9+
{
10+
private string gameObjectNames = string.Empty;
11+
12+
[MenuItem("Tools/Copy GameObject Names")]
13+
public static void ShowWindow()
14+
{
15+
GetWindow<CopyGameObjectNames>("Copy GameObject Names");
16+
}
17+
18+
private void OnGUI()
19+
{
20+
GUILayout.Label("Copy Names of Selected GameObjects", EditorStyles.boldLabel);
21+
22+
if (GUILayout.Button("Fetch Names"))
23+
{
24+
FetchNames();
25+
}
26+
27+
GUILayout.Label("GameObject Names:", EditorStyles.label);
28+
gameObjectNames = EditorGUILayout.TextArea(gameObjectNames, GUILayout.Height(200));
29+
30+
if (GUILayout.Button("Copy to Clipboard"))
31+
{
32+
CopyToClipboard();
33+
}
34+
}
35+
36+
private void FetchNames()
37+
{
38+
StringBuilder sb = new StringBuilder();
39+
GameObject[] selectedObjects = Selection.gameObjects;
40+
41+
foreach (GameObject obj in selectedObjects)
42+
{
43+
sb.AppendLine(obj.name);
44+
}
45+
46+
gameObjectNames = sb.ToString();
47+
}
48+
49+
private void CopyToClipboard()
50+
{
51+
EditorGUIUtility.systemCopyBuffer = gameObjectNames;
52+
Debug.Log("GameObject names copied to clipboard.");
53+
}
54+
}
55+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /