跳到主要內容

發表文章

目前顯示的是 11月, 2025的文章

處理 Material doesn't have _Stencil property 警告

 游戲運行時出現下列錯誤,查了老半天是 Particle System 放在 Scrollview 就會一直刷警告 material 用的是 Legancy Shaders/Particles/Additive , 後來安裝了支持的插件,如下 https://github.com/mob-sakai/ParticleEffectForUGUI?tab=readme-ov-file#install-via-upm-with-package-manager-ui 改選擇  UI/Additive ,這樣既沒有警告也支持 clip 效果了

使用 windbg 查找 unity crash

 1、首先下載 WinDbg   2、開啓 WinDbg  接著選擇 File / Open dump file  3、將dump檔案指定進去,接著按 open unity crash 路徑如下:      c:\Users\JOKER0~1\AppData\Local\Temp\Unity\Editor\Crashes\ 4、 接著打開 View / Command WinDbg 畫面如下 這時候輸入 symbol link 參考 unity 官網 (https://docs.unity3d.com/cn/2021.2/Manual/WindowsDebugging.html) 指令如下: .sympath+ SRV*c:\symbols-cache*http://symbolserver.unity3d.com/ 接著在輸入分析指令 !analyze -v 如下圖 看到最後輸出内容如下: 可以看到内容包含下面 STACK_TEXT:   00000070`1355f360 00007ffa`26980c1c     : 0000025c`ecabf1b8 00007ffa`2704a398 00007ffa`26f83bdb 00007ffa`26f83bdb : KERNELBASE! RaiseException +0x8a 00000070`1355f460 00007ffa`2696c822     : 00007ffa`26f867c8 0000025a`e5a5de20 00000000`00000000 00000070`1355f9e8 : mono_2_0_bdwgc! mono_log_write_logfile +0x14c (Inline Function) --------`--------     : --------`-------- --------`-------- --------`-------- --------`-------- : mono_2_0_bdwgc! monoeg_g_logstr +0xbd 00000070`1355f520 ...

其他/Newton 與 Utf8Json 序列化差異

 case1、 private int displayMode = 0; public int DisplayMode { set => _displayMode = value; get => _displayMode; } case2、 private string overEntityId = ""; public string OverEntityId { get { return overEntityId; } } 兩者在 Newtonsoft.Jons、Utf8Jon 的差異 在序列化過程中,這兩種寫法有重要區別: 序列化行為差異: 1.  Newtonsoft.Json (JsonConvert) / 方式1: 會序列化 _displayMode 私有字段(預設行為) private int _displayMode = 0 ; public int DisplayMode { set => _displayMode = value ; get => _displayMode ; } // 方式2: 會序列化 overEntityId 私有字段 private string overEntityId = "" ; public string OverEntityId { get { return overEntityId ; } } 預設都會序列化私有字段 兩種寫法在 Newtonsoft.Json 中 沒有太大區別 2.  Utf8Json // 方式1: ❌ 無法序列化(沒有 backing field) private int _displayMode = 0 ; public int DisplayMode { set => _displayMode = value ; get => _displayMode ; } // 方式2: ❌ 無法序列化(只有 getter,沒有 setter) private string overEntityId = "" ; public string OverEntityId { get { return overEntityI...