如何让unity总是生成typetree

本文介绍如何使用 lldb-p 工具附加到 Unity 进程,并设置断点进行调试的具体步骤。通过查找特定的汇编指令行并设置断点命令,可以帮助开发者更有效地定位和解决问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

__text:000000010187CF12                 or      eax, r14d <--这里下断点加上断点命令 register write eax 0x140  


使用lldb -p  pid 附加上unity进程, 然后找上面这行,加上断点命令,就可以了. 以下内容仅用作查找上面这一行的上下文使用



text:000000010187CE6F loc_10187CE6F:                          ; CODE XREF: __text:000000010187CD4Bj
__text:000000010187CE6F                 mov     edi, [rbp-0BF4h]
__text:000000010187CE75                 mov     esi, 1
__text:000000010187CE7A                 xor     edx, edx
__text:000000010187CE7C                 xor     ecx, ecx
__text:000000010187CE7E                 call    __ZN12SpritePacker25RebuildAtlasCacheIfNeededE19BuildTargetPlatformbNS_21SpritePackerExecutionEb ; SpritePacker::RebuildAtlasCacheIfNeeded(BuildTargetPlatform,bool,SpritePacker::SpritePackerExecution,bool)
__text:000000010187CE83                 test    al, al
__text:000000010187CE85                 jz      loc_10187D017
__text:000000010187CE8B                 call    __Z15GetScriptMapperv ; GetScriptMapper(void)
__text:000000010187CE90                 mov     rbx, rax
__text:000000010187CE93                 call    __Z17GetPlayerSettingsv ; GetPlayerSettings(void)
__text:000000010187CE98                 mov     al, [rax+384h]
__text:000000010187CE9E                 mov     [rbx+3Ch], al
__text:000000010187CEA1                 mov     eax, [rbp-1024h]
__text:000000010187CEA7                 and     eax, 10h
__text:000000010187CEAA                 mov     [rbp-1008h], eax
__text:000000010187CEB0                 shr     eax, 4
__text:000000010187CEB3                 mov     r15d, [rbp-0BF4h]
__text:000000010187CEBA                 mov     [rbp-1048h], r15d
__text:000000010187CEC1                 and     r15d, 0FFFFFFFEh
__text:000000010187CEC5                 cmp     r15d, 6
__text:000000010187CEC9                 setz    r12b
__text:000000010187CECD                 or      r12b, al
__text:000000010187CED0                 mov     r13b, 1
__text:000000010187CED3                 jnz     short loc_10187CEE3
__text:000000010187CED5                 mov     rax, [rbp-1038h]
__text:000000010187CEDC                 cmp     dword ptr [rax], 0
__text:000000010187CEDF                 setnz   r13b
__text:000000010187CEE3
__text:000000010187CEE3 loc_10187CEE3:                          ; CODE XREF: __text:000000010187CED3j
__text:000000010187CEE3                 mov     edi, [rbp-1048h]
__text:000000010187CEE9                 call    __Z25CalculateEndianessOptions19BuildTargetPlatform ; CalculateEndianessOptions(BuildTargetPlatform)
__text:000000010187CEEE                 mov     r14d, eax
__text:000000010187CEF1                 mov     edi, [rbp-1048h]
__text:000000010187CEF7                 call    __Z34DoesTargetPlatformSupportTypeTrees19BuildTargetPlatform ; DoesTargetPlatformSupportTypeTrees(BuildTargetPlatform)
__text:000000010187CEFC                 test    al, al
__text:000000010187CEFE                 mov     eax, 140h
__text:000000010187CF03                 mov     ecx, 4000140h    
__text:000000010187CF08                 cmovz   eax, ecx
__text:000000010187CF0B                 test    r12b, 1
__text:000000010187CF0F                 cmovz   eax, ecx
__text:000000010187CF12                 or      eax, r14d <--这里下断点加上断点命令 register write eax 0x140
__text:000000010187CF15                 mov     ebx, eax
__text:000000010187CF17                 or      ebx, 80000h
__text:000000010187CF1D                 test    r13b, r13b
__text:000000010187CF20                 cmovnz  ebx, eax
__text:000000010187CF23                 call    __Z17GetPlayerSettingsv ; GetPlayerSettings(void)
__text:000000010187CF28                 cmp     byte ptr [rax+15Bh], 0
__text:000000010187CF2F                 jz      short loc_10187CF37
__text:000000010187CF31                 or      ebx, 400000h
__text:000000010187CF37
__text:000000010187CF37 loc_10187CF37:                          ; CODE XREF: __text:000000010187CF2Fj
__text:000000010187CF37                 cmp     r15d, 6
__text:000000010187CF3B                 jnz     short loc_10187CF79
__text:000000010187CF3D                 mov     eax, ebx
__text:000000010187CF3F                 and     eax, 80000h
__text:000000010187CF44                 jz      short loc_10187CF79
__text:000000010187CF46                 mov     qword ptr [rsp+8], 0
__text:000000010187CF4F                 mov     dword ptr [rsp], 0
__text:000000010187CF56                 lea     rdi, aFlagsKbuildres ; "!((flags & kBuildResourceImage) && IsWe"...
__text:000000010187CF5D                 lea     rdx, asc_10342C675 ; "/Users/builduser/buildslave/unity/build"...
__text:000000010187CF64                 xor     esi, esi
__text:000000010187CF66                 mov     ecx, 5E6h
__text:000000010187CF6B                 mov     r8d, 2
__text:000000010187CF71                 xor     r9d, r9d
__text:000000010187CF74                 call    __Z17DebugStringToFilePKciS0_iiiiPFvRK11CppLogEntryE ; DebugStringToFile(char  const*,int,char  const*,int,int,int,int,void (*)(CppLogEntry  const&))
__text:000000010187CF79
__text:000000010187CF79 loc_10187CF79:                          ; CODE XREF: __text:000000010187CF3Bj
__text:000000010187CF79                                         ; __text:000000010187CF44j
__text:000000010187CF79                 mov     rax, [rbp+18h]
__text:000000010187CF7D                 mov     ecx, ebx
__text:000000010187CF7F                 or      ecx, 40000000h
__text:000000010187CF85                 test    ebx, 4000000h
__text:000000010187CF8B                 cmovz   ecx, ebx
__text:000000010187CF8E                 cmp     dword ptr [rbp-1008h], 0
__text:000000010187CF95                 cmovz   ecx, ebx
__text:000000010187CF98                 mov     [rbp-1064h], ecx
__text:000000010187CF9E                 mov     rsi, [rbp-1020h]
__text:000000010187CFA5                 mov     rcx, [rsi+8]
__text:000000010187CFA9                 sub     rcx, [rsi]
__text:000000010187CFAC                 shr     rcx, 4
__text:000000010187CFB0                 mov     [rbp-1050h], rcx
__text:000000010187CFB7                 movzx   ecx, r13b
__text:000000010187CFBB                 mov     [rbp-1058h], rcx
__text:000000010187CFC2                 movss   xmm0, dword ptr [rax+4]
__text:000000010187CFC7                 subss   xmm0, dword ptr [rax]
__text:000000010187CFCB                 movss   dword ptr [rbp-1010h], xmm0
__text:000000010187CFD3                 lea     rdi, [rbp-0CB8h]
__text:000000010187CFDA                 call    __ZNSt6vectorI8UnityStrSaIS0_EEC2ERKS2_ ; std::vector<UnityStr,std::allocator<UnityStr>>::vector(std::vector<UnityStr,std::allocator<UnityStr>> const&)
__text:000000010187CFDF                 mov     [rbp-1071h], r13b
__text:000000010187CFE6                 mov     [rbp-1072h], r12b
__text:000000010187CFED                 mov     r14, [rbp-0CB8h]
__text:000000010187CFF4                 mov     r15, [rbp-0CB0h]
__text:000000010187CFFB                 cmp     r15, r14
__text:000000010187CFFE                 jz      loc_10187D1A1
__text:000000010187D004                 xor     r13d, r13d
__text:000000010187D007                 xor     r12d, r12d
__text:000000010187D00A                 jmp     loc_10187D0F0


