代码拉取完成,页面将自动刷新
"""
This example shows how to write a custom MonoBehaviour class.
The script is for a game that generates its encryption key based on a specific image.
This image is linked to by a MonoBheaviour called "ScriptableTexture2D".
It is linked to by a pointer after the default MonoBehaviour structure.
This intel was acquired from the assembly of the game.
Unfortunately, the asset doesn't have a type-tree, so the default MonoBehaviour class can't find the pointer.
So a custom MonoBehaviour class is required to get the pointer comfortably.
Doing so is simple, as seen in the following code.
"""
import os
import UnityPy
from UnityPy.classes import MonoBehaviour, PPtr
class ScriptableTexture2D(MonoBehaviour):
def __init__(self, reader):
# calls the default MonoBehaviour init
super().__init__(reader=reader)
# here goes the implementation of the extra data
self.texture = PPtr(reader)
# set the path for the target file
root = os.path.dirname(os.path.realpath(__file__))
fp = os.path.join(root,"data.unity3d")
env = UnityPy.load(fp)
# find the correct asset
for obj in env.objects:
if obj.type == "MonoBehaviour":
data = obj.read()
if data.name == "ScriptableTexture2D":
# correct obj found
# lets read it with the custom class
st = ScriptableTexture2D(obj)
# read the linked image and save it
tex = st.texture.read()
print(st.texture.read().name)
#tex.image.save(os.path.join(root, f"{tex.name}.png"))
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。