Exemple #1
0
    /// <summary>
    /// Render method for ingame. Waits for postrender.
    /// </summary>
    private IEnumerator OnPostRender()
    {
        if (itsPhotoData != null)
        {
            itsPhotoData.itsTexture.ReadPixels(new Rect(0, 0, itsPhotoData.itsTextureSize, itsPhotoData.itsTextureSize), 0, 0);
            itsPhotoData.itsTexture.wrapMode = TextureWrapMode.Clamp;
            itsPhotoData.itsTexture.Apply();

            itsOldPhotoData = itsPhotoData;
            // Get next frames data
            itsPhotoData = itsMapSystem.GetNextPhotoData();
            if (itsPhotoData != null)
            {
                transform.position = CalculateCameraPosition(itsPhotoData); //place camera correctly for photo
            }
            yield return(new WaitForEndOfFrame());                          //this is very important! When using pro reflective water effects you cannot simply create new MeshRenderers during rendering. So wait for end of frame.

            KGFMapSystem.KGFSetChildrenActiveRecursively(itsOldPhotoData.itsPhotoPlane, true);
        }
        if (itsPhotoData == null)
        {
            yield return(new WaitForEndOfFrame());

            itsDestroy = true;
        }
    }