Unity中使用柏林噪声(Perlin Noise)生成植物群落是一种常用的艺术化地形或元素分布方式,它能模拟自然随机性和多样性。以下是简单的步骤: 1. **导入所需库**:首先,在Unity项目中需要安装或编写一个插件来支持柏林噪声算法,例如Unity内置的Procedural Content Generation (PCG) 或者第三方的NoiseLib等。 2. **创建噪声纹理**:使用柏林噪声函数(如Unity的Noise3D函数)生成一张二维或三维的噪声图。可以调整参数(如频率、振幅)来控制细节程度。 ```csharp public static float[,] PerlinNoise(int width, int height) { float[, ] noiseMap = new float[width, height]; for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { noiseMap[x, y] = Mathf.PerlinNoise(x / (float)width, y / (float)height); } } return noiseMap; } ``` 3. **植物分布**:基于噪声图,将较高的值对应于密集的植被区域,较低的值对应稀疏地区。可以设定阈值,比如噪声值大于某个数值的地方种植高大的树木,而小于另一个数值的地方种植低矮的草丛。 ```csharp float noiseThreshold = 0.5f; for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { if (noiseMap[i, j] > noiseThreshold) { PlantPlantAtPoint(i, j, "Tree"); } else if (noiseMap[i, j] < (1 - noiseThreshold)) { PlantPlantAtPoint(i, j, "Grass"); } } } private void PlantPlantAtPoint(int x, int y, string type) { GameObject plant = Instantiate(plantPrefab, new Vector3(x, noiseMap[x, y] * maxHeight, y), Quaternion.identity); plant.GetComponent<Renderer>().material.color = GetRandomColorForPlantType(type); } ``` 4. **美化效果**:最后,你可以进一步定制每个植物的外观、大小以及生长状态,或者给它们添加动画效果,使其看起来更真实。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值