Unity Runtime Sketchfab Login Data API Import / Export

There have been several topics about using our Unity plugin(s) at runtime instead of only in the editor. I will combine them all here.

In short, it’s on our todo list, but requires some technical changes. The primary requirement is to remove all UnityEditor.dll dependencies. More information from @waleguene in the merged topics below.

Is it possible to browse sketch fab in standalone app? I downloaded the “sketchfab for unity” thing from the asset store but all the plugins it uses seem to be editor only. I am interested in using it on Windows & Android.

At the moment, our plugin is only made for the editor. It should be possible to use it or something similar at runtime / in a Unity app, but I don’t think we have anything ready to go, @waleguene?

Okay, thanks. I’ll see what I can do.

Hi @stavros99,

The plugin currently uses some of the features provided by UnityEditor, but there are only a few. In order to make it embeddable inside a build (Windows, Android), the code needs to be updated to remove the UnityEditor dependency (and the preprocessor directives #if UNITY_EDITOR/#else/#endif).

We already discussed about this but didn’t started to work on it yet.

1 Like

I was hoping the Sketchfab Unity api would allow for runtime searching and importing like the Google Poly does. Am I correct that this is not currently supported? Is there any plan to add support to this?

I’ve checked into this a bit further. I believe that runtime searches and imports are supported by the “Sketchfab for Unity” asset at run time, but you need to dig in an find that code that does the login, and the searching. There is no documentation for how to do any of this provided by the asset…which is fine. It should be possible to cut and paste some of this code, and use it in my application.

I’m not clear on what you’re asking here exactly; using our Unity importer plugin you can search and import assets. If you want to code something yourself you can use our Download API. Does that answer it?

No, I’m afraid not yet. Adding support for runtime is something we want to do in a future version of the importer/exporter, but there is quite a bit of work to do.

Thanks. I’ve spent a few days working on this, and have the search, download, and runtime loading of models working now. I just needed to tweak the code in various places. I’m using your Unity asset code for logging in, doing searches, and downloading. Then I’m using the Kronos GLTF code to load themodels at runtime. In your Unity asset, you have this in a .dll, but I found the version you were using, and used the non-dll code instead. I wish the API allowed for smaller versions of the files. Some models have unecessarily large (like 20mb) texture files that can be compressed 10x without losing much fidelity.

1 Like

Also, has Sketchfab checked into using GLTF draco to compress the meshes? Some of gltf files are also very large due to the meshes.

1 Like

Thanks for the update and feedback. @waleguene maybe some useful info for you?

I’m trying to login sketchfab on runtime using “username” and " password", but when i’m logging through editor window its logging inn (printing “accesstoken”).

runtime - accesstoken - not getting
editor window - accesstoken - getting.

At the moment, I don’t think you can login at runtime. @waleguene ?

Hi @suzitpunk,

The plugin is currently not designed to work at runtime, but I tested and I’m able to login at runtime (meaning clicking Play, opening the plugin and loggin in)

Do you have any issue in the console ? Also, do you use the latest version (1.0.2) ?
The access token should not be printed anymore

@waleguene, thanks for the reply

Runtime means through scene(with in the app-VR), are you able to login? Actually according to our app feature there should be login through game(standalone), is it possible? If yes, then can i get code snippet? Ans yes i’m using latest version 1.0.2

@suzitpunk
The login is just a UnityWebRequest being sent and the response being retrieved and read so it’s possible and it should work yes.
I don’t have any snippet for login but I have one that runs a UnityWebRequest at runtime (in Editor pushing Play, or in a build app) and uses the Sketchfab API to search for models.
It was just a test to check that Sketchfab API can be requested in runtime Unity apps.

In order to visually check the result, a cube is translated by request.responseCode / 10 (so the middle cube is not aligned anymore with the two other cubes at the end)

It’s just a way to check that the response is not 0 and that the requests works.

Maybe it can help:
TestAPI.zip (14.4 MB)

1 Like

@waleguene, Thanks for that. I’ll check for it.

I just posted another post about using the API at runtime to seach for and import sketchfab models. Then I found this post. Waleguene, did you intend to include a Unity project in the TestAPI.zip? Because all I see is a built executable which (because there is no code to view) isn’t very helpful. The Google Poly API does support both searches (that return metadata including thumbnails), and model imports. It’s pretty great! I was hoping the sketchfab api would also support this. I’ve seen some posts suggesting this isn’t supported, but you post makes me think it might be, so I’m confused about this. Thanks!

Hi @Stephen.Gower,

TestAPI.zip was just a quick build running a very small script to ensure that UnityWebRequest was able to run successful requests on our API at runtime, but it does nothing more so for the runtime search/import models it’s missing 99% of the work.

We discussed several times about having a runtime version of our Unity plugin, as it has been asked a lot by the community.
The main blocker is that we currently don’t have the bandwidth to work on this, as it’s a bit out of our current target which is providing a way for games and app developers 3D assets for their development.

However, we still need to evaluate what it would mean to make it work runtime. If it’s quick enough to do, it could be done on the side, but I cannot promise anything on this.

I hope it answers your question :slight_smile:

1 Like