Code: Select all
public class Rename
{
[MenuItem("Assets/Test")]
private static void renameTest()
{
//select a fbx in project window
GameObject fbx = Selection.activeGameObject;
Mesh meshAsset = fbx.GetComponentInChildren().sharedMesh;
meshAsset.name = "new name";
Debug.Log(meshAsset);
}
}
< /code>
Ich habe es auch versucht: < /p>
private static void renameTestv2()
{
GameObject fbx = Selection.activeGameObject;
Mesh meshAsset = fbx.GetComponentInChildren().sharedMesh;
Mesh meshAsset2 = Object.Instantiate(meshAsset);
meshAsset2.name = "new name";
fbx.GetComponentInChildren().sharedMesh = meshAsset2;
}
< /code>
Der dritte Weg kann den Namen des Netzes in der Meshfilter -Komponente von FBX ändern, aber das tatsächliche Subasset verwendet immer noch die alte.private static void renameTest()
{
GameObject fbx = Selection.activeGameObject;
string path = AssetDatabase.GetAssetPath(fbx);
Mesh meshAsset = AssetDatabase.LoadAllAssetRepresentationsAtPath(path)[0] as Mesh;
meshAsset.name = "new name";
fbx.GetComponentInChildren().sharedMesh = meshAsset;
Debug.Log(meshAsset);
}
Die Datei aa.fbx in Einheit in bb.fbx < /li>
BB.FBX in 3DSMAX importieren und den Namen von AA in 3DSMAX < /li>
export in unität als bbbx erneut.>