2
0

SteamVR_ActivateActionSetOnLoad.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. //======= Copyright (c) Valve Corporation, All rights reserved. ===============
  2. using UnityEngine;
  3. using System.Collections;
  4. namespace Valve.VR
  5. {
  6. /// <summary>
  7. /// Automatically activates an action set on Start() and deactivates the set on OnDestroy(). Optionally deactivating all other sets as well.
  8. /// </summary>
  9. public class SteamVR_ActivateActionSetOnLoad : MonoBehaviour
  10. {
  11. public SteamVR_ActionSet actionSet = SteamVR_Input.GetActionSet("default");
  12. public SteamVR_Input_Sources forSources = SteamVR_Input_Sources.Any;
  13. public bool disableAllOtherActionSets = false;
  14. public bool activateOnStart = true;
  15. public bool deactivateOnDestroy = true;
  16. private void Start()
  17. {
  18. if (actionSet != null && activateOnStart)
  19. {
  20. //Debug.Log(string.Format("[SteamVR] Activating {0} action set.", actionSet.fullPath));
  21. actionSet.Activate(forSources, 0, disableAllOtherActionSets);
  22. }
  23. }
  24. private void OnDestroy()
  25. {
  26. if (actionSet != null && deactivateOnDestroy)
  27. {
  28. //Debug.Log(string.Format("[SteamVR] Deactivating {0} action set.", actionSet.fullPath));
  29. actionSet.Deactivate(forSources);
  30. }
  31. }
  32. }
  33. }