Add UniTask dependency, and wait 1 frame before showing subtitle to ensure UI positioned correctly (avoids "flipping" effect when initially shown)
This commit is contained in:
parent
a90a9adc28
commit
0071110c51
|
@ -4,7 +4,8 @@
|
|||
"references": [
|
||||
"Unity.TextMeshPro",
|
||||
"TriInspector",
|
||||
"com.leantween"
|
||||
"com.leantween",
|
||||
"UniTask"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
@ -192,6 +193,9 @@ namespace R0bbie.VRSubtitles
|
|||
// Update speaking character name and avatar displayed
|
||||
UpdateCharacterDisplay(_characterDataRef);
|
||||
|
||||
// Start subtitle position and rotation where we want it, before showing
|
||||
SnapToFollowTarget();
|
||||
|
||||
// Set new active line to show
|
||||
activeLine = _text;
|
||||
|
||||
|
@ -202,8 +206,6 @@ namespace R0bbie.VRSubtitles
|
|||
// If we want to have this line not follow the character position
|
||||
dontFollowCharacter = _dontAttachSubToCharacter;
|
||||
|
||||
SnapToFollowTarget();
|
||||
|
||||
// Allow continue after audio finished playing
|
||||
Invoke(nameof(LineAudioFinished), _audioDuration);
|
||||
}
|
||||
|
@ -386,9 +388,6 @@ namespace R0bbie.VRSubtitles
|
|||
/// </summary>
|
||||
public void SnapToFollowTarget()
|
||||
{
|
||||
if (!panelActive)
|
||||
return;
|
||||
|
||||
CalculateTargetPositions();
|
||||
|
||||
// Immediately update both parent and child objects pos to target
|
||||
|
@ -465,6 +464,9 @@ namespace R0bbie.VRSubtitles
|
|||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Once conditions have been met to end this subtitle line
|
||||
/// </summary>
|
||||
void LineContinued()
|
||||
{
|
||||
// Play continued sound if set
|
||||
|
@ -482,11 +484,14 @@ namespace R0bbie.VRSubtitles
|
|||
/// <summary>
|
||||
/// Activate and show panel
|
||||
/// </summary>
|
||||
void ShowPanel()
|
||||
async UniTaskVoid ShowPanel()
|
||||
{
|
||||
// If panel is being shown, and wasn't already showing
|
||||
|
||||
// Add a slight delay for playing sound in case toggled quickly off and on again
|
||||
// Wait a frame to ensure subtitle UI correctly positioned before showing
|
||||
await UniTask.DelayFrame(2);
|
||||
|
||||
// Add a slight delay for playing sound again, in case toggled quickly off and on again
|
||||
if (!panelActive && (Time.timeSinceLevelLoad > (timeLastHidden + 0.5f)))
|
||||
{
|
||||
// Play popup sound event
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "com.r0bbie.vrsubtitles",
|
||||
"displayName": "VR Subtitles",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.1",
|
||||
"unity": "2021.3",
|
||||
"author": {
|
||||
"name" : "Robbie Cargill",
|
||||
|
@ -15,6 +15,7 @@
|
|||
],
|
||||
"dependencies": {
|
||||
"com.codewriter.triinspector": "1.13.2",
|
||||
"com.cysharp.unitask": "2.5.0",
|
||||
"com.oss.leantween": "2.50.4",
|
||||
"com.unity.textmeshpro": "3.0.6"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue