Asset embed fix

This commit is contained in:
Joshua Granick
2016-12-19 21:00:50 -08:00
parent 5940a1cad0
commit f54528b9e2

View File

@@ -79,7 +79,7 @@ class AssetsMacro {
};
var args = [ { name: "length", opt: false, type: macro :Int }, { name: "bytesData", opt: false, type: macro :haxe.io.BytesData } ];
var args = [ { name: "length", opt: true, type: macro :Int }, { name: "bytesData", opt: true, type: macro :haxe.io.BytesData } ];
fields.push ({ name: "new", access: [ APublic ], kind: FFun({ args: args, expr: constructor, params: [], ret: null }), pos: Context.currentPos () });
#end
@@ -159,12 +159,22 @@ class AssetsMacro {
#else
var path = filePath;
if (!sys.FileSystem.exists(filePath)) {
path = Context.resolvePath (filePath);
}
var bytes = File.getBytes (path);
var resourceName = "__ASSET__" + metaName + "_" + (classType.pack.length > 0 ? classType.pack.join ("_") + "_" : "") + classType.name;
if (Context.getResources ().exists (resourceName)) {
return null;
}
if (encode) {
var resourceType = "image/png";