Assignment for RMIT Mixed Reality in 2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.3 KiB

  1. /************************************************************************************
  2. Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved.
  3. See SampleFramework license.txt for license terms. Unless required by applicable law
  4. or agreed to in writing, the sample code is provided AS IS WITHOUT WARRANTIES OR
  5. CONDITIONS OF ANY KIND, either express or implied. See the license for specific
  6. language governing permissions and limitations under the license.
  7. ************************************************************************************/
  8. using System.Collections;
  9. using System.Collections.Generic;
  10. using UnityEngine;
  11. using UnityEngine.UI;
  12. namespace OculusSampleFramework
  13. {
  14. public class DistanceGrabberSample : MonoBehaviour
  15. {
  16. bool useSpherecast = false;
  17. bool allowGrabThroughWalls = false;
  18. public bool UseSpherecast
  19. {
  20. get { return useSpherecast; }
  21. set
  22. {
  23. useSpherecast = value;
  24. for (int i = 0; i < m_grabbers.Length; ++i)
  25. {
  26. m_grabbers[i].UseSpherecast = useSpherecast;
  27. }
  28. }
  29. }
  30. public bool AllowGrabThroughWalls
  31. {
  32. get { return allowGrabThroughWalls; }
  33. set
  34. {
  35. allowGrabThroughWalls = value;
  36. for (int i = 0; i < m_grabbers.Length; ++i)
  37. {
  38. m_grabbers[i].m_preventGrabThroughWalls = !allowGrabThroughWalls;
  39. }
  40. }
  41. }
  42. [SerializeField]
  43. DistanceGrabber[] m_grabbers = null;
  44. // Use this for initialization
  45. void Start()
  46. {
  47. DebugUIBuilder.instance.AddLabel("Distance Grab Sample");
  48. DebugUIBuilder.instance.AddToggle("Use Spherecasting", ToggleSphereCasting, useSpherecast);
  49. DebugUIBuilder.instance.AddToggle("Grab Through Walls", ToggleGrabThroughWalls, allowGrabThroughWalls);
  50. DebugUIBuilder.instance.Show();
  51. }
  52. public void ToggleSphereCasting(Toggle t)
  53. {
  54. UseSpherecast = !UseSpherecast;
  55. }
  56. public void ToggleGrabThroughWalls(Toggle t)
  57. {
  58. AllowGrabThroughWalls = !AllowGrabThroughWalls;
  59. }
  60. }
  61. }