Stereoscopic Slideshow

btc_debug
Nadine Ganz 2024-04-10 09:44:23 +02:00
parent 6e9b67cfb8
commit b7bf08930d
41 changed files with 19170 additions and 15892 deletions

View File

@ -684,7 +684,7 @@ MonoBehaviour:
- {fileID: -4731438336562001402}
- {fileID: 4135229692886101830}
- {fileID: 2220871646205782247}
m_renderMode: 1
m_renderMode: 0
m_depthSubmissionMode: 0
m_symmetricProjection: 0
--- !u!114 &-3022769360335504799
@ -2133,3 +2133,4 @@ MonoBehaviour:
- {fileID: -7494486358618572369}
m_renderMode: 1
m_depthSubmissionMode: 0
m_symmetricProjection: 0

View File

@ -1,10 +1,9 @@
Tree("Root") {
Composite(Sequence) {
Composite (Marathon) {
RunTree("Fading_Text")
RunTree("Fading_Bush")
RunTree("Play_Depthkit")
}
BTC.Show("GO.Canvas")
Composite(Race) {
Composite(Sequence) {
// Blue Cube
@ -22,24 +21,24 @@
}
}
Tree("Fading_Text") {
Composite (Sequence) {
BTC.FadeOut("TextMeshPro.Canvas")
BTC.FadeIn("TextMeshPro.Canvas")
}
}
Tree("Fading_Bush") {
Composite (Sequence) {
BTC.FadeIn("Renderer.STATIC.bushBaked")
}
}
Tree("Play_Depthkit") {
Composite(Sequence) {
BTC.Show("Depthkit.STATIC.D21A")
BTC.Run("Depthkit.STATIC.D21A")
}
}
Tree("Reset") {
Composite(Marathon) {
BTC.Hide("GO.Canvas")
BTC.Hide("GO.STATIC.-152100")
BTC.Hide("GO.STATIC")
BTC.FadeOut("Renderer.STATIC.bushBaked")
BTC.Hide("Depthkit.STATIC.D21A")
}
}

View File

@ -0,0 +1,4 @@
Tree("Root") {
BTC.Run("StereoSlideshow.CompleteXROriginSetUp.IMG0047")
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 860366996b80f463584f75cf0281e80d
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -143,7 +143,7 @@ ModelImporter:
importPhysicalCameras: 1
importVisibility: 1
importBlendShapes: 1
importCameras: 1
importCameras: 0
importLights: 1
nodeNameCollisionStrategy: 1
fileIdsGeneration: 2

View File

@ -0,0 +1,75 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using MyBT;
#if UNITY_EDITOR
using UnityEditor;
[CustomEditor(typeof(NamedStereoscopicSlideshow))]
public class NamedStereoscopicSlideshowInspector : ComponentHandlerInspector {
}
#endif
[System.Serializable]
public class NamedStereoscopicSlideshow : ComponentHandler {
public override string TypeLabel()
{
return "StereoSlideshow";
}
public override string ContentLabel()
{
UpdateComponent();
string[] fullPath = photoTransition.imgPathList[0].Split('/');
string filename = fullPath[fullPath.Length - 1];
string fileNameWithoutExt = filename.Remove(filename.Length - 5); // remove .jpeg
string final = fileNameWithoutExt.Length > 10 ? fileNameWithoutExt.Substring(0, 10) : fileNameWithoutExt; // first 10 characters
return final;
}
public override void UpdateComponent()
{
base.UpdateComponent();
photoTransition = GetComponent<PhotoTransition>();
if (photoTransition == null)
{
Debug.Log($"NamedStereoscopicSlideshow.UpdateComponent photoTransition is null");
}
}
public PhotoTransition photoTransition;
float _timeLeft;
float _totalTime = 5.0f;
public override void Run(NodeState nodeState)
{
switch (nodeState)
{
case NodeState.FirstRun:
photoTransition.Reset();
_timeLeft = _totalTime;
StartCoroutine(photoTransition.SetUp());
break;
case NodeState.Running:
_timeLeft -= Time.deltaTime;
if (_timeLeft < 0)
{
StartCoroutine(photoTransition.LoadNextImage());
_timeLeft = _totalTime;
}
if (photoTransition.IsSlideshowFinished())
{
Task.SetSucceeded();
}
break;
case NodeState.Aborting:
photoTransition.Reset();
_timeLeft = _totalTime;
break;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 04127b6bcb23c4d00a2639b54db59ea2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 90945948616a441e2ae6b7210940d695
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 2cc997087ddfed54f97fe057e7bc91c9
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 87771824a45c27741989588b75cf621b
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 813571ffdd414844da8bee3252681a08
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,132 @@
//----------------------------------------------------------------.
// 球に対して、Equirectangular360/Equirectangular180 SBS/FishEye180 SBSのステレオパラマ投影を行う.
//----------------------------------------------------------------.
Shader "Hidden/Panorama180View/panoramaSphereRendering"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_Intensity ("Intensity", Range (0, 10.0)) = 1.0
}
SubShader
{
Tags { "RenderType"="Opaque" "Queue"="geometry-100" }
LOD 100
ZWrite On
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
#define UNITY_PI2 (UNITY_PI * 2.0)
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float2 uv : TEXCOORD0;
float4 vertex : SV_POSITION;
};
sampler2D _MainTex;
float4 _MainTex_ST;
float _Intensity;
int _Mode; // 0 : Equirectangular360 TopAndBottom、1 : Equirectangular180 SideBySide、2 : FishEye180 SideBySide.
int _TransitionType; // 0 : 遷移しない、 1 : フェードイン、 2 : フェードアウト、 3 : ブレンド.
sampler2D _DestTex; // 状態遷移時の移行先のテクスチャ.
float _TPos; // 遷移の移行値 (0.0 - 1.0).
float4 _FadeInColor; // フェードインの色.
float4 _FadeOutColor; // フェードアウトの色.
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
//o.uv = v.uv;
return o;
}
/**
* テクスチャ上のUV位置を計算.
*/
float2 calcUV (float2 _uv) {
float2 uv = _uv;
if (_Mode == 2) {
// FishEyeからequirectangularの変換.
// reference : http://paulbourke.net/dome/fish2/
float theta = UNITY_PI2 * (uv.x - 0.5);
float phi = UNITY_PI * (uv.y - 0.5);
float sinP = sin(phi);
float cosP = cos(phi);
float sinT = sin(theta);
float cosT = cos(theta);
float3 vDir = float3(cosP * sinT, cosP * cosT, sinP);
theta = atan2(vDir.z, vDir.x);
phi = atan2(sqrt(vDir.x * vDir.x + vDir.z * vDir.z), vDir.y);
float r = phi / UNITY_PI;
uv.x = 0.5 + r * cos(theta);
uv.y = 0.5 + r * sin(theta);
uv.x *= 0.5;
if (unity_StereoEyeIndex == 1) {
uv.x += 0.5;
}
} if (_Mode == 0) { // Equirectangular360 TopAndBottom.
uv.y *= 0.5;
if (unity_StereoEyeIndex == 0) {
uv.y += 0.5;
}
} else if (_Mode == 1) { // Equirectangular180 SideBySide.
uv.x -= 0.25;
if (unity_StereoEyeIndex == 1) {
uv.x += 0.5;
}
}
return uv;
}
float4 frag (v2f i) : SV_Target
{
float2 uv = i.uv;
if (uv.x < 0.25 || uv.x > 0.75) return float4(0.0, 0.0, 0.0, 1.0);
// UV値を計算.
uv = calcUV(uv);
float4 col = tex2D(_MainTex, uv);
col.rgb *= _Intensity;
if (_TransitionType == 1) { // フェードイン.
col.rgb = lerp(_FadeInColor.rgb, col.rgb, _TPos);
} else if (_TransitionType == 2) { // フェードアウト.
col.rgb = lerp(col.rgb, _FadeOutColor.rgb, _TPos);
} else if (_TransitionType == 3) { // ブレンド.
float4 col2 = tex2D(_DestTex, uv);
col2.rgb *= _Intensity;
col.rgb = lerp(col.rgb, col2.rgb, _TPos);
}
return col;
}
ENDCG
}
}
}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 4f38283228bf75441836d159564d7390
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 2849ba4d9bb80114482417a9ca73fea4
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,97 @@
fileFormatVersion: 2
guid: 9dfee461a74deb944aa1179683344d46
ModelImporter:
serializedVersion: 23
fileIDToRecycleName:
100000: //RootNode
400000: //RootNode
2100000: background
2300000: //RootNode
3300000: //RootNode
4300000: sphere
externalObjects: {}
materials:
importMaterials: 1
materialName: 0
materialSearch: 1
materialLocation: 1
animations:
legacyGenerateAnimations: 4
bakeSimulation: 0
resampleCurves: 1
optimizeGameObjects: 0
motionNodeName:
rigImportErrors:
rigImportWarnings:
animationImportErrors:
animationImportWarnings:
animationRetargetingWarnings:
animationDoRetargetingWarnings: 0
importAnimatedCustomProperties: 0
importConstraints: 0
animationCompression: 1
animationRotationError: 0.5
animationPositionError: 0.5
animationScaleError: 0.5
animationWrapMode: 0
extraExposedTransformPaths: []
extraUserProperties: []
clipAnimations: []
isReadable: 1
meshes:
lODScreenPercentages: []
globalScale: 1
meshCompression: 0
addColliders: 0
useSRGBMaterialColor: 1
importVisibility: 1
importBlendShapes: 1
importCameras: 1
importLights: 1
swapUVChannels: 0
generateSecondaryUV: 0
useFileUnits: 1
optimizeMeshForGPU: 1
keepQuads: 0
weldVertices: 1
preserveHierarchy: 0
indexFormat: 0
secondaryUVAngleDistortion: 8
secondaryUVAreaDistortion: 15.000001
secondaryUVHardAngle: 88
secondaryUVPackMargin: 4
useFileScale: 1
previousCalculatedGlobalScale: 1
hasPreviousCalculatedGlobalScale: 0
tangentSpace:
normalSmoothAngle: 60
normalImportMode: 0
tangentImportMode: 3
normalCalculationMode: 4
legacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes: 0
blendShapeNormalImportMode: 1
normalSmoothingSource: 0
importAnimation: 1
copyAvatar: 0
humanDescription:
serializedVersion: 2
human: []
skeleton: []
armTwist: 0.5
foreArmTwist: 0.5
upperLegTwist: 0.5
legTwist: 0.5
armStretch: 0.05
legStretch: 0.05
feetSpacing: 0
rootMotionBoneName:
hasTranslationDoF: 0
hasExtraRoot: 0
skeletonHasParents: 1
lastHumanDescriptionAvatarSource: {instanceID: 0}
animationType: 0
humanoidOversampling: 1
additionalBone: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 3bad6245bcc5a2341b5278255b78be8d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,318 @@
#pragma warning disable 0414
/**
* Panorama180View.Panorama180View
* Equirectangular180VR.
*/
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Video;
using UnityEngine.Rendering;
namespace Panorama180View {
[RequireComponent(typeof(Camera))]
public class Panorama180View : MonoBehaviour
{
/**
* .
*/
public enum BackgroundType {
Image,
Video
}
/**
* .
*/
public enum PanoramaType {
Equirectangular360TopAndBottom,
Equirectangular180SideBySide,
FishEye180SideBySide
}
/**
* .
*/
public enum StateTransitionType {
None, // 状態遷移なし.
FadeIn, // フェードイン (フェードイン色 ==> image).
FadeOut, // フェードアウト (image ==> フェードアウト色).
Blend, // 静止画合成 (image ==> destinationImage).
}
[SerializeField] BackgroundType fileType = BackgroundType.Image; // 背景の種類.
[SerializeField] Texture2D image = null; // 背景画像のパノラマ.
[SerializeField] VideoClip video = null; // 背景動画のパノラマ.
[SerializeField] PanoramaType projectonType = PanoramaType.Equirectangular180SideBySide; // パノラマの種類.
[SerializeField, Range(1.0f, 10000.0f)] float radius = 500.0f; // 背景球の半径.
[SerializeField, Range(0.0f, 10.0f)] float intensity = 1.0f; // 明るさ.
private GameObject m_backgroundSphere = null; // 背景球.
private Material m_backgroundSphereMat = null; // 背景のマテリアル.
private GameObject m_videoG = null; // VideoClip用のGameObject.
private VideoPlayer m_videoPlayer = null; // Video再生用.
private GameObject m_audioSource = null; // Audioの発生源.
private RenderTexture m_renderTexture = null; // 1フレームのキャプチャ用.
//-------------------------------------------------.
// 以下、静止画の状態遷移用.
//-------------------------------------------------.
private StateTransitionType m_stateTransitionType = StateTransitionType.None; // 状態遷移の種類.
private Texture2D m_destinationImage; // 状態遷移時の静止画像.
private Color m_fadeInColor = Color.black; // フェイドインの色.
private Color m_fadeOutColor = Color.white; // フェイドアウトの色.
private float m_transitionStartTime = 0.0f; // 状態遷移の開始時間.
private float m_transitionInterval = 1.0f; // 状態遷移の時間間隔.
private bool m_inTransition = false; // 遷移中の場合true.
//-------------------------------------------------.
void Start () {
// 背景球を作成.
m_CreateBackgroundSphere();
// VideoPlayerの作成.
m_CreateVideoPlayer();
}
void Update () {
if (!m_UpdateTransition()) { // 状態遷移させる.
// 背景テクスチャを指定.
m_SetBackgroundTexture();
}
}
void OnDestroy () {
if (m_renderTexture != null) {
Destroy(m_renderTexture);
m_renderTexture = null;
}
if (m_videoG != null) {
GameObject.Destroy(m_videoG);
m_videoG = null;
}
if (m_audioSource != null) {
GameObject.Destroy(m_audioSource);
m_audioSource = null;
}
if (m_backgroundSphereMat != null) {
Destroy(m_backgroundSphereMat);
}
if (m_backgroundSphere != null) {
GameObject.Destroy(m_backgroundSphere);
}
}
/**
* .
*/
private void m_CreateBackgroundSphere () {
if (m_backgroundSphereMat == null) {
// 以下、ビルドして実行する時にShaderを読み込めるように
// Shader.FindではなくResources.Load<Shader>を使用している.
Shader shader = Resources.Load<Shader>("Shaders/panoramaSphereRendering");
m_backgroundSphereMat = new Material(shader);
}
if (m_backgroundSphere == null) {
Mesh mesh = Resources.Load<Mesh>("Objects/backgroundSphere_vr360");
m_backgroundSphere = new GameObject("panorama360Sphere");
MeshRenderer meshRenderer = m_backgroundSphere.AddComponent<MeshRenderer>();
MeshFilter meshFilter = m_backgroundSphere.AddComponent<MeshFilter>();
meshRenderer.shadowCastingMode = ShadowCastingMode.Off;
meshRenderer.receiveShadows = false;
meshRenderer.material = m_backgroundSphereMat;
meshFilter.mesh = mesh;
m_backgroundSphere.transform.localScale = new Vector3(radius, radius, radius);
m_backgroundSphere.transform.position = this.transform.position;
// Y軸中心の回転角度.
Quaternion currentCameraRot = this.transform.rotation;
float cRotY = currentCameraRot.eulerAngles.y;
m_backgroundSphere.transform.rotation = Quaternion.Euler(0, cRotY + 90, 0);
}
}
/**
* VideoPlayer.
*/
private void m_CreateVideoPlayer () {
// Audioソース用のGameObjectを作成.
// Audioは、指定のGameObjectを中心に音が鳴る.
if (m_audioSource == null) {
m_audioSource = new GameObject("AudioSource");
m_audioSource.transform.position = this.transform.position;
}
AudioSource audioSource = m_audioSource.AddComponent<AudioSource>();
// Video再生用のGameObjectを作成.
if (m_videoG == null) {
m_videoG = new GameObject("VideoPlayer");
//m_videoG.transform.parent = m_rootG.transform;
if (m_videoG.GetComponent<VideoPlayer>() == null) {
m_videoG.AddComponent<VideoPlayer>();
}
m_videoPlayer = m_videoG.GetComponent<VideoPlayer>();
m_videoPlayer.renderMode = VideoRenderMode.RenderTexture;
m_videoPlayer.isLooping = true;
m_videoPlayer.playOnAwake = true;
m_videoPlayer.waitForFirstFrame = true; // ソースVideoの最初のフレームが表示される状態になるまで待機する.
}
}
/**
* .
*/
private void m_SetBackgroundTexture () {
if (m_backgroundSphere == null || m_backgroundSphereMat == null) return;
if (fileType == BackgroundType.Image) {
// 静止画のパラメータを渡す.
m_backgroundSphere.SetActive(image != null);
m_videoG.SetActive(false);
m_audioSource.SetActive(false);
m_backgroundSphereMat.SetTexture("_MainTex", image);
m_backgroundSphereMat.SetFloat("_Intensity", intensity);
m_backgroundSphereMat.SetInt("_Mode", (int)projectonType);
m_backgroundSphereMat.SetInt("_TransitionType", 0);
} else {
// VideoClipのパラメータを渡す.
m_backgroundSphere.SetActive(video != null);
m_videoG.SetActive(video != null);
m_audioSource.SetActive(video != null);
if (m_videoPlayer == null) return;
if (m_renderTexture != null) {
if (video == null || (m_renderTexture.width != video.width || m_renderTexture.height != video.height)) {
if (m_renderTexture != null) {
Destroy(m_renderTexture);
m_renderTexture = null;
}
}
}
m_videoPlayer.clip = video;
if (video != null) {
int width = (int)video.width;
int height = (int)video.height;
if (m_renderTexture == null) {
m_renderTexture = new RenderTexture(width, height, 0, RenderTextureFormat.ARGB32);
m_videoPlayer.targetTexture = m_renderTexture;
{
AudioSource audioSource = m_audioSource.GetComponent<AudioSource>();
if (audioSource != null) {
m_videoPlayer.EnableAudioTrack(0, true);
m_videoPlayer.SetTargetAudioSource(0, audioSource);
}
}
}
if (m_renderTexture != null) {
m_backgroundSphereMat.SetTexture("_MainTex", m_renderTexture);
m_backgroundSphereMat.SetFloat("_Intensity", intensity);
m_backgroundSphereMat.SetInt("_Mode", (int)projectonType);
m_backgroundSphereMat.SetInt("_TransitionType", 0);
}
}
}
}
//-----------------------------------------------------------------.
// 静止画の場合の状態遷移用.
//-----------------------------------------------------------------.
/**
* Update.
*/
private bool m_UpdateTransition () {
if (m_stateTransitionType == StateTransitionType.None) return false;
if (fileType != BackgroundType.Image) return false;
float passTime = Time.time - m_transitionStartTime;
m_inTransition = (passTime < m_transitionInterval);
float tPos = passTime / m_transitionInterval;
tPos = Mathf.Clamp(tPos, 0.0f, 1.0f);
m_backgroundSphere.SetActive(image != null);
m_videoG.SetActive(false);
m_audioSource.SetActive(false);
m_backgroundSphereMat.SetTexture("_MainTex", image);
m_backgroundSphereMat.SetFloat("_Intensity", intensity);
m_backgroundSphereMat.SetInt("_Mode", (int)projectonType);
m_backgroundSphereMat.SetInt("_TransitionType", (int)m_stateTransitionType); // 状態遷移させるモード.
m_backgroundSphereMat.SetTexture("_DestTex", m_destinationImage);
m_backgroundSphereMat.SetFloat("_TPos", tPos);
m_backgroundSphereMat.SetVector("_FadeInColor", new Vector4(m_fadeInColor.r, m_fadeInColor.g, m_fadeInColor.b, 1.0f));
m_backgroundSphereMat.SetVector("_FadeOutColor", new Vector4(m_fadeOutColor.r, m_fadeOutColor.g, m_fadeOutColor.b, 1.0f));
return true;
}
//-----------------------------------------------------------------.
// 外部からアクセス.
//-----------------------------------------------------------------.
/**
* .
*/
public int GetVersion () { return 0x101; }
/**
* .
*/
public void SetStateTransition (StateTransitionType type) {
if (m_inTransition) return;
m_stateTransitionType = type;
m_transitionStartTime = Time.time;
}
/**
* Texture.
*/
public void SetSrcTexture (Texture2D tex) {
if (m_inTransition) return;
image = tex;
}
/**
* Texture.
*/
public void SetDestTexture (Texture2D tex) {
if (m_inTransition) return;
m_destinationImage = tex;
}
/**
* .
*/
public void SetFadeInColor (Color col) {
if (m_inTransition) return;
m_fadeInColor = col;
}
/**
* .
*/
public void SetFadeOutColor (Color col) {
if (m_inTransition) return;
m_fadeOutColor = col;
}
/**
* .
*/
public void SetTransitionInterval (float interval) {
if (m_inTransition) return;
m_transitionInterval = interval;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5be50d4c78681f94fa7eee0386219792
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,48 @@
//------------------------------------------------.
// Panorama180View
//------------------------------------------------.
[ How to use ] ----------------
Please turn on "Virtual Reality Supported" in "XR Settings" of "Project Settings".
1. Copy the "Panorama180View" folder to the project.
2. Added "Scripts/Panorama180View/Panorama180View" to the MainCamera component.
3. In the Inspector of MainCamera, specify the parameter of "Panorama180View".
File Type : Image or Video
Image : Still image
Video : Video Clip
ProjectionType : Equirectangular360TopAndBottom Place left eye / right eye equirectangular 360 degrees image on the top and bottom
Equirectangular180SideBySide Place left eye / right eye equirectangular 180 degrees image on the left and right
FishEye180SideBySide Place left eye / right eye fish eye 180 degrees image on the left and right
Radius : Background sphere radius
Intensity : Background brightness
[ 使い方 ] ----------------
"Project Settings"の"XR Settings"で"Virtual Reality Supported"をOnにして使用してください。
1. "Panorama180View"フォルダをプロジェクトにコピー。
2. MainCameraのコンポーネントに"Scripts/Panorama180View/Panorama180View"を追加。
3. MainCameraのInspectorで、"Panorama180View"のパラメータを指定。
File Type : Image(静止画像)/Vodeo(動画)
Image : 静止画のTexture
Video : 動画のVideo Clip
ProjectionType : Equirectangular360TopAndBottom 上下に左目/右目のEquirectangular360画像を配置
Equirectangular180SideBySide 左右に左目/右目のEquirectangular180画像を配置
FishEye180SideBySide 左右に左目/右目の魚眼180画像を配置
Radius : 背景球の半径
Intensity : 明るさ
[ Change Log ] ----------------
[03/13/2019]
- Added methods of state transition with panorama180 still image.
- Added sample scene "StateTransition".
[03/08/2019]
- first version

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 36363d4ad2b51704a955dd80cf2466da
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: d30b9a945a08543918f700fd6e5cd57e
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 25210524aed564f88a4f2745153ad79f
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,39 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.InputSystem;
public class OnButtonPress : MonoBehaviour
{
[Tooltip("Actions to check")]
public InputAction action = null;
// When the button is pressed
public UnityEvent OnPress = new UnityEvent();
private void Awake()
{
action.started += Pressed;
}
private void OnDestroy()
{
action.started -= Pressed;
}
private void OnEnable()
{
action.Enable();
}
private void OnDisable()
{
action.Disable();
}
private void Pressed(InputAction.CallbackContext context)
{
OnPress.Invoke();
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f3657284cbc344c10b72aff76116332b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,102 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO;
using UnityEngine.Networking;
public class PhotoTransition : MonoBehaviour
{
public List<string> imgPathList = null;
[SerializeField]
List<Texture2D> _imgList = new List<Texture2D>();
private Panorama180View.Panorama180View _panorama180View = null;
private int _state = 0;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
IEnumerator BlendImage(Texture2D srcImg, Texture2D destImg)
{
_panorama180View.SetSrcTexture(srcImg);
_panorama180View.SetDestTexture(destImg);
_panorama180View.SetTransitionInterval(2.0f);
_panorama180View.SetStateTransition(Panorama180View.Panorama180View.StateTransitionType.Blend);
yield return new WaitForSeconds(2);
}
public IEnumerator LoadNextImage()
{
if (_state < imgPathList.Count - 1)
{
yield return StartCoroutine(BlendImage(_imgList[_state], _imgList[_state + 1]));
_state++;
}
if (_imgList.Count < imgPathList.Count)
{
yield return StartCoroutine(ImageLoader(imgPathList[_state + 1]));
}
}
public bool IsSlideshowFinished()
{
if (_state == imgPathList.Count-1) return true;
return false;
}
public void Reset()
{
_imgList.Clear();
_state = 0;
}
public IEnumerator SetUp()
{
// Load first two images
for (int i = 0; i < 2; i++)
{
yield return StartCoroutine(ImageLoader(imgPathList[i]));
}
_panorama180View = this.GetComponent<Panorama180View.Panorama180View>();
_panorama180View.SetSrcTexture(_imgList[0]);
_panorama180View.SetTransitionInterval(2.0f);
_panorama180View.SetStateTransition(Panorama180View.Panorama180View.StateTransitionType.FadeIn);
}
IEnumerator ImageLoader(string path)
{
string imgPath = Path.Combine(Application.streamingAssetsPath, path);
imgPath = "file://" + imgPath; // For testing in editor
using (UnityWebRequest uwr = UnityWebRequestTexture.GetTexture(imgPath))
{
yield return uwr.SendWebRequest();
if (uwr.result != UnityWebRequest.Result.Success)
{
Debug.Log(uwr.error);
}
else
{
Texture2D tex = DownloadHandlerTexture.GetContent(uwr);
_imgList.Add(tex);
}
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0f6672e37ce3d4ed9915e5766be6fa61
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: a48f0d3fb3f0142318353e12ca0153e8
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c4e2c37d42f614521ab25c2e722b8c18
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 MiB

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: be1106f0c2add453d93a76eb15c5e86f
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 MiB

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 30757dc81dd964d269beda18a3f63003
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 MiB

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: e438032979ef740508c32bd4e4304788
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 MiB

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 6151f6d8480154c7895ec28ded2c68c0
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 MiB

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 698877680d23e46d58fd7d678938f7a0
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: