All Projects → HearthSim → Unitypack

HearthSim / Unitypack

Licence: mit
Python deserialization library for Unity3D Asset format

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Unitypack

Unitypcss
Nvidia's PCSS soft shadow algorithm implemented in Unity
Stars: ✭ 533 (-7.14%)
Mutual labels:  unity, unity3d
Mixedreality Webrtc
MixedReality-WebRTC is a collection of components to help mixed reality app developers integrate audio and video real-time communication into their application and improve their collaborative experience
Stars: ✭ 568 (-1.05%)
Mutual labels:  unity, unity3d
Firefly
Unity ECS example for special effects
Stars: ✭ 489 (-14.81%)
Mutual labels:  unity, unity3d
Kinomotion
Motion blur post-processing effect for Unity
Stars: ✭ 484 (-15.68%)
Mutual labels:  unity, unity3d
Swarm
An example of use of compute shaders and procedural instancing.
Stars: ✭ 547 (-4.7%)
Mutual labels:  unity, unity3d
Randomation Vehicle Physics
Vehicle physics system for the Unity engine.
Stars: ✭ 487 (-15.16%)
Mutual labels:  unity, unity3d
Texturepanner
This repository hosts a shader for Unity3D whose main goal is to facilitate the creation of neon-like signs, conveyor belts and basically whatever based on scrolling textures
Stars: ✭ 528 (-8.01%)
Mutual labels:  unity, unity3d
Unitybookpagecurl
Page curl effect for Unity3d using UGUI
Stars: ✭ 464 (-19.16%)
Mutual labels:  unity, unity3d
Unity3d Rainbow Folders
This asset allows you to set custom icons for any folder in unity project browser.
Stars: ✭ 519 (-9.58%)
Mutual labels:  unity, unity3d
Unity Frosted Glass
❄️ Test of a frosted glass material in Unity.
Stars: ✭ 506 (-11.85%)
Mutual labels:  unity, unity3d
Rsvfx
An example that shows how to connect RealSense depth camera to Unity VFX Graph
Stars: ✭ 541 (-5.75%)
Mutual labels:  unity, unity3d
Unity Shadergraph Sandbox
✏️ Collection of ShaderGraph examples for Unity.
Stars: ✭ 525 (-8.54%)
Mutual labels:  unity, unity3d
Inputmanager
Custom InputManager for Unity
Stars: ✭ 479 (-16.55%)
Mutual labels:  unity, unity3d
Jengine
JEngine是针对Unity开发者设计的开箱即用的框架,封装了强大的功能,小白也能快速上手,轻松制作可以热更新的游戏 | JEngine is a streamlined and easy-to-use framework designed for Unity Programmers which contains powerful features, beginners can start up quickly and making hot update-able games easily
Stars: ✭ 564 (-1.74%)
Mutual labels:  unity, unity3d
Kvantwig
Non-realistic hair simulation in Unity
Stars: ✭ 467 (-18.64%)
Mutual labels:  unity, unity3d
Unity Reorderable List
Extended version of the Reorderable List in Unity
Stars: ✭ 489 (-14.81%)
Mutual labels:  unity, unity3d
Reorderableinspector
Automatic reorderable lists for Unity game engine components
Stars: ✭ 455 (-20.73%)
Mutual labels:  unity, unity3d
Unityurpunlitscreenspacedecalshader
Unity unlit screen space decal shader for URP. Just create a new material using this shader, then assign it to a new unity cube GameObject = DONE, now you have unlit decal working in URP
Stars: ✭ 455 (-20.73%)
Mutual labels:  unity, unity3d
Consolation
In-game debug console for Unity.
Stars: ✭ 489 (-14.81%)
Mutual labels:  unity, unity3d
Fontainebleaudemo
Fontainebleau demo
Stars: ✭ 524 (-8.71%)
Mutual labels:  unity, unity3d

UnityPack

Build Status

A library to deserialize Unity3D Assets and AssetBundles files (*.unity3d).

Dependencies

How Unity packs assets

Most extractors for Unity3D files (such as Disunity) deal with the format as a "file store", treating it as one would treat a zip. This is not how the format actually works.

Unity files are binary-packed, serialized collections of Unity3D classes. To this end, they are much closer to a json file containing arrays of objects.

