72 lines
1.7 KiB
C#
72 lines
1.7 KiB
C#
using System.Collections;
|
|
using UnityEngine;
|
|
|
|
public class KGFPhotoCapture : MonoBehaviour
|
|
{
|
|
private KGFMapSystem.KGFPhotoData itsOldPhotoData;
|
|
|
|
public KGFMapSystem itsMapSystem;
|
|
|
|
private KGFMapSystem.KGFPhotoData itsPhotoData;
|
|
|
|
private bool itsDestroy;
|
|
|
|
private void Start()
|
|
{
|
|
itsPhotoData = itsMapSystem.GetNextPhotoData();
|
|
if (itsPhotoData != null)
|
|
{
|
|
base.transform.position = CalculateCameraPosition(itsPhotoData);
|
|
}
|
|
}
|
|
|
|
private Vector3 CalculateCameraPosition(KGFMapSystem.KGFPhotoData thePhotoData)
|
|
{
|
|
Vector3 itsPosition = thePhotoData.itsPosition;
|
|
float num = thePhotoData.itsMeters / 2f;
|
|
itsPosition.x += num;
|
|
if (itsMapSystem.GetOrientation() == KGFMapSystem.KGFMapSystemOrientation.XZDefault)
|
|
{
|
|
itsPosition.z += num;
|
|
itsPosition.y += GetComponent<Camera>().farClipPlane;
|
|
}
|
|
else
|
|
{
|
|
itsPosition.y += num;
|
|
itsPosition.z -= GetComponent<Camera>().farClipPlane;
|
|
}
|
|
return itsPosition;
|
|
}
|
|
|
|
private IEnumerator OnPostRender()
|
|
{
|
|
if (itsPhotoData != null)
|
|
{
|
|
itsPhotoData.itsTexture.ReadPixels(new Rect(0f, 0f, itsPhotoData.itsTextureSize, itsPhotoData.itsTextureSize), 0, 0);
|
|
itsPhotoData.itsTexture.wrapMode = TextureWrapMode.Clamp;
|
|
itsPhotoData.itsTexture.Apply();
|
|
itsOldPhotoData = itsPhotoData;
|
|
itsPhotoData = itsMapSystem.GetNextPhotoData();
|
|
if (itsPhotoData != null)
|
|
{
|
|
base.transform.position = CalculateCameraPosition(itsPhotoData);
|
|
}
|
|
yield return new WaitForEndOfFrame();
|
|
KGFMapSystem.KGFSetChildrenActiveRecursively(itsOldPhotoData.itsPhotoPlane, true);
|
|
}
|
|
if (itsPhotoData == null)
|
|
{
|
|
yield return new WaitForEndOfFrame();
|
|
itsDestroy = true;
|
|
}
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (itsDestroy)
|
|
{
|
|
Object.Destroy(base.gameObject);
|
|
}
|
|
}
|
|
}
|