76 lines
2.2 KiB
C#
76 lines
2.2 KiB
C#
|
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;
|
||
|
}
|
||
|
}
|
||
|
}
|