Cloud Code now allows access to external services!
You can now mix and match any UGS service through public API or Cloud Code SDK with your own existing tools and services. This should unlock a lot of exciting use cases and make it easier for you to migrate to UGS while retaining access to services you cannot do without.
We are working on an update to our documentation, in the meantime here is some sample code that calls out to the Cloud Save public API:
const axios = require("axios")
module.exports = async ({ params, context, logger }) => {
let config = {
headers: {
Authorization: `Bearer ${context.accessToken}`
}
};
let url = `https://cloud-save.services.api.unity.com/v1/data/projects/${context.projectId}/players/${context.playerId}/items?keys=HEALTH`;
let result = await axios.get(url, config);
return result.data;
};
We’re always looking to improve Cloud Code based on your feedback. Please don’t hesitate to post feature requests, questions and interesting use cases for us and others to consider.
Hi. If you run this sample as a Cloud Code script in the Dashboard, even if a given player (playerId) does not have the HEALTH item in their Cloud Save, you should receive this response:
{
"links": {
"next": null
},
"results": []
}
A 404 might occur if the url is incorrect for example …/items?keys=HEALTH endpoint call is changed to …/itemz?keys=HEALTH
I can’t seem to locate in the docs or within the web console where you can set secrets which can be used. I am working with Supabase and need to pass in keys to my requests and most certainly don’t want this embedded in the code.
As you’ve noticed thats a key feature that we’re currenty missing so I’m very happy to say that we are working on secret management functionality for Cloud Code!