forked from cgvr/DeltaVR
computer screen shows text, pressing enter key prints out image
This commit is contained in:
@@ -115,11 +115,11 @@ public class ShapeDetectionNPC : NPCController
|
||||
|
||||
private async void OnPlayerPressedKeyboard()
|
||||
{
|
||||
string inputPrompt = microphoneStand.GetTextOutput();
|
||||
byte[] imageBytes = await InvokeAiClient.Instance.GenerateImage(inputPrompt);
|
||||
GeneratedTexture = ModelGenerationUtils.CreateTexture(imageBytes);
|
||||
Sprite sprite = ModelGenerationUtils.CreateSprite(GeneratedTexture);
|
||||
imageDisplay.sprite = sprite;
|
||||
//string inputPrompt = microphoneStand.GetTextOutput();
|
||||
//byte[] imageBytes = await InvokeAiClient.Instance.GenerateImage(inputPrompt);
|
||||
//GeneratedTexture = ModelGenerationUtils.CreateTexture(imageBytes);
|
||||
//Sprite sprite = ModelGenerationUtils.CreateSprite(GeneratedTexture);
|
||||
//imageDisplay.sprite = sprite;
|
||||
|
||||
imageGenerationButton.Deactivate();
|
||||
if (state == 3)
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
using DG.Tweening;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class ComputerPrinter : MonoBehaviour
|
||||
{
|
||||
public TextMeshProUGUI textDisplay;
|
||||
public PushableButton enterKey;
|
||||
public Transform ejectionOrigin;
|
||||
public Transform ejectionDestination;
|
||||
public GameObject printablePrefab;
|
||||
public float ejectionDuration = 1.0f;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
enterKey.OnButtonPressed += PrintImage;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private async void PrintImage()
|
||||
{
|
||||
string inputPrompt = textDisplay.text;
|
||||
byte[] imageBytes = await InvokeAiClient.Instance.GenerateImage(inputPrompt);
|
||||
Texture2D generatedTexture = ModelGenerationUtils.CreateTexture(imageBytes);
|
||||
Sprite sprite = ModelGenerationUtils.CreateSprite(generatedTexture);
|
||||
|
||||
GameObject printable = Instantiate(printablePrefab, ejectionOrigin.position, Quaternion.identity);
|
||||
Image printableDisplay = printable.GetComponentInChildren<Image>();
|
||||
printableDisplay.sprite = sprite;
|
||||
|
||||
printable.transform.DOMove(ejectionDestination.position, ejectionDuration).OnComplete(() =>
|
||||
{
|
||||
Rigidbody printableRigidbody = printable.GetComponent<Rigidbody>();
|
||||
printableRigidbody.isKinematic = false;
|
||||
enterKey.Deactivate();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 61da8777d60372649a52316cac583c10
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user