Custom request header when streaming 3D tiles from URL

Hi,
I would like to stream 3D Tiles from our own cloud into Unity with the “Tileset Source” -Option set to “From Url”. However my content is private and I use custom cookies in http request header to authenticate request. What scripts or classes should I modify to develop this feature. Normally in Unity I would use:
UnityWebRequest.SetRequestHeader(“Cookie”, “CookieValue”);

but now I probably have to deal with c++ also and I do not have a proper knowledge to get started with. Could someone help with this? I am happy to share the outcome to the community.

Hi @Tkorho89, yes, as you’ve observed, you will need to modify C++ code to accomplish this. You can find the developer setup instructions here:

Thank, I now managed to manually set cookie in UnityAssetAccessor.cpp but how to read that cookie string from c# side?

I don’t think I quite understand what you’re doing. Why do you need to read the cookie string from C#?

We have an API that generates the signed cookie based on user authentication every time user starts Unity runtime application whre most of the application is done i c# already. The cookie is then stored in c# side to be used in various unitywebrequests. I thought that storing this cookie in some c# static property and using reinterop I could fetch the cookie using c++ UnityAssetAccessor.cpp to be used there. I tried setting static property into Cesium3Dtileset.cs and into my own custom class to store it there for c++ usage without success. Perhaps i just had something wrong with my setup when trying this.

Perhaps there is much more easier way to achieve this but anyway I need somehow to get the signed cookie to be transferred from c# side into the loader that loads tileset from url (unitywebrequest in unityassetaccessor) via code. Getting and setting cookie from API is done runtime so cookie should be handled via c# and not as user input via editor.

Any thoughts what might be the right way to continue?

Sounds like you’re on the right track. After you added your property to Cesium3DTileset.cs, did you also add some code that accesses it to ConfigureReinterop.cs? That file is what tells Reinterop what to expose to C++.

This blog post might be helpful, if you haven’t seen it already:

Similar problem in node but can probably do How to change the header when requesting b3dm files?

Hi,

Thanks again. I have been reading and following those guidelines and also this: cesium-unity/Reinterop~ at main · CesiumGS/cesium-unity · GitHub

After trial and error I noticed that I was modifying ConfigureReinterop.cs in Runtime-folder but everything started to work when I also made the modifications into ConfigureReinterop.cs in Editor-Folder.