I'm working with AssetDatabase.CreateAsset
and all over the internet (not so much in the official documentation) I see
AssetDatabase.CreateAsset(blah, blahPath);
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
Why?
SaveAssets
says it Writes all unsaved asset changes to disk so I assume that there's a situation in which you can have changes to your assets in memory, but not on disk. Is this the case when you create an asset with CreateAsset
? I tried ending the Unity process right after creating a file but it looks like it writes to disk immediately, but I've only tried in-editor on Windows. Maybe it behaves differently in runtime or on different platforms.
Refresh
says it will import any assets that have changed their content modification data or have been added-removed to the project folder. The editor UI gets updated when I call CreateAsset even if I don't Refresh, so is this for updates from other sources, or what?
I'm trying to understand the process and not do things just because everyone does it like that.
AssetDatabase
s, but the general rule is, if the documentation doesn't support something, you are not supposed to use it that way. Obviously there are exceptions, but then its up to you. \$\endgroup\$ – TomTsagk Aug 31 '18 at 15:14