I've noticed that the logic for playing audio for each letter read out does not function with the other draw orders. For random, it only plays audio if the letter that just appeared is further right than the others. For right-to-left, none of them play. It looks like it's because UpdateMesh implicitly assumes left-to-right when setting doPrintEventAfter. I'm a bit hesitant to mess around with this code because it's setting a lot of member variables unrelated to the audio. Is there a fix in the works for this?
Relevant code:
//just to get timing info for events //these are used to that positional data is updated before events are called doPrintEventAfter = false; doEventAfter = false; if (reading) { float divideAnimAmount = CurrentTextInfo.drawAnimData.animTime == 0f ? 0.0000001f : CurrentTextInfo.drawAnimData.animTime; //so it doesn't get NaN'd float myAnimPos = (myTime - CurrentTextInfo.readTime) / divideAnimAmount; // on a range between 0-1 on the curve, the position of the animation if(myAnimPos > 0f && i > latestNumber){ doEventAfter = true; //if(!playedSoundThisFrame){ // playedSoundThisFrame = true; //ignore 0-width space, as it's used for tacked-on events if(hyphenedText[i] != '\u200B') { //} doPrintEventAfter = true; if(hyphenedText[i] != ' ' && hyphenedText[i] != '\n') { lowestDrawnPosition = Mathf.Min(lowestDrawnPosition, CurrentTextInfo.pos.y); lowestDrawnPositionRaw = Mathf.Min(lowestDrawnPosition, CurrentTextInfo.pos.y + offset.y); //Debug.Log(CurrentTextInfo.pos.y); furthestDrawnPosition = Mathf.Max(furthestDrawnPosition, CurrentTextInfo.RelativeAdvance(characterSpacing).x + offset.x + TextBounds_rightOffset.x); } } latestNumber = Mathf.Max(latestNumber, i); //find latest number to start from next frame /* if(info[i].pos.y + info[i].size + lowestLineOffset.y < 0f && //this number is below the limit info[i].pos.y + info[i].size + lowestLineOffset.y > highestVisiblePoint){ //is this number taller than the current tallest number? highestVisiblePoint = info[i].pos.y + info[i].size + lowestLineOffset.y; tallestVisibleIndex = i; } */ } }else if(!Application.isPlaying || VerticalLimitStored == 0f || !(verticalLimitMode == VerticalLimitMode.AutoPause || verticalLimitMode == VerticalLimitMode.AutoPauseFull)){ //don't do this for autopauses latestNumber = hyphenedText.Length-1; lowestDrawnPosition = info[latestNumber].pos.y; //assume the final letter lowestDrawnPositionRaw = info[latestNumber].pos.y + offset.y; furthestDrawnPosition = rawBottomRightTextBounds.x; //this causes some sizes to be incorrect in-editor, but should be fine as text reads out } RecalculateTextBounds(); if(doEventAfter) { DoEvent(i); //do every event up to this integer } if(doPrintEventAfter) { PlaySound(i); //only play one sound this frame, from the first letter drawn this frame if(onPrintEvent != null) onPrintEvent.Invoke(); if(OnPrintEvent != null) OnPrintEvent(); }
Thanks!