Basic working prefab

This commit is contained in:
Momo The Monster
2023-02-15 00:31:34 -08:00
commit f358512f17
165 changed files with 9682 additions and 0 deletions

View File

@@ -0,0 +1,72 @@
using UdonSharp;
using UnityEngine;
using UnityEngine.UI;
using VRC.SDK3.Image;
using VRC.SDK3.StringLoading;
using VRC.SDKBase;
using VRC.Udon;
public class FrameDataLoader : UdonSharpBehaviour
{
private VRCImageDownloader _imageDownloader;
public UdonBehaviour udonEventReceiver;
public VRCUrl[] rgbUrl;
public VRCUrl[] stringUrl;
public Renderer renderer;
public Text field;
public float photoDurationSeconds = 10f;
private int _loadedIndex = -1;
void Start()
{
_imageDownloader = new VRCImageDownloader();
LoadNextRecursive();
}
public void LoadNextRecursive()
{
LoadNext();
SendCustomEventDelayedSeconds(nameof(LoadNextRecursive), photoDurationSeconds);
}
private void LoadNext()
{
// _loadedIndex++;
// if(_loadedIndex >= rgbUrl.Length)
// {
// _loadedIndex = 0;
// }
_loadedIndex = (int)(Networking.GetServerTimeInMilliseconds() / 1000f / photoDurationSeconds) % rgbUrl.Length;
var rgbInfo = new TextureInfo();
rgbInfo.WrapModeU = TextureWrapMode.Mirror;
rgbInfo.WrapModeV = TextureWrapMode.Mirror;
_imageDownloader.DownloadImage(rgbUrl[_loadedIndex], renderer.material, udonEventReceiver, rgbInfo);
VRCStringDownloader.LoadUrl(stringUrl[_loadedIndex], udonEventReceiver);
}
public override void OnStringLoadSuccess(IVRCStringDownload result)
{
field.text = result.Result;
}
public override void OnStringLoadError(IVRCStringDownload result)
{
Debug.LogError($"Could not load string {result.Error}");
}
public override void OnImageLoadSuccess(IVRCImageDownload result)
{
Debug.Log($"Image loaded: {result.SizeInMemoryBytes} bytes.");
}
public override void OnImageLoadError(IVRCImageDownload result)
{
Debug.Log($"Image not loaded: {result.Error.ToString()}: {result.ErrorMessage}.");
}
private void OnDestroy()
{
_imageDownloader.Dispose();
}
}