mafaca / UtinyRipper

GUI and API library to work with Engine assets, serialized and bundle files
MIT License
2.81k stars 432 forks source link

Export Tree Component #896

Open ZhaoXiangXML opened 3 years ago

ZhaoXiangXML commented 3 years ago

I'm trying to add an exporter for the Tree Component of Unity 2019.4.0f1

The source code from Visual Studio looks like this:

using UnityEngine.Bindings;

namespace UnityEngine
{
    //
    // Summary:
    //     Tree Component for the tree creator.
    [NativeHeader("Modules/Terrain/Public/Tree.h")]
    public sealed class Tree : Component
    {
        public Tree();

        //
        // Summary:
        //     Data asociated to the Tree.
        [NativeProperty("TreeData")]
        public ScriptableObject data { get; set; }
        //
        // Summary:
        //     Tells if there is wind data exported from SpeedTree are saved on this component.
        public bool hasSpeedTreeWind { get; }
    }
}

Parts of the Tree.prefab looks like this:

Tree:
  m_ObjectHideFlags: 0
  m_CorrespondingSourceObject: {fileID: 0}
  m_PrefabInstance: {fileID: 0}
  m_PrefabAsset: {fileID: 0}
  m_GameObject: {fileID: 4317327013210407872}
  m_SpeedTreeWindAsset: {fileID: 0}
  m_TreeData: {fileID: -2861458992197153078}

MonoBehaviour:
  m_ObjectHideFlags: 0
  m_CorrespondingSourceObject: {fileID: 0}
  m_PrefabInstance: {fileID: 0}
  m_PrefabAsset: {fileID: 0}
  m_GameObject: {fileID: 0}
  m_Enabled: 1
  m_EditorHideFlags: 0
  m_Script: {fileID: 12106, guid: 0000000000000000e000000000000000, type: 0}
  m_Name: Tree Data
  m_EditorClassIdentifier: 
  _uniqueID: 5
  materialHash: 31d6cfe0d16ae931b73c59d7e0c089c0-583008256
  root:

And the hex of this Tree component in Windows standard alone build looks like this:

00 00 00 00 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

The size is 24 which could only contain one PPtr property (instead of two), and is zero. So I can't find out the TreeData property from it. According to Asset Studio, the solo property is m_SpeedTreeWindAsset.

Another problem is the MonoBehaviour with name Tree Data has failed to export its script and properties.

To summary up, the issues are I can't export the TreeData property of the Tree Component, nor the Tree Data it self.

Please help me with this if possible.

Thanks.

ds5678 commented 2 years ago

This will be part of AssetRipper 0.2.0.0.