- Home /
Question by
DaiMangouDev · Sep 13, 2015 at 01:21 PM ·
c#editoreditorwindowassetdatabase
How do I return the path of a sub-asset in an AssetDatabase ?
How do i return the path of a sub-asset in an asset database ?
Return the path of 'Comp 1' in 'Comp Project'
This is just for example , I actually hide all the sub-assets via HideFlags, so that only Comp Project is seen. Do they actually have individual paths ? I am trying to delete Comp1 via script . I tried AssetDatabase.DeleteAsset but I can t get the path...
comp6.jpg
(13.0 kB)
Comment
As far as I know you can't. To delete an asset I load everything from the file and use DestroyImmediate() on the object.
I just tried this
UnityEngine.Object[] allassets = AssetDatabase.LoadAllAssetsAtPath(AssetDatabase.GetAssetPath(path to Comp Project));
string final = (allassets.ElementAt(1).name);
it will return the name Comp1
but that is all i got so far . I tried to do this
AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(path to Comp Project +"/"+ final));
but as expected noting happens
As I said, I don't think you can do it that way. Use DestroyImmediate(myObject, true) to delete the object.