示例#1
0
    public static Texture2D ImportTexture(string path, AssetHelper.ImportDone doneFn = null)
    {
        var fullPath = Utils.CombinePath(dataPath, path);

        if (!File.Exists(fullPath))
        {
            Debug.LogWarning("Could not find referenced texture: " + fullPath);
            return(null);
        }

        var texPath = GenerateAssetPath(path, Path.GetExtension(path));

        if (!File.Exists(texPath))
        {
            Directory.CreateDirectory(Path.GetDirectoryName(texPath));
            File.Copy(fullPath, texPath);
            AssetHelper.ImportTexture(texPath, doneFn);
        }
        else
        {
            AssetHelper.Delay(doneFn);
        }
        return(AssetDatabase.LoadAssetAtPath <Texture2D>(texPath));
    }