forked from cgvr/DeltaVR
set up shape detection minigame pieces
This commit is contained in:
@@ -44,40 +44,12 @@ void Start()
|
||||
meshRenderer.material = loadingMaterial;
|
||||
|
||||
byte[] imageBytes = await InvokeAiClient.Instance.GenerateImage(refinedPrompt);
|
||||
LastTexture = CreateTexture(imageBytes);
|
||||
Sprite sprite = CreateSprite(LastTexture);
|
||||
LastTexture = ModelGenerationUtils.CreateTexture(imageBytes);
|
||||
Sprite sprite = ModelGenerationUtils.CreateSprite(LastTexture);
|
||||
imageDisplay.sprite = sprite;
|
||||
|
||||
isLoading = false;
|
||||
meshRenderer.material = inactiveMaterial;
|
||||
}
|
||||
}
|
||||
|
||||
private Texture2D CreateTexture(byte[] imageBytes)
|
||||
{
|
||||
var tex = new Texture2D(2, 2, TextureFormat.RGBA32, false);
|
||||
// ImageConversion.LoadImage returns bool (true = success)
|
||||
if (!ImageConversion.LoadImage(tex, imageBytes, markNonReadable: false))
|
||||
{
|
||||
Destroy(tex);
|
||||
throw new InvalidOperationException("Failed to decode image bytes into Texture2D.");
|
||||
}
|
||||
|
||||
tex.filterMode = FilterMode.Bilinear;
|
||||
tex.wrapMode = TextureWrapMode.Clamp;
|
||||
|
||||
return tex;
|
||||
}
|
||||
|
||||
private Sprite CreateSprite(Texture2D tex)
|
||||
{
|
||||
var sprite = Sprite.Create(
|
||||
tex,
|
||||
new Rect(0, 0, tex.width, tex.height),
|
||||
new Vector2(0.5f, 0.5f),
|
||||
pixelsPerUnit: 100f
|
||||
);
|
||||
|
||||
return sprite;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user