forked from cgvr/DeltaVR
can insert printable into 3d printer, 3d printer starts printing
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
using DG.Tweening;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class ComputerPrinter : MonoBehaviour
|
||||
{
|
||||
@@ -9,8 +8,9 @@ public class ComputerPrinter : MonoBehaviour
|
||||
public PushableButton enterKey;
|
||||
public Transform ejectionOrigin;
|
||||
public Transform ejectionDestination;
|
||||
public GameObject printablePrefab;
|
||||
public Printable printablePrefab;
|
||||
public float ejectionDuration = 1.0f;
|
||||
public int ignorePlayerCollisionLayer = 2;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
@@ -29,11 +29,14 @@ public class ComputerPrinter : MonoBehaviour
|
||||
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 printable = Instantiate(printablePrefab, ejectionOrigin.position, Quaternion.identity);
|
||||
printable.AttachTexture(generatedTexture);
|
||||
printable.gameObject.layer = ignorePlayerCollisionLayer;
|
||||
foreach (Transform childTrans in printable.transform.GetComponentInChildren<Transform>())
|
||||
{
|
||||
childTrans.gameObject.layer = ignorePlayerCollisionLayer;
|
||||
}
|
||||
|
||||
printable.transform.DOMove(ejectionDestination.position, ejectionDuration).OnComplete(() =>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user