|
@@ -65,6 +65,33 @@ static int AssetDatabase_GetFolderAssets(duk_context* ctx)
|
|
|
return 1;
|
|
return 1;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+static int AssetDatabase_GetAssetsByImporterType(duk_context* ctx)
|
|
|
|
|
+{
|
|
|
|
|
+ JSVM* vm = JSVM::GetJSVM(ctx);
|
|
|
|
|
+ ToolSystem* ts = vm->GetSubsystem<ToolSystem>();
|
|
|
|
|
+ AssetDatabase* db = vm->GetSubsystem<AssetDatabase>();
|
|
|
|
|
+ Project* project = ts->GetProject();
|
|
|
|
|
+
|
|
|
|
|
+ StringHash type = duk_require_string(ctx, 0);
|
|
|
|
|
+
|
|
|
|
|
+ duk_push_array(ctx);
|
|
|
|
|
+
|
|
|
|
|
+ if (!project)
|
|
|
|
|
+ return 1;
|
|
|
|
|
+
|
|
|
|
|
+ PODVector<Asset*> assets;
|
|
|
|
|
+ db->GetAssetsByImporterType(type, assets);
|
|
|
|
|
+
|
|
|
|
|
+ for(unsigned i = 0; i < assets.Size(); i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ js_push_class_object_instance(ctx, assets[i], 0);
|
|
|
|
|
+ duk_put_prop_index(ctx, -2, i);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return 1;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
void jsapi_init_toolcore(JSVM* vm)
|
|
void jsapi_init_toolcore(JSVM* vm)
|
|
|
{
|
|
{
|
|
|
duk_context* ctx = vm->GetJSContext();
|
|
duk_context* ctx = vm->GetJSContext();
|
|
@@ -85,13 +112,13 @@ void jsapi_init_toolcore(JSVM* vm)
|
|
|
duk_push_c_function(ctx, js_atomic_GetAssetDatabase, 0);
|
|
duk_push_c_function(ctx, js_atomic_GetAssetDatabase, 0);
|
|
|
duk_put_prop_string(ctx, -2, "getAssetDatabase");
|
|
duk_put_prop_string(ctx, -2, "getAssetDatabase");
|
|
|
|
|
|
|
|
-
|
|
|
|
|
duk_pop(ctx);
|
|
duk_pop(ctx);
|
|
|
|
|
|
|
|
-
|
|
|
|
|
js_class_get_prototype(ctx, "ToolCore", "AssetDatabase");
|
|
js_class_get_prototype(ctx, "ToolCore", "AssetDatabase");
|
|
|
duk_push_c_function(ctx, AssetDatabase_GetFolderAssets, 1);
|
|
duk_push_c_function(ctx, AssetDatabase_GetFolderAssets, 1);
|
|
|
duk_put_prop_string(ctx, -2, "getFolderAssets");
|
|
duk_put_prop_string(ctx, -2, "getFolderAssets");
|
|
|
|
|
+ duk_push_c_function(ctx, AssetDatabase_GetAssetsByImporterType, 1);
|
|
|
|
|
+ duk_put_prop_string(ctx, -2, "getAssetsByImporterType");
|
|
|
duk_pop(ctx);
|
|
duk_pop(ctx);
|
|
|
|
|
|
|
|
|
|
|