Page 1 of 1

Optimization Tips for the Dialogue System

Posted: Wed Nov 07, 2018 7:56 am
by Tony Li
This post will collect optimization tips for using the Dialogue System for Unity. Some of them are Dialogue System-specific; others are general Unity optimization tips. I'll add more tips as they come in.

UI
If you're using Unity UI (including TextMesh Pro), see this article: Some of the best optimization tips for Unity UI, including:
  • Divide up your canvases
  • Optimal use of Graphic Raycaster (i.e., turn off Raycast Target everywhere possible)
  • Avoid Layout Groups and Content Size Fitter
Many of the UI prefabs that ship with the Dialogue System use layout groups fairly liberally. They're built for flexibility over performance. When you start customizing them, you can remove layout groups that you don't need and turn off raycast targets.

In version 2.0.7+, Dialogue System UI panels can use Animator or Animation components. Unless your panel needs to update its animation every frame (such as a wiggle effect), use an Animation component.

If you're using the default legacy Unity GUI display with Selector or ProximitySelector, update to version 2.0.6+, which initializes the font and GUI style on start to prevent a possible stutter the first time a selection message is displayed. Regardless of which version you're using, assign a GUI Skin so the component doesn't need to take time to create one at runtime. If you're using Unity UI (e.g., Selector Use Standard UI Elements), you can disregard this and instead follow the general Unity UI optimization recommendations above.

Triggers and Starting Conversations
Consider unticking the Selector/Proximity Selector's Broadcast To Children checkbox. This will speed up "On Use" because it won't need to traverse the usable's entire hierarchy. However, only the usable object, and not children, will receive "On Use" messages in this case.

If you know that your conversation will have at least one valid dialogue entry, inspect the Dialogue System Trigger and UNtick Skip If No Valid Entries. This will half the conversation setup time.

If your character's barks don't have Conditions, tick the Dialogue System Trigger's Cache Bark Lines checkbox.

Be careful with your own custom hooks. Methods that you assign to DialogueManager.isDialogueEntryValid or getInputButtonDown, or custom OnConversationXXX() methods, or methods assigned to Dialogue System Events, should be optimized so the Dialogue System isn't left waiting for them to execute.

Saving & Loading
Only use SimStatus if you need it. It adds about 20 bytes of memory to each dialogue entry. In most cases this is negligible, but it can add up if you have an enormous amount of dialogue.