I use the AssetDatabase.GetAssetPath() to find the path / file name of a gameobject. It serves my purpose fine… But this AssetDataBase is available only when i run from the editor. I can’t build a standalone exe file.
Is there any equivalent? Like… in resources?. However, I don’t load or “Instantiate” these objects… They are placed in the scene statically, so i can’t “save the path while loading”.
Thanks & Regards
I got my solution…
I do the GetAssetPath in edit mode and save the string (Which get saved along with the scene), and exclude the code in run mode, using ExecuteInEditMode.
This gives me another way for doing some more optimizations… To move some one-time calculations from runtime into edit time.
Another option I found to work is to use OnValidate() enclosed within #if UNITY_EDITOR (This is even better… I don’t have to add a separate class)