浏览代码

add camera cubemap controller

/cinematic-demo-ME
etienne cella 5 年前
当前提交
e5d404ed
共有 2 个文件被更改,包括 68 次插入0 次删除
  1. 57
      Assets/ClusterDisplay/Scripts/CubemapCameraController.cs
  2. 11
      Assets/ClusterDisplay/Scripts/CubemapCameraController.cs.meta

57
Assets/ClusterDisplay/Scripts/CubemapCameraController.cs


using System;
using UnityEngine;
[ExecuteInEditMode]
public class CubemapCameraController : MonoBehaviour
{
static readonly Vector3[] k_Orientations = new[]
{
new Vector3(0, 0, 0),
new Vector3(0, 1, 0),
new Vector3(0, 2, 0),
new Vector3(0, 3, 0),
new Vector3(-1, 0, 0), // ceiling
new Vector3(1, 0, 0), // bottom
};
int m_Index;
void OnEnable()
{
m_Index = 0;
}
void Update()
{
// B + left or right arrow to switch orientation
if (Input.GetKey(KeyCode.B))
{
if (Input.GetKeyDown(KeyCode.RightArrow))
Next();
else if (Input.GetKeyDown(KeyCode.LeftArrow))
Previous();
}
}
public void Next()
{
m_Index = (m_Index + 1) % k_Orientations.Length;
SetOrientation(m_Index);
}
public void Previous()
{
m_Index = (m_Index - 1 + k_Orientations.Length) % k_Orientations.Length;
SetOrientation(m_Index);
}
// we deliberately set transform outside update to avoid conflict with other camera controllers
void SetOrientation(int index)
{
var camera = Camera.main;
if (camera != null)
{
camera.transform.rotation = Quaternion.Euler(k_Orientations[index] * 90);
}
}
}

11
Assets/ClusterDisplay/Scripts/CubemapCameraController.cs.meta


fileFormatVersion: 2
guid: 5e0d67f9bc76ad74a97e3919a6db523c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存