0%

Unity Editor Utils

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
[MenuItem("Assets/Helper/Get Texture Path For Houdini Terrain",true,1)]
static bool _GetTexturePathForHoudiniTerrain()
{
if(Selection.assetGUIDs.Length>0)
{
string path = AssetDatabase.GUIDToAssetPath(Selection.assetGUIDs[0]);
string temp = "Resources/";
int index = path.IndexOf(temp);
if(index>-1)
{
return true;
}
}
return false;
}
[MenuItem("Assets/Helper/Get Texture Path For Houdini Terrain",false,1)]
static void _GetTexturePathForHoudiniTerrain()
{
string path = AssetDatabase.GUIDToAssetPath(Selection.assetGUIDs[0]);
string temp = "Resources/";
int index = path.IndexOf(temp);
int end = path.lastIndexOf(',');
index += temo.Length;
GUIUtility.systemCopyBuffer = path.Substring(index,end-index);
}

[MenuItem("Assets/Helper/Trim File Name")]
static void TrimFileName()
{
if(Selection.assetGUIDs.Length >0)
{
for(int i=0;i<Selection.assetGUIDs.Length;++i)
{
string path = AssetDatabase.GUIDToAssetPath(Selection.assetGUIDs[i]);
string fileName = Path.GetFileName(path);
int index = path.IndexOf(' ');
if(index>-1)
{
string newFileName = fileName.Replace(' ','_');
string rst = AssetDatabase.RenameAsset(path,newFileName);
}
}
AssetDatabase.SaveAssets();
}
}