Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

DrawOrders other than left to right do not play audio clips properly

A topic by bread created Apr 07, 2020 Views: 226 Replies: 5
Viewing posts 1 to 6
(2 edits)

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!

Developer (2 edits)

Hi!


Found this myself last night and I was working on it today. Already got it fixed for Right To Left and Reverse LTR, but RTL One Word at a Time is giving me issues and might take a bit longer... hopefully it'll be fixed, soon. Nice catch with Random though, hopefully I can get this fixed.

awesome. i'll be on the lookout for it in the next update!

Developer

Just letting you know, got this fixed for the next update!

Awesome! My writer will be very happy to hear that. Hopefully it will be easy to cherry pick

Just pulled in the change and it looks good! Thank you!