- Home /
Create asset does not work and do not give meaningful error
I am stuck on this one. I am trying to create a copy of an asset. I used this code https://forum.unity.com/threads/assetdatabase-copyasset-and-resources-load-what-am-i-doing-wrong.143958/ My code looks like this: public DisruptorBeam.Content.EventContent bEventDefinition;
private void CloneEvent()
{
DisruptorBeam.Content.EventContent clonedAsset = Instantiate(bEventDefinition);
AssetDatabase.StartAssetEditing();
try {
AssetDatabase.CreateAsset(clonedAsset, Application.dataPath + "/DisruptorEngine/Editor/content/events/");
} catch (Exception e) {
EditorUtility.DisplayDialog("Error", "Error cloning asset", "Ok");
return;
}
finally
{
AssetDatabase.StopAssetEditing();
}
And I am getting the UnityException: Creating asset at path C:/Breal/unity/Assets/DisruptorEngine/Editor/content/events/ failed. But I do not know why it failed, the folder is exists and it is not read-only
try removing the last / from this: AssetDatabase.CreateAsset(clonedAsset, Application.dataPath + "/DisruptorEngine/Editor/content/events/");
Your answer
Follow this Question
Related Questions
AssetDatabase.AddToObject with existing assets 1 Answer
Importing custom assets? 0 Answers
Cannot save a generated texture as part of a bundle 1 Answer
How do I import assets from the Asset Store while offline? 2 Answers
Unity Error removes assets - "Rebuilding Library because asset database could not be found!" 0 Answers