2021年7月31日 星期六

Unity Universal Render Pipeline (URP) 增加 Frames per second (FPS)

 2021.07.31 Unity 輸出到手機常有卡頓的情形,經過 Profiler 發現 FPS 過低,以下是一些可以改進的選項,不過這都是效能跟效果之間的取捨。

不用動的物件設定靜態 (Static),以及盡量使用 Level of Detail (LOD) 。

在 Camera 以下選項視需要關閉:

Post Processing
Render Shadows
Opaque Texture Off
Depth Texture Off

URP 設定檔 UniversalPipelineAsset 以下選項視需要關閉:

Opaque Texture Off
Depth Texture Off
Cast Shadows
Additional Lights Diabled 

2021年7月4日 星期日

Unity GoogleMobileAds-v5.4.0 發生 "You are trying to create a MonoBehaviour using the 'new' keyword" 錯誤

2021.07.04 GoogleMobileAds.Unity.RewardingAdBaseClient:CreateButtonBehavior() 發生 " You are trying to create a MonoBehaviour using the 'new' keyword.  This is not allowed.  MonoBehaviours can only be added using AddComponent(). Alternatively, your script can inherit from ScriptableObject or no base class at all
UnityEngine.MonoBehaviour:.ctor()
ButtonBehaviour:.ctor() " 錯誤,雖然不會影響結果但是改一改總是好的。

解決方法為將 RewardingAdBaseClient 內的

    buttonBehaviour = new ButtonBehaviour(); 

改為:

     GameObject ob=new GameObject();
     ob.AddComponent<ButtonBehaviour>();
     buttonBehaviour = ob.GetComponent<ButtonBehaviour>();

即可。