[Source Code] Get Unity Version C#


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 "";
    }
}


Comments

Popular Posts

VMOS Pro - FREE Custom ROMs without VIP | GMS, ROOT, Xposed | Android 4.4.4, 5.1.1, 7.1.2, 9.0 ROMs

List of Android Virtual Machine apps for Android devices