Advertisement
Guest User

Untitled

a guest
May 27th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class DrawLineManager : MonoBehaviour {
  6.  
  7. public Material lMat;
  8.  
  9. public SteamVR_TrackedObject trackedObject;
  10.  
  11. private MeshLineRenderer currLine;
  12.  
  13. private int numClicks = 0;
  14.  
  15. void Update () {
  16. SteamVR_Controller.Device device = SteamVR_Controller.Input((int)trackedObject.index);
  17.  
  18. if (device.GetTouchDown (SteamVR_Controller.ButtonMask.Trigger)) {
  19. GameObject go = new GameObject ();
  20. currLine = go.AddComponent<MeshLineRenderer> ();
  21.  
  22. currLine.lmat = new Material (lMat);
  23. currLine.setWidth (0.1f);
  24.  
  25. numClicks = 0;
  26.  
  27. } else if (device.GetTouch(SteamVR_Controller.ButtonMask.Trigger)) {
  28. currLine.AddPoint (trackedObject.transform.position);
  29. numClicks++;
  30. } else if (device.GetTouchUp(SteamVR_Controller.ButtonMask.Trigger)) {
  31. numClicks = 0;
  32. currLine = null;
  33. }
  34.  
  35. if (currLine != null) {
  36. // currLine.lmat.color = ColorManager.Instance.GetCurrentColor ();
  37. }
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement