1
0
forked from cgvr/DeltaVR

set up shape detection minigame pieces

This commit is contained in:
2026-01-13 16:06:13 +02:00
parent d2ac917db3
commit 3097c404ba
11 changed files with 149 additions and 75 deletions

View File

@@ -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;
}
}