2024-04-10 09:44:23 +02:00
|
|
|
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();
|
2024-05-06 16:53:42 +02:00
|
|
|
if (photoTransition == null || photoTransition.imgPathList.Count == 0)
|
|
|
|
{
|
|
|
|
return "ImgsNotDefined";
|
|
|
|
}
|
2024-04-10 09:44:23 +02:00
|
|
|
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;
|
2024-04-18 14:47:46 +02:00
|
|
|
public float totalTime = 5.0f;
|
2024-04-10 09:44:23 +02:00
|
|
|
|
|
|
|
public override void Run(NodeState nodeState)
|
|
|
|
{
|
|
|
|
switch (nodeState)
|
|
|
|
{
|
|
|
|
case NodeState.FirstRun:
|
|
|
|
photoTransition.Reset();
|
2024-04-18 14:47:46 +02:00
|
|
|
_timeLeft = totalTime;
|
2024-04-10 09:44:23 +02:00
|
|
|
StartCoroutine(photoTransition.SetUp());
|
|
|
|
break;
|
|
|
|
case NodeState.Running:
|
|
|
|
_timeLeft -= Time.deltaTime;
|
|
|
|
if (_timeLeft < 0)
|
|
|
|
{
|
|
|
|
StartCoroutine(photoTransition.LoadNextImage());
|
2024-04-18 14:47:46 +02:00
|
|
|
_timeLeft = totalTime;
|
2024-04-10 09:44:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (photoTransition.IsSlideshowFinished())
|
|
|
|
{
|
|
|
|
Task.SetSucceeded();
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
case NodeState.Aborting:
|
|
|
|
photoTransition.Reset();
|
2024-04-18 14:47:46 +02:00
|
|
|
_timeLeft = totalTime;
|
2024-04-10 09:44:23 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|