Guest User

Untitled

a guest
Jan 17th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.71 KB | None | 0 0
  1. void start(){
  2. objmark = this.gameObject;
  3. }
  4.  
  5. void Update () {
  6. if (_isRendered) {
  7. if (Input.GetKeyDown (KeyCode.Return)) {
  8. objRelative = objmark.transform.position;
  9. objRelative.z = 0;
  10. WebCamController.marktra.Add (objRelative);
  11. WebCamController.markkind.Add ("GO");
  12. RobotController.CodeList.Add("A");
  13. RobotController.CodeList.Add(pos2);
  14. Debug.Log ("success A");
  15. Debug.Log (pos2);
  16. }
  17. }
  18. _isRendered = false;
  19. }
  20. }
  21.  
  22. public class WebCamController : MonoBehaviour
  23. {
  24. public static List<Vector3> marktra = new List<Vector3>();
  25. public static List<string> markkind = new List<string>();
  26. public int Width = 1920;
  27. public int Height = 1080;
  28. public int FPS = 30;
  29. GameObject ARCamera,childmark;
  30.  
  31. // Use this for initialization
  32. void Start()
  33. {
  34. var devices = WebCamTexture.devices;
  35. if ( devices.Length == 0 ) {
  36. Debug.LogError( "Webカメラが検出できませんでした。" );
  37. return;
  38. }
  39.  
  40. // WebCamテクスチャを作成する
  41. var webcamTexture = new WebCamTexture( Width, Height, FPS );
  42. GetComponent<Renderer>().material.mainTexture = webcamTexture;
  43. webcamTexture.Play();
  44. }
  45.  
  46. // Update is called once per frame
  47. void Update()
  48. {
  49. if(marktra[0] != null){
  50. for (int i = 0; i < marktra.Count; i++) {
  51. GameObject objcube = new GameObject();
  52. if (markkind [i] == "GO") {
  53. objcube = GameObject.Find ("GoCube");
  54. objcube.transform.position = marktra[i];
  55. } else if (markkind [i] == "TURN") {
  56. }
  57. }
  58. }
  59. }
  60. }
  61.  
  62. public class RobotController : MonoBehaviour {
  63. public static List<string> CodeList = new List<string>();
  64. public static SerialPort sp = new SerialPort("COM3",9600);
  65. private bool _isRendered = false;
  66.  
  67. // Use this for initialization
  68. void Start () {
  69. if (sp.IsOpen) {
  70. } else {
  71. OpenConnection ();
  72. }
  73. }
  74.  
  75. // Update is called once per frame
  76. void Update () {
  77. if (_isRendered) {
  78. if (Input.GetKeyDown (KeyCode.Return)) {
  79. for (int i = 0; i < CodeList.Count; i++) {
  80. sp.Write (CodeList[i]);
  81. Debug.Log (CodeList[i]);
  82. }
  83. sp.Write ("X");
  84. Debug.Log ("success X");
  85. for (int i = 0; i < CodeList.Count; i++) {
  86. CodeList.RemoveAt(i);
  87. }
  88. }
  89. }
  90. _isRendered = false;
  91. }
  92.  
  93.  
  94. }
Add Comment
Please, Sign In to add comment