- Home /
How to get the asset file from the AssetDatabase.CreateAsset()
I want to create an asset from a scriptable object (let call it SO) and make that asset to be the Selection.activeObject. How can I get that asset file? AssetDatabase.CreateAsset doesn't return anything and calling AssetDatabase.LoadAssetAtPath is unnecessarily costly (when AssetDatabase.CreateAsset can just return the asset file). I don't know if there is a better way to do this? Also, I wonder if the new asset has a reference to the SO, or does the CreateAsset function clone the value of SO?
Answer by Hellium · Feb 23, 2021 at 10:40 AM
The first argument you pass to the AssetDatabase.CreateAsset
function is the object to create the asset from. Have you tried using this object when setting Selection.activeObject
?
Your answer
Follow this Question
Related Questions
Custom assets give Missing (Mono Script) 0 Answers
Can I save a ScriptableObject holding data from a private database class without [SerializeField]? 1 Answer
Why unity can't create/save asset (ScriptableObject ) at runtime ? 1 Answer
Prefab as a subasset of a ScriptableObject 0 Answers
How to make game moddable? 1 Answer