Game Development Reference
In-Depth Information
037
038 //Source Rect
039 Rect SourceRect = new Rect(0,1,1,-1);
040
041 //Render each camera to their target texture
042 for(int i = 0; i<Cameras.Length; i++)
043 {
044 //Render camera
045 Cameras[i].Render();
046
047 //Draw textures to screen using camera
048 GL.PushMatrix();
049 GL.LoadPixelMatrix();
050 Graphics.DrawTexture(ScreenRct,
Cameras[i].targetTexture, SourceRect,
0,0,0,0, CamCols[i]);
051 GL.PopMatrix(); //Reset matrix
052 }
053 }
054 //---------------------------------------
055 //This function is called after OnPostRender
056 //And when final pixels are to be shown on screen
057 //src = current render from camera
058 //dst = texture to be shown on screen
059 void OnRenderImage(RenderTexture src, RenderTexture dst)
060 {
061 //Now push final pixels to screen with Mat
062 Graphics.Blit(src, dst, Mat);
063 }
064 //---------------------------------------
065 //Lerp color over period TotalTime
066 //Fade alpha for topmost rendered camera CamCols[1]
067 public IEnumerator Fade(Color From, Color To, float
TotalTime)
068 {
069 float ElapsedTime = 0f;
070
071 //Loop while total time is not met
072 while(ElapsedTime <= TotalTime)
073 {
074 //Update color
075 CamCols[1] = Color.Lerp(From, To,
ElapsedTime/TotalTime);
 
Search WWH ::




Custom Search