- Home /
Question by
ugur_gok · Dec 20, 2020 at 02:54 PM ·
prefabeditor-scriptingassetprefabutility
How do I change the name of the prefab in the prefab folder with code?
There is this code in the prefab and I want to write a number in front of the name of my prefab, but this code does not work.
private void OnValidate()
{
string path = UnityEditor.AssetDatabase.GetAssetPath(gameObject);
string name = identity.Length + "-" + identity;
UnityEditor.AssetDatabase.RenameAsset(path, name);
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
}
Comment