44 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			44 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| using System.Collections;
 | |
| using System.Collections.Generic;
 | |
| using UnityEngine;
 | |
| using UnityEngine.UI;
 | |
| using UnityEngine.XR.Interaction.Toolkit;
 | |
| 
 | |
| public class ContinuoslocomotionConfigurator : MonoBehaviour
 | |
| {
 | |
|     public Button turnOffButton;
 | |
|     public Button turnOnButton;
 | |
|     public ContinuousMoveProviderBase locomotion;
 | |
| 
 | |
| 
 | |
|     // Start is called before the first frame update
 | |
|     void Start()
 | |
|     {
 | |
|         turnOnButton.onClick.AddListener(enableLocomotion);
 | |
|         turnOffButton.onClick.AddListener(disableLocomotion);
 | |
|         turnOffButton.gameObject.SetActive(false); // off by default
 | |
|     }
 | |
|     public void UpdateSpeed(float speed)
 | |
|     {
 | |
|         locomotion.moveSpeed = speed;
 | |
|     }
 | |
| 
 | |
|     private void enableLocomotion()
 | |
|     {
 | |
|         AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.Click, gameObject);  //3d oneshot sound
 | |
|         locomotion.enabled = true;
 | |
|         turnOnButton.gameObject.SetActive(false);
 | |
|         turnOffButton.gameObject.SetActive(true);
 | |
|     }
 | |
| 
 | |
|     private void disableLocomotion()
 | |
|     {
 | |
|         AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.Click, gameObject);  //3d oneshot sound
 | |
|         locomotion.enabled = false;
 | |
|         turnOnButton.gameObject.SetActive(true);
 | |
|         turnOffButton.gameObject.SetActive(false);
 | |
|     }
 | |
| 
 | |
| 
 | |
| }
 |