- Home /
Why this code not working???
I am trying to save a mesh in assets. But it is not working.
I am making an editor window. Here is a test code:
if (GUILayout.Button ("Try Save")) {
AssetDatabase.AddObjectToAsset (new Mesh(),"Assets/text_M.asset");
AssetDatabase.Refresh ();
}
When I clicked "Try Save" button.. nothing happened. object is not saved.... Why???
I am using Unity 5 Personal Edition.
What do you mean by nothing happened? If you could state what result you were expecting, people might get a good idea of your issue.
The object is not saved I tried loading the object by same path... but it returned nothing.
Can you show us how you are trying to check if there is something in that asset?
Thanks it(AssetDatabase.CreateAsset) worked... I was missing this.
Answer by oscarlosu · Mar 16, 2015 at 01:59 PM
Are you trying to save the mesh as an asset (AssetDatabase.CreateAsset) or trying to add the mesh to an existing asset? Do you call AssetDatabase.SaveAssets at some point?
The problem is solved. I was trying to create mesh of a skinned mesh. And to save it.
Your answer
Follow this Question
Related Questions
Prefab as a subasset of a ScriptableObject 0 Answers
AssetDatabase.CreateAsset() - Value cannot be null 2 Answers
Getting assets / sub folders inside a folder 1 Answer
Addressables - Use Asset Database (faster) - Not loading assets within a folder 1 Answer
Cryptic assertion failure in AudioImporter.SaveAndReimport() 1 Answer