Access game version by code

Is there a way to read the version of the game by code, after that the game has been published through the editor?
I’d like to show it in the game and would be better to automate it, so to avoid mistakes.

I’m not quite sure it’s legal, but still. If guys from core team decide it’s not, I hope they would just delete this reply, not me.

So, first of all, you need to know your project ID. You can obtain it from Editor.
In console eval


Then in game you have to make ajax request to API.
Your end point is<project_id>/apps?limit=1

Since that, you will get json for your last build, where you can find your version.

In a sum, just use it like this:

pc.http.get("<project_id>/apps?limit=1", (code, response) => {console.log(response.result[0].version)});

1 Like

Nice trick :wink:

Wrap a little

function getLatestVersion(project_id) { 
	return new Promise(function(resolve, reject) {
		pc.http.get(""+project_id+"/apps?limit=1", (code, response) => {code? reject(code) : resolve(response.result[0].version)});

getLatestVersion(54667).then(version => console.log(version), error => console.log(error))

The only issue with this approach is that it returns the last published version regardless if the code is really updated.
I’m recently experiencing some caching problems, where the player is loading an old version of the game, and I need to show the version of that build.

Maybe you need to compare hash sums?