Question by
ShyshyDai · Jul 12, 2018 at 09:43 AM ·
editormeshmeshfilter
How to get the name of a model file(fbx) contained in a certain prefab with scripts?
Hi, I want to output a list about all the prefabs in the project and the related .fbx files with custom editor.
But now I can only get FilterMesh.name and sharedMesh.name.
I realized that I can select the .fbx file via click here
So I think it should be possible to get the information.
Here is the related code.I don't think it is necessary but still paste here.
public void GetMeshList()
{
for (int i = 0; i < prefab_list.Count; i++)
{
GameObject _prefab = AssetDatabase.LoadAssetAtPath(prefab_path[i] + "\\" + prefab_list[i], typeof(GameObject)) as GameObject;
if (_prefab != null)
{
MeshFilter[] _mf = _prefab.GetComponentsInChildren<MeshFilter>();
for (int j = 0; j < _mf.Length; j++)
{
GameObject go = _mf[j].gameObject;
//mesh_list.Add(prefab_list[i].ToString().Replace(".prefab","") + "=>" + _mf[j].name);
string str1 = _mf[j].name;
while (go.transform.parent!=null)
{
str1 = string.Concat(go.transform.parent.name + "=>" + str1);
go = go.transform.parent.gameObject;
}
mesh_list.Add(str1);
CalculateFinalData(_mf[j].sharedMesh, scale);
}
}
}
}
Thx!
微信图片-20180712172517.png
(5.5 kB)
Comment
Answer by ShyshyDai · Jul 12, 2018 at 09:48 AM
https://answers.unity.com/questions/527173/how-to-get-the-original-model-file-name-of-renamed.html A same question but haven't been solved.