Tutorial [Source Code] Get Unity Version C#

AndnixSH

PMT Elite Modder
Staff member
Modding-Team
As requested.
This code read unity asset binary and get strings of unity version

C#:
using System;
using System.IO;
using System.Text;

C#:
string UnityVersion(string file)
{
    try
    {
        BinaryReader br = new BinaryReader(File.OpenRead(file));
        string hex = null;
        for (int i = 0x14; i <= 0x1f; i++)
        {
            br.BaseStream.Position = i;
            hex += br.ReadByte().ToString("X2");
        }
        br.Close();
        var bytes = new byte[hex.Length / 2];
        for (var i = 0; i < bytes.Length; i++)
        {
            bytes[i] = Convert.ToByte(hex.Substring(i * 2, 2), 16);
        }
        string str = Encoding.ASCII.GetString(bytes);
        var strs = str.Split('.');
       // Logs("Got unity version");
        return strs[0] + "." + strs[1];
    }
    catch (Exception ex)
    {
        //Logs("Error: Couldn't get unity version. " + ex.Message);
        return "";
    }
}
 
Back
Top Bottom