forked from cgvr/DeltaVR
more wires to archery range, connecting buttons
This commit is contained in:
Binary file not shown.
BIN
Assets/_PROJECT/Scenes/MicrophoneTestScene.unity
LFS
Normal file
BIN
Assets/_PROJECT/Scenes/MicrophoneTestScene.unity
LFS
Normal file
Binary file not shown.
7
Assets/_PROJECT/Scenes/MicrophoneTestScene.unity.meta
Normal file
7
Assets/_PROJECT/Scenes/MicrophoneTestScene.unity.meta
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: df6aa17c908f8814a8a7abe743fdd28a
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -20,11 +20,14 @@ public class ArcheryRangeModelGenerationController : MonoBehaviour
|
|||||||
public Transform wire;
|
public Transform wire;
|
||||||
public Material wireActiveMaterial;
|
public Material wireActiveMaterial;
|
||||||
|
|
||||||
|
private bool modelGenerationInProgress;
|
||||||
|
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
imageGenerationButton.OnButtonPressed += InvokeImageGeneration;
|
imageGenerationButton.OnButtonPressed += InvokeImageGeneration;
|
||||||
modelGenerationButton.OnButtonPressed += InvokeModelGeneration;
|
modelGenerationButton.OnButtonPressed += InvokeModelGeneration;
|
||||||
|
modelGenerationInProgress = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
@@ -47,11 +50,16 @@ public class ArcheryRangeModelGenerationController : MonoBehaviour
|
|||||||
Sprite sprite = CreateSprite(GeneratedTexture);
|
Sprite sprite = CreateSprite(GeneratedTexture);
|
||||||
imageDisplay.sprite = sprite;
|
imageDisplay.sprite = sprite;
|
||||||
|
|
||||||
imageGenerationButton.MoveButtonUp();
|
imageGenerationButton.Deactivate();
|
||||||
|
if (!modelGenerationInProgress)
|
||||||
|
{
|
||||||
|
modelGenerationButton.Deactivate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void InvokeModelGeneration()
|
private async void InvokeModelGeneration()
|
||||||
{
|
{
|
||||||
|
modelGenerationInProgress = true;
|
||||||
string encodedTexture = Convert.ToBase64String(GeneratedTexture.EncodeToJPG());
|
string encodedTexture = Convert.ToBase64String(GeneratedTexture.EncodeToJPG());
|
||||||
byte[] encodedModel = await TrellisClient.Instance.GenerateModel(encodedTexture);
|
byte[] encodedModel = await TrellisClient.Instance.GenerateModel(encodedTexture);
|
||||||
|
|
||||||
@@ -63,7 +71,8 @@ public class ArcheryRangeModelGenerationController : MonoBehaviour
|
|||||||
GeneratedModel = spawnedObject;
|
GeneratedModel = spawnedObject;
|
||||||
|
|
||||||
OnModelReady();
|
OnModelReady();
|
||||||
modelGenerationButton.MoveButtonUp();
|
modelGenerationButton.Deactivate();
|
||||||
|
modelGenerationInProgress = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Texture2D CreateTexture(byte[] imageBytes)
|
private Texture2D CreateTexture(byte[] imageBytes)
|
||||||
|
|||||||
@@ -8,9 +8,14 @@ public class PushableButton : MonoBehaviour
|
|||||||
public event OnButtonPressedDelegate OnButtonPressed;
|
public event OnButtonPressedDelegate OnButtonPressed;
|
||||||
|
|
||||||
|
|
||||||
|
public bool startDown;
|
||||||
public Transform movableParts;
|
public Transform movableParts;
|
||||||
public float moveDuration = 0.25f;
|
public float moveDuration = 0.25f;
|
||||||
|
|
||||||
|
public Transform wire;
|
||||||
|
public Material wireActiveMaterial;
|
||||||
|
public Material wireInactiveMaterial;
|
||||||
|
|
||||||
private float upPositionY;
|
private float upPositionY;
|
||||||
private float downPositionY;
|
private float downPositionY;
|
||||||
private bool isButtonDown;
|
private bool isButtonDown;
|
||||||
@@ -25,7 +30,12 @@ public class PushableButton : MonoBehaviour
|
|||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start()
|
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
|
// Update is called once per frame
|
||||||
@@ -38,15 +48,30 @@ public class PushableButton : MonoBehaviour
|
|||||||
{
|
{
|
||||||
if (!isButtonDown && collision.gameObject.tag.EndsWith("Hand"))
|
if (!isButtonDown && collision.gameObject.tag.EndsWith("Hand"))
|
||||||
{
|
{
|
||||||
movableParts.DOLocalMoveY(downPositionY, moveDuration);
|
Activate();
|
||||||
isButtonDown = true;
|
|
||||||
OnButtonPressed?.Invoke();
|
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);
|
movableParts.DOLocalMoveY(upPositionY, moveDuration);
|
||||||
isButtonDown = false;
|
isButtonDown = false;
|
||||||
|
|
||||||
|
foreach (MeshRenderer meshRenderer in wire.GetComponentsInChildren<MeshRenderer>())
|
||||||
|
{
|
||||||
|
meshRenderer.material = wireInactiveMaterial;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user