Some of those classes have fields which contain raw data, such as Texture2D's image data field or TextAsset's m_Script field. Using this, files can be "extracted" from the asset bundles by using their m_Name and an appropriate extension. But doing so leaves out all the "unextractable" classes which one might want to deal with.

Usage

To open an asset, or asset bundle, with unitypack:

import unitypack

with open("example.unity3d", "rb") as f:
	bundle = unitypack.load(f)

	for asset in bundle.assets:
		print("%s: %s:: %i objects" % (bundle, asset, len(asset.objects)))

The objects field on every Asset is a dictionary of path_id keys to ObjectInfo values. The path_id is a unique 64-bit signed int which represents the object instance. The ObjectInfo class is a lazy lookup for the data on that object.

Thus, if you want to actually extract the data:

for id, object in asset.objects.items():
	# Let's say we only want TextAsset objects
	if object.type == "TextAsset":
		# We avoid reading the data, unless it's a TextAsset
		data = object.read()
		# The resulting `data` is a unitypack.engine.TextAsset instance
		print("Asset name:", data.name)
		print("Contents:", repr(data.script))

Not all base Unity3D classes are implemented. If a class is unimplemented, or a custom class (eg. a non-Unity class) is encountered, the resulting data is a dict of the fields instead. The same dict of fields can be found in the _obj attribute of the instance, otherwise.

Included tools

Included are two scripts which use unitypack for some common operations:

Asset extraction

unityextract can extract common types of data from assets and asset bundles, much like Disunity. By default, it will extract all known extractable types:

  • AudioClip objects will be converted back to their original format. Note that recent Unity3D versions pack these as FSB files, so python-fsb5 is required to convert them back.
  • Texture2D objects will be converted to png files. Not all Texture2D formats are supported. Pillow version >= 3.4 is required for this. decrunch is required for DXT1Crunched / DXT5Crunched.
  • Mesh objects (3D objects) will be pickled. Pull requests implementing a .obj converter are welcome and wanted.
  • TextAsset objects will be extracted as plain text, to .txt files
  • Shader objects work essentially the same way as TextAsset objects, but will be extracted to .cg files.

Filters for individual formats are available. Run unityextract --help for the full list.

YAML conversion

unity2yaml can convert AssetBundles to YAML output. YAML is more appropriate than JSON due to the recursive, pointer-heavy and class-heavy nature of the Unity3D format.

When run with the --strip argument, extractable data will be stripped out. This can make the resulting YAML output far less heavy, as binary data will otherwise be converted to Base64 which can result in extremely large text output.

Here is a stripped example of the movies0.unity3d file from Hearthstone, which contains only two objects (a MovieTexture cinematic and a corresponding AudioClip):

!unitypack:AudioClip
m_BitsPerSample: 16
m_Channels: 0
m_CompressionFormat: 0
m_Frequency: 0
m_IsTrackerFormat: false
m_Legacy3D: false
m_Length: 0.0
m_LoadInBackground: false
m_LoadType: 0
m_Name: Cinematic audio
m_PreloadAudioData: true
m_Resource: !unitypack:StreamedResource {m_Offset: 0, m_Size: 0, m_Source: ''}
m_SubsoundIndex: 0

m_AssetBundleName: ''
m_Container:
- first: final/data/movies/cinematic.unity3d
  second:
    asset: !PPtr [0, -4923783912342650895]
    preloadIndex: 0
    preloadSize: 2
m_Dependencies: []
m_IsStreamedSceneAssetBundle: false
m_MainAsset: {asset: null, preloadIndex: 0, preloadSize: 0}
m_Name: ''
m_PreloadTable:
- !PPtr [0, -6966092991433622133]
- !PPtr [0, -4923783912342650895]
m_RuntimeCompatibility: 1

!unitypack:stripped:MovieTexture
m_AudioClip: !PPtr [0, -6966092991433622133]
m_ColorSpace: 1
m_Loop: false
m_MovieData: <stripped>
m_Name: Cinematic

Stripped classes will be prefixed with unitypack:stripped:.

License

python-unitypack is licensed under the terms of the MIT license. The full license text is available in the LICENSE file.

Community

python-unitypack is a HearthSim project. All development happens on our IRC channel #hearthsim on Freenode.

Contributions are welcome. Make sure to read through the CONTRIBUTING.md first.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].