private void SwitchTexture() { if (null == m_LevelGeneratorPtr) { Debug.LogError("AnimationPlayer::SwitchTexture() null == m_LevelGeneratorPtr"); return; } if (false == m_LevelGeneratorPtr.m_AnimationSequenceData.ContainsKey(m_CurrentAnimationTag)) { Debug.LogError("AnimationPlayer::SwitchTexture() false == m_LevelGeneratorPtr.m_AnimationSequenceData.ContainsKey=" + m_CurrentAnimationTag); return; } if (null != m_GUIAnimationTexture) { AnimationSequenceStruct animSeq = m_LevelGeneratorPtr.m_AnimationSequenceData[m_CurrentAnimationTag]; string imagepath = animSeq.m_ImageFilepath[m_AnimationIndex]; Texture2D tex2D = (Texture2D)Resources.Load("Texture/" + imagepath); // Debug.Log( "AnimationPlayer::SwitchTexture() imagepath=" + m_AnimationIndex + " " + imagepath ) ; if (null == tex2D) { Debug.Log("AnimationPlayer::SwitchTexture() null == tex2D"); return; } m_GUIAnimationTexture.texture = tex2D; } }
// Update is called once per frame void Update() { if (false == m_IsActive) { return; } if (null == m_LevelGeneratorPtr) { return; } if (false == m_LevelGeneratorPtr.m_AnimationSequenceData.ContainsKey(m_CurrentAnimationTag)) { return; } if (Time.timeSinceLevelLoad - m_AnimationLastTime > m_AnimationSpeedSec) { AnimationSequenceStruct animSeq = m_LevelGeneratorPtr.m_AnimationSequenceData[m_CurrentAnimationTag]; ++m_AnimationIndex; m_AnimationLastTime = Time.timeSinceLevelLoad; if (m_AnimationIndex >= animSeq.m_ImageFilepath.Count) { Debug.Log("AnimationPlayer::Update() m_AnimationIndex >= animSeq.m_ImageFilepath.Count"); m_IsActive = false; } else { SwitchTexture(); } } }
void ParseAnimationSequence(string _Content) { string [] spliter = { "\n" }; string [] strLines = _Content.Split(spliter, System.StringSplitOptions.None); // Debug.Log( "ParseAnimationSequence() strLines.Length" + strLines.Length ) ; for (int i = 0; i < strLines.Length; ++i) { if (0 == strLines[i].Length) { continue; } // Debug.Log( "ParseAnimationSequence() strLines[ i ]=" + strLines[ i ] ) ; string [] spliter2 = { "," }; string [] strSegments = strLines[i].Split(spliter2, System.StringSplitOptions.None); // Debug.Log( "ParseAnimationSequence() strSegments.Length=" + strSegments.Length ) ; if (strSegments.Length > 0) { AnimationSequenceStruct newStruct = new AnimationSequenceStruct(); newStruct.m_AnimationTag = strSegments[0]; for (int j = 1; j < strSegments.Length; ++j) { if (strSegments[j].Length > 0) { // Debug.Log( "strSegments[ j ]=" + strSegments[ j ] ) ; newStruct.m_ImageFilepath.Add(strSegments[j]); } } m_AnimationSequenceData.Add(newStruct.m_AnimationTag, newStruct); } } Debug.Log("ParseAnimationSequence() m_AnimationSequenceData.Count=" + m_AnimationSequenceData.Count); }
void ParseAnimationSequence( string _Content ) { string [] spliter = { "\n" } ; string [] strLines = _Content.Split( spliter , System.StringSplitOptions.None ) ; // Debug.Log( "ParseAnimationSequence() strLines.Length" + strLines.Length ) ; for( int i = 0 ; i < strLines.Length ; ++i ) { if( 0 == strLines[ i ].Length ) continue ; // Debug.Log( "ParseAnimationSequence() strLines[ i ]=" + strLines[ i ] ) ; string [] spliter2 = { "," } ; string [] strSegments = strLines[ i ].Split( spliter2 , System.StringSplitOptions.None ) ; // Debug.Log( "ParseAnimationSequence() strSegments.Length=" + strSegments.Length ) ; if( strSegments.Length > 0 ) { AnimationSequenceStruct newStruct = new AnimationSequenceStruct() ; newStruct.m_AnimationTag = strSegments[ 0 ] ; for( int j = 1 ; j < strSegments.Length ; ++j ) { if( strSegments[ j ].Length > 0 ) { // Debug.Log( "strSegments[ j ]=" + strSegments[ j ] ) ; newStruct.m_ImageFilepath.Add( strSegments[ j ] ) ; } } m_AnimationSequenceData.Add( newStruct.m_AnimationTag , newStruct ) ; } } Debug.Log( "ParseAnimationSequence() m_AnimationSequenceData.Count=" + m_AnimationSequenceData.Count ) ; }