What is the purpose of .bytes file in unity?

My friend has sent me the .bytes file from unity for machine learning model. But I don't know how to open it in python for ML. Could any one able to give me the answer about the .bytes file in unity.

  1. What is the purpose of it?
  2. How to use it for python?

1 answer

  • answered 2018-07-11 08:06 Programmer

    What is the purpose of it?

    It's a raw bytes of a file. Let's say that you want to import a file into Unity Resources folder and the file is not one of the supported resources files in Unity such as .png, .mp3 and .mp4, but you want Unity to include this special file extension in the final build, you change the file extension to .bytes. It will be included in the final build and you can load and retrieve it during run-time with the Resources API and TextAsset.bytes. It's simply used to hold binary data.

    How to use it for python?

    You can like you would with any binary file in python.

    byte = f.read(1)
    binary_string = bin(int(binascii.hexlify(byte), 16))[2:].zfill(8)
    

    See this for more information.