From 8e6d750824bebae4bf3d587c471d0396abbea5a9 Mon Sep 17 00:00:00 2001 From: Icaro Magalhaes Date: Thu, 6 Aug 2015 14:42:27 -0300 Subject: [PATCH] Problemas de strings nulas resolvidos e anti aliasing implementado --- Assets/Scenes/Main.unity | 12 ++++++++---- Assets/Scripts/PlayerManager.cs | 114 +++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------------- Assets/Scripts/Subtitles.cs | 16 +++++++++++++++- ProjectSettings/QualitySettings.asset | 2 +- 4 files changed, 67 insertions(+), 77 deletions(-) diff --git a/Assets/Scenes/Main.unity b/Assets/Scenes/Main.unity index 9bf129d..74c2dcf 100644 --- a/Assets/Scenes/Main.unity +++ b/Assets/Scenes/Main.unity @@ -496,11 +496,11 @@ Prefab: objectReference: {fileID: 0} - target: {fileID: 22483792, guid: a310db7b56d86974ca7dc72c28f6a7f6, type: 2} propertyPath: m_AnchoredPosition.x - value: 57.2999992 + value: 61.9000015 objectReference: {fileID: 0} - target: {fileID: 22483792, guid: a310db7b56d86974ca7dc72c28f6a7f6, type: 2} propertyPath: m_AnchoredPosition.y - value: -137.100006 + value: 62.5 objectReference: {fileID: 0} - target: {fileID: 22483792, guid: a310db7b56d86974ca7dc72c28f6a7f6, type: 2} propertyPath: m_AnchorMin.x @@ -512,11 +512,11 @@ Prefab: objectReference: {fileID: 0} - target: {fileID: 22483792, guid: a310db7b56d86974ca7dc72c28f6a7f6, type: 2} propertyPath: m_AnchorMin.y - value: .5 + value: 0 objectReference: {fileID: 0} - target: {fileID: 22483792, guid: a310db7b56d86974ca7dc72c28f6a7f6, type: 2} propertyPath: m_AnchorMax.y - value: .5 + value: 0 objectReference: {fileID: 0} - target: {fileID: 22483792, guid: a310db7b56d86974ca7dc72c28f6a7f6, type: 2} propertyPath: m_SizeDelta.y @@ -546,6 +546,10 @@ Prefab: propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_MethodName value: start_web_play objectReference: {fileID: 0} + - target: {fileID: 11451458, guid: a310db7b56d86974ca7dc72c28f6a7f6, type: 2} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Mode + value: 1 + objectReference: {fileID: 0} m_RemovedComponents: [] m_ParentPrefab: {fileID: 100100000, guid: a310db7b56d86974ca7dc72c28f6a7f6, type: 2} m_IsPrefabParent: 0 diff --git a/Assets/Scripts/PlayerManager.cs b/Assets/Scripts/PlayerManager.cs index 7b45e7f..c63ea5e 100644 --- a/Assets/Scripts/PlayerManager.cs +++ b/Assets/Scripts/PlayerManager.cs @@ -15,6 +15,7 @@ public class PlayerManager : MonoBehaviour { public static float hSliderValue = 1.1f; public static string alphabet = "0123456789,ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + public string glosa = " _default "; public static String[] stringPos = {"_default"};//vetor que sera usado para quebrar a glosa // Guarda os nomes das palavras ja carregadas @@ -22,18 +23,11 @@ public class PlayerManager : MonoBehaviour { // Guarda os nomes das palavras que nao tem assetbundle HashSet nonexistentAssetBundles = new HashSet(); - - // Contem todos os nomes das anims na ordem que serao reproduzidas - public static Queue playList = new Queue(); - AnimationClip aniClip; - public string glosa = " _default "; - - + GameObject AVATAR; Animation COMPONENT_ANIMATION; - //Primeiro metodo que o player executa void Start( ){ Application.ExternalCall("onLoadPlayer");//var onLoadPlayer = function(){} @@ -44,33 +38,21 @@ public class PlayerManager : MonoBehaviour { } - void Update(){ - if(COMPONENT_ANIMATION.isPlaying) - foreach(AnimationState anim in COMPONENT_ANIMATION) - anim.speed = hSliderValue; - } + void Update( ){ if(COMPONENT_ANIMATION.isPlaying) foreach(AnimationState anim in COMPONENT_ANIMATION) anim.speed = hSliderValue; } //define a velocidade das animacoes com base no slider da GUI - public void setSlider( float x ){ - hSliderValue = x; - - } + public void setSlider( float x ){ hSliderValue = x; } //adiciona alfabeto e numerais ao componente animador do avatar void addAlpha( ){ - - - foreach( char letter in alphabet ){ - - aniClip = Resources.Load ("ANIMS/"+letter); + foreach( char letter in alphabet ){ aniClip = Resources.Load ("ANIMS/"+letter); if( aniClip ) COMPONENT_ANIMATION.AddClip(aniClip, ""+letter); else Debug.Log("Anim "+letter+" not found"); } - }//addAlpha public void stop_animations( ){ @@ -81,97 +63,82 @@ public class PlayerManager : MonoBehaviour { } - public void catchGlosa(){ + public void catchGlosa(String glosa){ - this.glosa = " _default "+glosa+" _default "; + //Debug.Log ("glosa antes do catch: "+glosa); + this.glosa = glosa; + //Debug.Log("glosa depois do catch: "+glosa); + start_web_play(); } - - - - public void start_inputfield_web_play( ){ - int version = 1; - StartCoroutine(webPlay(INFIELD.text.ToUpper(), version)); - } - - public void start_web_play( ){ - - catchGlosa(); - int version = 1; - StartCoroutine(webPlay(INFIELD.text.ToUpper(), version)); - + + public void start_web_play( ){ int version = 1; + try{ StartCoroutine(webPlay(glosa, version)); + }catch(Exception e){Debug.Log (e+" :: Ops! Tivemos um problema capiscioso e cabriocrarico...");} } IEnumerator webPlay(String glosa, int version) { - - stop_animations( ); - Subtitles.WORDS.Clear(); - foreach( char letter in alphabet ) Subtitles.WORDS.Add(""+letter); - + if(Subtitles.WORDS.Count==0) foreach( char letter in alphabet ) Subtitles.WORDS.Add(""+letter); stringPos = glosa.Split(' '); - String BaseURL = "http://150.165.205.9/anims/WEBGL/"; - //aniClip = www.assetBundle.mainAsset as AnimationClip; + String BaseURL = "http://150.165.205.9/anims/WEBGL/"; COMPONENT_ANIMATION.CrossFadeQueued("_default", 0.6F, QueueMode.CompleteOthers); foreach(string aniName in stringPos){ - try{ - - if (String.IsNullOrEmpty(aniName)) continue; - - }catch(Exception e){ Debug.Log(e+" :: NotNullNotEmpty"); } + try{ if(String.IsNullOrEmpty(aniName)) continue; + }catch(Exception e){ Debug.Log(e+" :: NotNullNotEmpty"); } // Se ja estiver carregado: reproduz animaƧao - if (loadedAssetBundles.Contains(aniName)){ + if(loadedAssetBundles.Contains(aniName)){ - Subtitles.WORDS.Add(aniName); COMPONENT_ANIMATION.CrossFadeQueued(aniName, 0.6F, QueueMode.CompleteOthers); - }else if (nonexistentAssetBundles.Contains(aniName)){//se nao estiver, soletra + }else if(nonexistentAssetBundles.Contains(aniName)){//se nao estiver, soletra foreach (char letter in aniName) COMPONENT_ANIMATION.CrossFadeQueued(""+letter, 0.6F, QueueMode.CompleteOthers); }else{ + if(String.IsNullOrEmpty(aniName)){ Debug.Log("NULL aniName:"+aniName+" vazio!"); continue; } + WWW www = WWW.LoadFromCacheOrDownload(BaseURL+aniName, version); yield return www; - if (www.error != null){//soletra se o ww inexistir + if(www.error != null){//soletra se o ww inexistir + //throw new Exception("Erro no WWW: " + www.error); Debug.Log("Sinal nao disponivel em banco de sinais. SOLETRANDO "+aniName); - foreach (char letter in aniName) - COMPONENT_ANIMATION.CrossFadeQueued(""+letter, 0.6F, QueueMode.CompleteOthers); - + foreach (char letter in aniName) COMPONENT_ANIMATION.CrossFadeQueued(""+letter, 0.6F, QueueMode.CompleteOthers); nonexistentAssetBundles.Add(aniName); continue; - }else{ + } - //Debug.Log (www.assetBundle.name); - aniClip = www.assetBundle.mainAsset as AnimationClip; + AssetBundle bundle = www.assetBundle; - if (aniClip){ + if(String.IsNullOrEmpty(bundle.mainAsset.name)){ Debug.Log(bundle.name+" vazio!"); continue; } - COMPONENT_ANIMATION.AddClip(aniClip, aniName); - COMPONENT_ANIMATION.CrossFadeQueued(aniName, 0.6F, QueueMode.CompleteOthers); // 0.4 + aniClip = bundle.mainAsset as AnimationClip; + bundle.Unload(false); - Subtitles.WORDS.Add(aniName); loadedAssetBundles.Add(aniName); + if(aniClip){ - }else{ - foreach (char letter in aniName) - COMPONENT_ANIMATION.CrossFadeQueued("" + letter, 0.6F, QueueMode.CompleteOthers); + COMPONENT_ANIMATION.AddClip(aniClip, aniName); + COMPONENT_ANIMATION.CrossFadeQueued(aniName, 0.6F, QueueMode.CompleteOthers); // 0.4 - } + Subtitles.WORDS.Add(aniName); loadedAssetBundles.Add(aniName); + }else{ Debug.Log ("eita"); + foreach(char letter in aniName) COMPONENT_ANIMATION.CrossFadeQueued(""+letter, 0.6F, QueueMode.CompleteOthers); } }//else @@ -181,5 +148,10 @@ public class PlayerManager : MonoBehaviour { COMPONENT_ANIMATION.CrossFadeQueued("_default", 0.6F, QueueMode.CompleteOthers); } - -} \ No newline at end of file + + public void start_inputfield_web_play( ){ int version = 1; + try{ StartCoroutine(webPlay(INFIELD.text.ToUpper(), version)); + }catch(Exception e){Debug.Log (e+" :: Exception StartCourr"); } + } + +} diff --git a/Assets/Scripts/Subtitles.cs b/Assets/Scripts/Subtitles.cs index 8dcbb92..1926e3b 100644 --- a/Assets/Scripts/Subtitles.cs +++ b/Assets/Scripts/Subtitles.cs @@ -13,6 +13,7 @@ public class Subtitles : MonoBehaviour { public Text SUBTITLES; GameObject AVATAR; Animation COMPONENT_ANIMATION; + private HashSet numeros; public static HashSet WORDS = new HashSet(); @@ -32,6 +33,18 @@ public class Subtitles : MonoBehaviour { string GetCurrentPlayingAnimationClip( ){ + foreach(AnimationState aniName in COMPONENT_ANIMATION) + if( COMPONENT_ANIMATION.IsPlaying(aniName.name) && !aniName.name[0].Equals('_')) return aniName.name.Split(' ')[0]; + + return null; + + } + + + + + string _AGetCurrentPlayingAnimationClip( ){ + foreach(String aniName in WORDS) if(COMPONENT_ANIMATION.IsPlaying(aniName+" - Queued Clone")) return aniName; @@ -40,7 +53,8 @@ public class Subtitles : MonoBehaviour { } - /*string GetCurrentPlayingAnimationClip( ){ if(isCaptionActiveFlag) foreach(string anim in words_from_glosa){ if( COMPONENT_ANIMATION.IsPlaying( anim+" - Queued Clone" ) ) //if( !(anim.Equals("_default - Queued Clone") || anim.Equals("_default") ) ) return anim; } return null; }*/ + /*string GetCurrentPlayingAnimationClip( ){ + * if(isCaptionActiveFlag) foreach(string anim in words_from_glosa){ if( COMPONENT_ANIMATION.IsPlaying( anim+" - Queued Clone" ) ) //if( !(anim.Equals("_default - Queued Clone") || anim.Equals("_default") ) ) return anim; } return null; }*/ bool isCaptionActiveFlag = true; diff --git a/ProjectSettings/QualitySettings.asset b/ProjectSettings/QualitySettings.asset index 022ce14..b7444d5 100644 --- a/ProjectSettings/QualitySettings.asset +++ b/ProjectSettings/QualitySettings.asset @@ -134,7 +134,7 @@ QualitySettings: blendWeights: 4 textureQuality: 0 anisotropicTextures: 2 - antiAliasing: 0 + antiAliasing: 2 softParticles: 0 softVegetation: 1 realtimeReflectionProbes: 1 -- libgit2 0.21.2