| 
 | 
 
馬上註冊,結交更多好友,享用更多功能,讓你輕鬆玩轉社區。
您需要 登錄 才可以下載或查看,沒有帳號?立即註冊  
 
x
 
Fungus預設使用UGUI中的Text, 想使用TextMesh Pro中的TMP_Text取代的話, 需要一些更改. 
 
1. 先找到其中一個使用了UGUI的Text的地方, 我在SayDialog.cs裡開始, 對著Text右鍵, 按Find References. 
  
 
2. 接著會顯示出所有使用了UGUI的Text的地方, 除了TextMesh Pro的Script, 所有Fungus的Text我們都將把他轉成TMP_Text. 
  
 
3. 改成TMP_Text而出現紅色標示, 對著TMP_Text右鍵, 按Resolve->using TMPro; 
  
 
4. 把所有Fungus Script的Text都改成TMP_Text後, 我們還需要到\Fungus\Resources\Prefabs\中把使用了UGUI的Text的Prefabs改成TMP_Text. 當中包括: 
SayDialog 
    NameText 
    StoryText 
MenuDialog 
    Text 
  
 
5.把Text Remove後把TextMeshPro - Text (UI)加上. 
  
 
6. 上方Rect Transform數值變了, 可以按Revert to Prefab回復, 但Text Mesh Pro UGUI就得重新手動設定. 
  
 
7. 還有記得把與原本UGUI的Text有聯繫的Script(如Say Dialog)與新的Text Mesh Pro UGUI聯繫上, 最後按上方的Apply以儲存修改好的Prefab. 
  
 
  
如果始終不會改Script, 而又只需在很少地方使用TextMesh Pro的話, 可以只改Prefab不改Script, 或許會神奇地生效! 
(Say Dialog測試可用此方法) 
主要原因是Fungus當中包含了少量簡單粗暴的CODE, 會在找不到原有Text的情況下, 查找其他含有"text"Property的component. 
-             // Try to find any component with a text property
 
 -             if (textUI == null && inputField == null && textMesh == null)
 
 -             {
 
 -                 var allcomponents = go.GetComponents<Component>();
 
 -                 for (int i = 0; i < allcomponents.Length; i++)
 
 -                 {
 
 -                     var c = allcomponents[i];
 
 -                     textProperty = c.GetType().GetProperty("text");
 
 -                     if (textProperty != null)
 
 -                     {
 
 -                         textComponent = c;
 
 -                         break;
 
 -                     }
 
 -                 }
 
 -             }
 
  複製代碼 
 
 
 |   
 
 
 
 |