- Home /
Question by
aaaaa12345 · Jul 23, 2015 at 06:07 PM ·
unity 5importasset
Import Asset if it's not already imported
I want dynamically import an asset if it has not been yet imported to the asset folder. In the manual there are two options to load asset: (1) ImportAsset and (2) LoadAssetAtPath. ImportAsset seems to import the asset in any case, while Load Asset loads assets only if they are needed. There is also Contains method, which checks if the object not yet in database.
So far, I have the following code:
using UnityEngine;
using UnityEditor;
public class ImportAsset {
[MenuItem ("AssetDatabase/Import Asset")]
static void ImportNewAsset ()
{
AssetDatabase.ImportAsset("Assets/Textures/texture.jpg", ImportAssetOptions.Default);
}
}
But it doesn't check if the asset already imported. So, how do I inspect if the asset is already imported?
Comment