question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Improve method of finding Unity version

See original GitHub issue

Currently, the target version of Unity comes from the defines in the .csproj (e.g. UNITY_5_5). This doesn’t work for external class libraries, where the define isn’t set manually, and if the version isn’t set

The version should come from /ProjectSettings/ProjectVersion.txt, or even from the editor itself via the protocol (although this doesn’t help class libraries).

See #121 for more context, and examples of how to get the version

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:13 (12 by maintainers)

github_iconTop GitHub Comments

2reactions
Ethan-VisualVocalcommented, Aug 8, 2018

It may be worth noting that ProjectSettings/ProjectVersion.txt doesn’t get proactively saved by Unity when you open a project with a newer version of Unity. (Which frustrates me.)

User must trigger the save for the new version to be written out. (Not sure about all of the entry-points for that to happen, other than Cmd/Ctrl-S or File->Save Project.)

Your layered approach will account for this, I just wanted to mention this issue if you didn’t already know about it.

EDIT: This is only for external class libraries, right? Any reason to not tell authors via a build error that they should add a project define for the Unity version they’re targeting?

1reaction
citizenmattcommented, Oct 18, 2018

So, in order of priority, most accurate to least:

  • Get version from the protocol. We’ll need to cope with this appearing and disappearing during the solution lifetime. I don’t see this being an issue
  • Parse version from defines in C# project. This is likely to be most accurate, as the currently open Unity will have generated the project files
  • Fetch version from Unity app if UnityEngine.dll is from an install folder. This should hopefully help class libraries, but the assembly is not guaranteed to be referenced from the install folder
  • Read version from ProjectSettings/ProjectVersion.txt. This is the least reliable, as it really reflects the version of Unity that last saved the project, and could be different to currently open. Class libraries might not even have this file
  • A per-project setting, saved to .sln.dotSettings
  • Default value of the latest supported Unity (get it from our Unity API data)

And also show version information in the settings page, with a message where it came from.

Read more comments on GitHub >

github_iconTop Results From Across the Web

A way to check Unity version in a project
To view the version your project was built with you can open the ProjectSettings.asset with NotePad++ or something similar and the version ......
Read more >
How to know Unity version of an Unity project without open ...
How to know Unity version of an Unity project without open it? ... Under ProjectSettings in the project folder there's a ProjectVersion.txt.
Read more >
Finding the Name and Editor Version Used in Unity Projects
The editor version used to create the project is found on the very first line of the file. All that is necessary to...
Read more >
The best way to upgrade your Unity project to a newer ...
The best way to upgrade your Unity project to a newer version of Unity. ... Find the Shader in the Project folder with...
Read more >
Application.version - Scripting API
This function returns the current version of the Application. This is read-only. To set the version number in Unity, go to Edit>Project Settings>Player....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found