1
0
forked from cgvr/DeltaVR

more wires to archery range, connecting buttons

This commit is contained in:
2026-01-11 14:47:39 +02:00
parent a23f40787e
commit 991f7d73b9
5 changed files with 52 additions and 8 deletions

Binary file not shown.

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: df6aa17c908f8814a8a7abe743fdd28a
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -20,11 +20,14 @@ public class ArcheryRangeModelGenerationController : MonoBehaviour
public Transform wire;
public Material wireActiveMaterial;
private bool modelGenerationInProgress;
// Start is called before the first frame update
void Start()
{
imageGenerationButton.OnButtonPressed += InvokeImageGeneration;
modelGenerationButton.OnButtonPressed += InvokeModelGeneration;
modelGenerationInProgress = false;
}
// Update is called once per frame
@@ -47,11 +50,16 @@ public class ArcheryRangeModelGenerationController : MonoBehaviour
Sprite sprite = CreateSprite(GeneratedTexture);
imageDisplay.sprite = sprite;
imageGenerationButton.MoveButtonUp();
imageGenerationButton.Deactivate();
if (!modelGenerationInProgress)
{
modelGenerationButton.Deactivate();
}
}
private async void InvokeModelGeneration()
{
modelGenerationInProgress = true;
string encodedTexture = Convert.ToBase64String(GeneratedTexture.EncodeToJPG());
byte[] encodedModel = await TrellisClient.Instance.GenerateModel(encodedTexture);
@@ -63,7 +71,8 @@ public class ArcheryRangeModelGenerationController : MonoBehaviour
GeneratedModel = spawnedObject;
OnModelReady();
modelGenerationButton.MoveButtonUp();
modelGenerationButton.Deactivate();
modelGenerationInProgress = false;
}
private Texture2D CreateTexture(byte[] imageBytes)

View File

@@ -8,9 +8,14 @@ public class PushableButton : MonoBehaviour
public event OnButtonPressedDelegate OnButtonPressed;
public bool startDown;
public Transform movableParts;
public float moveDuration = 0.25f;
public Transform wire;
public Material wireActiveMaterial;
public Material wireInactiveMaterial;
private float upPositionY;
private float downPositionY;
private bool isButtonDown;
@@ -25,7 +30,12 @@ public class PushableButton : MonoBehaviour
// Start is called before the first frame update
void Start()
{
if (startDown)
{
// Dont call Activate, we dont want to change wire material here
movableParts.DOLocalMoveY(downPositionY, moveDuration);
isButtonDown = true;
}
}
// Update is called once per frame
@@ -38,15 +48,30 @@ public class PushableButton : MonoBehaviour
{
if (!isButtonDown && collision.gameObject.tag.EndsWith("Hand"))
{
movableParts.DOLocalMoveY(downPositionY, moveDuration);
isButtonDown = true;
Activate();
OnButtonPressed?.Invoke();
}
}
public void MoveButtonUp()
private void Activate()
{
movableParts.DOLocalMoveY(downPositionY, moveDuration);
isButtonDown = true;
foreach (MeshRenderer meshRenderer in wire.GetComponentsInChildren<MeshRenderer>())
{
meshRenderer.material = wireActiveMaterial;
}
}
public void Deactivate()
{
movableParts.DOLocalMoveY(upPositionY, moveDuration);
isButtonDown = false;
foreach (MeshRenderer meshRenderer in wire.GetComponentsInChildren<MeshRenderer>())
{
meshRenderer.material = wireInactiveMaterial;
}
}
}