I have this in Awake()
and OnValidate()
(also have tried OnEnable()
)
string assetPath = AssetDatabase.GetAssetPath(this);
AssetDatabase.RenameAsset(assetPath, "myName");
The above renames the ScriptableObject
Asset in the Object Window in OnValidate()
but not in Awake()
or OnEnable()
.
Not sure if it matters, but I am creating the ScriptableObject
using this at the top of the SO class:
[CreateAssetMenu(fileName = "NewActor", menuName = "ScriptableObject/Object/Actor", order = 0)]
The Object is named NewActor
and not myName
until I enter some data in a field.
My goal is to the name asset based on name field and an id that I’m generating (not shown in the above code, since I can’t even get a simple myName
string to rename properly in Awake()
).