Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void start(){
- objmark = this.gameObject;
- }
- void Update () {
- if (_isRendered) {
- if (Input.GetKeyDown (KeyCode.Return)) {
- objRelative = objmark.transform.position;
- objRelative.z = 0;
- WebCamController.marktra.Add (objRelative);
- WebCamController.markkind.Add ("GO");
- RobotController.CodeList.Add("A");
- RobotController.CodeList.Add(pos2);
- Debug.Log ("success A");
- Debug.Log (pos2);
- }
- }
- _isRendered = false;
- }
- }
- public class WebCamController : MonoBehaviour
- {
- public static List<Vector3> marktra = new List<Vector3>();
- public static List<string> markkind = new List<string>();
- public int Width = 1920;
- public int Height = 1080;
- public int FPS = 30;
- GameObject ARCamera,childmark;
- // Use this for initialization
- void Start()
- {
- var devices = WebCamTexture.devices;
- if ( devices.Length == 0 ) {
- Debug.LogError( "Webカメラが検出できませんでした。" );
- return;
- }
- // WebCamテクスチャを作成する
- var webcamTexture = new WebCamTexture( Width, Height, FPS );
- GetComponent<Renderer>().material.mainTexture = webcamTexture;
- webcamTexture.Play();
- }
- // Update is called once per frame
- void Update()
- {
- if(marktra[0] != null){
- for (int i = 0; i < marktra.Count; i++) {
- GameObject objcube = new GameObject();
- if (markkind [i] == "GO") {
- objcube = GameObject.Find ("GoCube");
- objcube.transform.position = marktra[i];
- } else if (markkind [i] == "TURN") {
- }
- }
- }
- }
- }
- public class RobotController : MonoBehaviour {
- public static List<string> CodeList = new List<string>();
- public static SerialPort sp = new SerialPort("COM3",9600);
- private bool _isRendered = false;
- // Use this for initialization
- void Start () {
- if (sp.IsOpen) {
- } else {
- OpenConnection ();
- }
- }
- // Update is called once per frame
- void Update () {
- if (_isRendered) {
- if (Input.GetKeyDown (KeyCode.Return)) {
- for (int i = 0; i < CodeList.Count; i++) {
- sp.Write (CodeList[i]);
- Debug.Log (CodeList[i]);
- }
- sp.Write ("X");
- Debug.Log ("success X");
- for (int i = 0; i < CodeList.Count; i++) {
- CodeList.RemoveAt(i);
- }
- }
- }
- _isRendered = false;
- }
- }
Add Comment
Please, Sign In to add comment