Commit 956881583bd272afb467a10334afa317ac136588
1 parent
39372c3a
Exists in
master
and in
6 other branches
Otimization
Showing
5 changed files
with
142 additions
and
121 deletions
Show diff stats
Assets/Scenes/Main.unity
... | ... | @@ -5756,7 +5756,7 @@ GameObject: |
5756 | 5756 | m_Icon: {fileID: 0} |
5757 | 5757 | m_NavMeshLayer: 0 |
5758 | 5758 | m_StaticEditorFlags: 0 |
5759 | - m_IsActive: 1 | |
5759 | + m_IsActive: 0 | |
5760 | 5760 | --- !u!224 &970584909 |
5761 | 5761 | RectTransform: |
5762 | 5762 | m_ObjectHideFlags: 0 |
... | ... | @@ -6697,7 +6697,7 @@ MonoBehaviour: |
6697 | 6697 | m_HorizontalOverflow: 0 |
6698 | 6698 | m_VerticalOverflow: 0 |
6699 | 6699 | m_LineSpacing: 1 |
6700 | - m_Text: Version 3.0.34 | |
6700 | + m_Text: Version 3.0.36 | |
6701 | 6701 | --- !u!222 &1071047506 |
6702 | 6702 | CanvasRenderer: |
6703 | 6703 | m_ObjectHideFlags: 0 |
... | ... | @@ -13955,7 +13955,7 @@ GameObject: |
13955 | 13955 | m_Icon: {fileID: 0} |
13956 | 13956 | m_NavMeshLayer: 0 |
13957 | 13957 | m_StaticEditorFlags: 0 |
13958 | - m_IsActive: 1 | |
13958 | + m_IsActive: 0 | |
13959 | 13959 | --- !u!224 &2099411279 |
13960 | 13960 | RectTransform: |
13961 | 13961 | m_ObjectHideFlags: 0 |
... | ... | @@ -13970,10 +13970,10 @@ RectTransform: |
13970 | 13970 | m_Children: [] |
13971 | 13971 | m_Father: {fileID: 702185295} |
13972 | 13972 | m_RootOrder: 2 |
13973 | - m_AnchorMin: {x: 0, y: 0} | |
13974 | - m_AnchorMax: {x: 0, y: 0} | |
13975 | - m_AnchoredPosition: {x: 0, y: 0} | |
13976 | - m_SizeDelta: {x: 0, y: 0} | |
13973 | + m_AnchorMin: {x: 0, y: 1} | |
13974 | + m_AnchorMax: {x: 0, y: 1} | |
13975 | + m_AnchoredPosition: {x: 260.71997, y: -76.62858} | |
13976 | + m_SizeDelta: {x: 106, y: 106} | |
13977 | 13977 | m_Pivot: {x: 0.5, y: 0.5} |
13978 | 13978 | --- !u!114 &2099411280 |
13979 | 13979 | MonoBehaviour: | ... | ... |
... | ... | @@ -0,0 +1,20 @@ |
1 | +using System; | |
2 | +using System.Collections.Generic; | |
3 | +using System.Linq; | |
4 | +using System.Text; | |
5 | + | |
6 | +namespace LAViD.VLibras.Generic | |
7 | +{ | |
8 | + class Node | |
9 | + { | |
10 | + private bool end = false; | |
11 | + private Node[] children = null; | |
12 | + } | |
13 | + | |
14 | + class Trie | |
15 | + { | |
16 | + private Node root; | |
17 | + | |
18 | + // public Trie() | |
19 | + } | |
20 | +} | ... | ... |
... | ... | @@ -0,0 +1,12 @@ |
1 | +fileFormatVersion: 2 | |
2 | +guid: 3238f46fe9379b2469349a4bce058b65 | |
3 | +timeCreated: 1476385070 | |
4 | +licenseType: Pro | |
5 | +MonoImporter: | |
6 | + serializedVersion: 2 | |
7 | + defaultReferences: [] | |
8 | + executionOrder: 0 | |
9 | + icon: {instanceID: 0} | |
10 | + userData: | |
11 | + assetBundleName: | |
12 | + assetBundleVariant: | ... | ... |
Assets/Scripts/Player Manager/GenericPlayerManager.cs
... | ... | @@ -187,8 +187,8 @@ public abstract class GenericPlayerManager : MonoBehaviour { |
187 | 187 | /* Para animações */ |
188 | 188 | public void stopAnimations() |
189 | 189 | { |
190 | - StopCoroutine("AnimationsHandler"); | |
191 | - this.randomAnimations.unlockFor("AnimationsHandler"); | |
190 | + StopCoroutine("AnimationsWatcher"); | |
191 | + this.randomAnimations.unlockFor("AnimationsWatcher"); | |
192 | 192 | this.subtitles.setText(""); |
193 | 193 | |
194 | 194 | lock (this.animQueue) { this.animQueue.Clear(); } |
... | ... | @@ -472,13 +472,7 @@ public abstract class GenericPlayerManager : MonoBehaviour { |
472 | 472 | string lastAnimationSubtitle = ""; |
473 | 473 | bool spelled = false; |
474 | 474 | |
475 | - if ( ! this.playing) | |
476 | - StartCoroutine("AnimationsHandler"); | |
477 | - | |
478 | - String[] stringPos = gloss.Split(' '); | |
479 | - | |
480 | 475 | Queue<ToPlay> toPlayQueue = new Queue<ToPlay>(); |
481 | - int wordsCount = 0; | |
482 | 476 | toPlayQueue.Enqueue(new ToPlay(Subtitle.TYPE_NONE, DEFAULT_ANIMATION, "", this)); |
483 | 477 | |
484 | 478 | /*WWW checkConnectionRequest = getCheckConnectionRequest(); |
... | ... | @@ -497,9 +491,9 @@ public abstract class GenericPlayerManager : MonoBehaviour { |
497 | 491 | bool connected = true; |
498 | 492 | bool playingStarted = false; |
499 | 493 | |
494 | + String[] stringPos = gloss.Split(' '); | |
500 | 495 | foreach (string aniName in stringPos) |
501 | 496 | { |
502 | - wordsCount++; | |
503 | 497 | if (String.IsNullOrEmpty(aniName)) continue; |
504 | 498 | |
505 | 499 | bool nonexistent = nonexistentAssetBundles.Contains(aniName); |
... | ... | @@ -508,41 +502,46 @@ public abstract class GenericPlayerManager : MonoBehaviour { |
508 | 502 | if ( ! nonexistent && ! loaded && connected) |
509 | 503 | { |
510 | 504 | WWW bundleRequest = loadAssetBundle(aniName); |
511 | - yield return WaitForResponse(bundleRequest); | |
512 | - | |
513 | - PlayerLogger.Log("GPM", "L", "Bundle request done (" + aniName + ")."); | |
514 | 505 | |
515 | - if (bundleRequest.isDone && bundleRequest.error == null) | |
506 | + if (bundleRequest != null) | |
516 | 507 | { |
517 | - AssetBundle bundle = bundleRequest.assetBundle; | |
508 | + yield return WaitForResponse(bundleRequest); | |
509 | + | |
510 | + PlayerLogger.Log("GPM", "L", "Bundle request done (" + aniName + ")."); | |
518 | 511 | |
519 | - if (bundle != null && !String.IsNullOrEmpty(bundle.mainAsset.name)) | |
512 | + if (bundleRequest.isDone && bundleRequest.error == null) | |
520 | 513 | { |
521 | - AnimationClip aniClip = bundle.mainAsset as AnimationClip; | |
522 | - bundle.Unload(false); | |
514 | + AssetBundle bundle = bundleRequest.assetBundle; | |
523 | 515 | |
524 | - if (aniClip) | |
516 | + if (bundle != null && !String.IsNullOrEmpty(bundle.mainAsset.name)) | |
525 | 517 | { |
526 | - COMPONENT_ANIMATION.AddClip(aniClip, aniName); | |
527 | - if (playingStarted) yield return new WaitForEndOfFrame(); | |
518 | + AnimationClip aniClip = bundle.mainAsset as AnimationClip; | |
519 | + bundle.Unload(false); | |
528 | 520 | |
529 | - loadedAssetBundles.Add(aniName); | |
530 | - loaded = true; | |
521 | + if (aniClip) | |
522 | + { | |
523 | + COMPONENT_ANIMATION.AddClip(aniClip, aniName); | |
524 | + if (playingStarted) yield return new WaitForEndOfFrame(); | |
531 | 525 | |
532 | - PlayerLogger.Log("GPM", "L", "Bundle \"" + aniName + "\" loaded!"); | |
526 | + loadedAssetBundles.Add(aniName); | |
527 | + loaded = true; | |
528 | + | |
529 | + PlayerLogger.Log("GPM", "L", "Bundle \"" + aniName + "\" loaded!"); | |
530 | + } | |
531 | + else PlayerLogger.Log("GPM", "L", "Sign \"" + aniName + "\" wasn't loaded successfuly."); | |
533 | 532 | } |
534 | - else PlayerLogger.Log("GPM", "L", "Sign \"" + aniName + "\" wasn't loaded successfuly."); | |
535 | - } | |
536 | - else PlayerLogger.Log("GPM", "L", "Bundle \"" + aniName + "\" wasn't loaded successfuly."); | |
533 | + else PlayerLogger.Log("GPM", "L", "Bundle \"" + aniName + "\" wasn't loaded successfuly."); | |
537 | 534 | |
538 | - if ( ! loaded) nonexistentAssetBundles.Add(aniName); | |
539 | - } | |
540 | - else | |
541 | - { | |
542 | - PlayerLogger.Log("GPM", "L", "Connection error."); | |
543 | - onConnectionError(gloss, aniName); | |
535 | + if ( ! loaded) nonexistentAssetBundles.Add(aniName); | |
536 | + } | |
537 | + else | |
538 | + { | |
539 | + PlayerLogger.Log("GPM", "L", "Connection error."); | |
540 | + onConnectionError(gloss, aniName); | |
541 | + } | |
544 | 542 | } |
545 | - } | |
543 | + else PlayerLogger.Log("GPM", "L", "Animation of \"" + aniName + "\" do not exist."); | |
544 | + } | |
546 | 545 | |
547 | 546 | // Reproduz palavra |
548 | 547 | if (loaded) |
... | ... | @@ -588,7 +587,7 @@ public abstract class GenericPlayerManager : MonoBehaviour { |
588 | 587 | } |
589 | 588 | } |
590 | 589 | |
591 | - if (toPlayQueue.Count > 4 || wordsCount == stringPos.Length) { | |
590 | + if (toPlayQueue.Count > 4) { | |
592 | 591 | playingStarted = true; |
593 | 592 | |
594 | 593 | while (toPlayQueue.Count > 0) |
... | ... | @@ -601,6 +600,12 @@ public abstract class GenericPlayerManager : MonoBehaviour { |
601 | 600 | if (playingStarted) yield return new WaitForEndOfFrame(); |
602 | 601 | } |
603 | 602 | |
603 | + while (toPlayQueue.Count > 0) | |
604 | + { | |
605 | + toPlayQueue.Dequeue().play(this); | |
606 | + yield return new WaitForEndOfFrame(); | |
607 | + } | |
608 | + | |
604 | 609 | // Default |
605 | 610 | playAnimation(Subtitle.TYPE_NONE, DEFAULT_ANIMATION, ""); |
606 | 611 | |
... | ... | @@ -610,93 +615,75 @@ public abstract class GenericPlayerManager : MonoBehaviour { |
610 | 615 | } |
611 | 616 | |
612 | 617 | /* Sincroniza as legendas com as animações. */ |
613 | - IEnumerator AnimationsHandler() | |
618 | + IEnumerator AnimationsWatcher() | |
614 | 619 | { |
615 | - this.playing = true; | |
616 | - this.randomAnimations.lockFor("AnimationsHandler"); | |
617 | - onPlayingStateChange(); | |
618 | - | |
619 | - bool isNotEmpty = this.animQueue.Count > 0; | |
620 | - | |
621 | - // Animação anterior a atual | |
622 | - AnimationReference endedAnimation = null; | |
623 | - | |
624 | - // Enquanto estiver executando a corotina "Loader" | |
625 | - // ou existir animações na fila de reprodução | |
626 | - while (loading || isNotEmpty) | |
620 | + PlayerLogger.Log("GPM", "AW", "Starting."); | |
621 | + | |
622 | + while (true) | |
627 | 623 | { |
628 | - // Se não houver animações na fila, espera | |
629 | - if (isNotEmpty) | |
624 | + if (this.animQueue.Count > 0) | |
630 | 625 | { |
631 | - // Pega primeira animação | |
632 | - AnimationReference reference; | |
633 | - lock (this.animQueue) { reference = this.animQueue.Peek(); } | |
634 | - | |
635 | - // Se estiver sendo reproduzida | |
636 | - if (COMPONENT_ANIMATION.IsPlaying(reference.name)) | |
626 | + if (!this.playing) | |
637 | 627 | { |
638 | - this.subtitles.setText(reference.subtitle); | |
628 | + PlayerLogger.Log("GPM", "AW", "Playing."); | |
639 | 629 | |
640 | - // Animação seguinte | |
641 | - AnimationReference next = null; | |
642 | - lock (this.animQueue) | |
643 | - { | |
644 | - this.animationPlaying = this.animQueue.Dequeue(); | |
630 | + this.playing = true; | |
631 | + onPlayingStateChange(); | |
645 | 632 | |
646 | - if (this.animQueue.Count > 0) | |
647 | - next = this.animQueue.Peek(); | |
648 | - } | |
633 | + this.randomAnimations.lockFor("AnimationsWatcher"); | |
634 | + } | |
649 | 635 | |
636 | + // Gets first animation | |
637 | + AnimationReference reference = this.animQueue.Peek(); | |
638 | + | |
639 | + if (COMPONENT_ANIMATION.IsPlaying(reference.name)) | |
640 | + { | |
641 | + this.animationPlaying = this.animQueue.Dequeue(); | |
642 | + this.subtitles.setText(reference.subtitle); | |
643 | + | |
644 | + // Watches transition between current and next animation | |
650 | 645 | while (true) |
651 | 646 | { |
652 | - // Se a próxima animação estiver sendo reproduzida (no fade) | |
647 | + yield return new WaitForEndOfFrame(); | |
648 | + | |
649 | + // Gets next animation | |
650 | + AnimationReference next = this.animQueue.Count > 0 ? this.animQueue.Peek() : null; | |
651 | + | |
653 | 652 | if (next != null && COMPONENT_ANIMATION.IsPlaying(next.name)) |
654 | 653 | { |
655 | - // Se a animação anterior a atual não tiver acabado, | |
656 | - // espera acabar e só então conta o tempo | |
657 | - if (endedAnimation != null) | |
658 | - while (COMPONENT_ANIMATION.IsPlaying(endedAnimation.name)) | |
659 | - yield return null; | |
660 | - | |
661 | - // Tempo para pular para a legenda da próxima animação | |
662 | - yield return new WaitForSeconds(0.4F); | |
663 | - | |
664 | - endedAnimation = reference; | |
654 | + // Waits next animation starts | |
655 | + while (!COMPONENT_ANIMATION.IsPlaying(next.name)) | |
656 | + yield return new WaitForEndOfFrame(); | |
657 | + | |
658 | + // Waits half fade | |
659 | + yield return new WaitForSeconds(this.fadeLength / 2); | |
665 | 660 | break; |
666 | 661 | } |
667 | - | |
668 | - else if (COMPONENT_ANIMATION.IsPlaying(reference.name)) | |
669 | - yield return null; | |
670 | - | |
671 | - else break; | |
662 | + else if (!COMPONENT_ANIMATION.IsPlaying(reference.name)) break; | |
672 | 663 | } |
673 | - | |
674 | - reference = null; | |
675 | 664 | } |
676 | 665 | |
677 | - // Se a animação não tiver sido liberada e seu AnimationState for nulo, | |
678 | - // a animação será liberada | |
679 | - if (reference != null && reference.state == null) | |
666 | + // Animation played but was not tracked | |
667 | + if (reference.state == null) | |
680 | 668 | this.animQueue.Dequeue(); |
681 | - else | |
682 | - yield return null; | |
683 | - } | |
684 | - else yield return null; | |
685 | - | |
686 | - isNotEmpty = this.animQueue.Count > 0; | |
687 | - } | |
669 | + } | |
670 | + else if (this.playing && !this.loading) | |
671 | + { | |
672 | + PlayerLogger.Log("GPM", "AW", "Not playing."); | |
688 | 673 | |
689 | - this.subtitles.setText(""); | |
674 | + resetStates(); | |
690 | 675 | |
691 | - resetStates(); | |
692 | - this.randomAnimations.unlockFor("AnimationsHandler"); | |
676 | + this.subtitles.setText(""); | |
677 | + this.randomAnimations.unlockFor("AnimationsWatcher"); | |
678 | + } | |
679 | + } | |
693 | 680 | } |
694 | 681 | |
695 | 682 | public void resetStates() |
696 | 683 | { |
697 | - this.animationPlaying = null; | |
698 | 684 | this.playing = false; |
699 | 685 | this.paused = false; |
686 | + this.animationPlaying = null; | |
700 | 687 | |
701 | 688 | onPlayingStateChange(); |
702 | 689 | } | ... | ... |
Assets/Scripts/PlayerManager.cs
... | ... | @@ -68,8 +68,8 @@ public class PlayerManager : GenericPlayerManager { |
68 | 68 | #endif |
69 | 69 | |
70 | 70 | Screen.fullScreen = false; |
71 | - // Hide input text preview | |
72 | - // TouchScreenKeyboard.hideInput = true; | |
71 | + | |
72 | + | |
73 | 73 | } |
74 | 74 | |
75 | 75 | public void playDict(string word) |
... | ... | @@ -120,19 +120,19 @@ public class PlayerManager : GenericPlayerManager { |
120 | 120 | |
121 | 121 | protected override WWW loadAssetBundle(string aniName) |
122 | 122 | { |
123 | - string address = BASE_URL + regionPath + WWW.EscapeURL(aniName); | |
123 | + if (this.regionHash == 1) | |
124 | + { | |
125 | + // Check if it exists in trie | |
126 | + } | |
127 | + | |
128 | + string address = BASE_URL + this.regionPath + WWW.EscapeURL(aniName); | |
124 | 129 | |
125 | 130 | PlayerLogger.Log("PM", "lAB", "Requesting bundle: " + address); |
126 | 131 | return WWW.LoadFromCacheOrDownload(address, this.regionHash); |
127 | 132 | } |
128 | 133 | |
129 | - private System.Object LOCKER_STATE = new System.Object(); | |
130 | - | |
131 | - public override void onPlayingStateChange() | |
132 | - { | |
133 | - lock (LOCKER_STATE) { | |
134 | - this.screenManager.changeStates(base.isPlaying(), base.isPaused(), ! String.IsNullOrEmpty(base.gloss)); | |
135 | - } | |
134 | + public override void onPlayingStateChange() { | |
135 | + this.screenManager.changeStates(base.isPlaying(), base.isPaused(), ! String.IsNullOrEmpty(base.gloss)); | |
136 | 136 | } |
137 | 137 | |
138 | 138 | public override void onConnectionError(string gloss, string word) |
... | ... | @@ -207,13 +207,8 @@ public class PlayerManager : GenericPlayerManager { |
207 | 207 | protected override IEnumerator WaitForResponse(WWW www) |
208 | 208 | { |
209 | 209 | PlayerLogger.Log("PM", "WFR", "Stating time check."); |
210 | - | |
211 | -#if UNITY_ANDROID | |
212 | - const float timeoutLimit = 10f; | |
213 | -#elif UNITY_IOS | |
214 | - const float timeoutLimit = 3f; | |
215 | -#endif | |
216 | 210 | |
211 | + const float timeoutLimit = 10f; | |
217 | 212 | float timer = 0; |
218 | 213 | |
219 | 214 | while ( ! www.isDone) |
... | ... | @@ -263,9 +258,16 @@ public class PlayerManager : GenericPlayerManager { |
263 | 258 | |
264 | 259 | PlayerLogger.Log("PM", "t", "(WWW) Error: " + glossRequest.error); |
265 | 260 | } |
266 | - else if (glossRequest.responseHeaders.Count == 0 || !glossRequest.responseHeaders["STATUS"].EndsWith("200 OK")) | |
261 | + else if (glossRequest.responseHeaders.Count == 0) | |
262 | + { | |
263 | + PlayerLogger.Log("PM", "t", "Unsuccessful answer (0)."); | |
264 | + | |
265 | + this.screenManager.showConnectionErrorDialog( | |
266 | + PlayerManager.ERROR_STATUS_MESSAGE.TRANSLATOR_CONNECTION_FAILURE); | |
267 | + } | |
268 | + else if (!glossRequest.responseHeaders["STATUS"].Contains("200")) | |
267 | 269 | { |
268 | - PlayerLogger.Log("PM", "t", "Unsuccessful answer."); | |
270 | + PlayerLogger.Log("PM", "t", "Unsuccessful answer (" + glossRequest.responseHeaders["STATUS"] + ")."); | |
269 | 271 | |
270 | 272 | this.screenManager.showConnectionErrorDialog( |
271 | 273 | PlayerManager.ERROR_STATUS_MESSAGE.TRANSLATOR_CONNECTION_FAILURE); | ... | ... |