Skip to content

Instantly share code, notes, and snippets.

@beardordie
Created January 28, 2019 01:43
Show Gist options
  • Save beardordie/f965daa73514b42c741e9b43ca74d39e to your computer and use it in GitHub Desktop.
Save beardordie/f965daa73514b42c741e9b43ca74d39e to your computer and use it in GitHub Desktop.
Click-to-assign a name field from a Scriptable Object's filename (requires Odin Inspector)
[InlineButton("AutoName", "Auto")]
public new string name;
public void AutoName()
{
#if UNITY_EDITOR
string assetPath = UnityEditor.AssetDatabase.GetAssetPath(GetInstanceID());
name = System.IO.Path.GetFileNameWithoutExtension(assetPath);
#endif
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment