1
This commit is contained in:
37
Unity/Scripts/UX/Components/UXDataComponents/QRBuilder.cs
Normal file
37
Unity/Scripts/UX/Components/UXDataComponents/QRBuilder.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using BITKit;
|
||||
using BITKit.UX;
|
||||
using UnityEngine.Networking;
|
||||
namespace BITKit.UX.Components
|
||||
{
|
||||
[System.Serializable]
|
||||
public class QRBuilder : StringComponent
|
||||
{
|
||||
public TranslateSO so;
|
||||
public UXImage image;
|
||||
public InitializationState state;
|
||||
protected override async void OnSet(string value)
|
||||
{
|
||||
state = InitializationState.Initializing;
|
||||
var url = so.Get(value);
|
||||
using (var request = UnityWebRequestTexture.GetTexture(url))
|
||||
{
|
||||
Debug.Log(url);
|
||||
await request.SendWebRequest();
|
||||
BITApp.CancellationTokenSource.Token.ThrowIfCancellationRequested();
|
||||
if (request.result is UnityWebRequest.Result.Success)
|
||||
{
|
||||
var texture = DownloadHandlerTexture.GetContent(request);
|
||||
image.Set(texture);
|
||||
state = InitializationState.Initialized;
|
||||
}
|
||||
else
|
||||
{
|
||||
state = InitializationState.None;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user