2015-05-29 12 views
-4

Мне нужен мой сценарий, чтобы перейти к следующей камере каждый раз, когда я нажимаю кнопку на моем Arduino, я просто не могу заставить ее работать, может кто-нибудь мне помочь?UNIDUINO HELP SWITCH CAMERA

У меня есть Arduino, общающийся с Anity, но я просто не могу опустить голову вокруг переключающей части камеры.

Может кто подскажет, как сделать кнопку пресс хмель к следующей камере, так что мне нужно 1 кнопка только, чтобы показать все камеры

using UnityEngine; 
using System.Collections; 
using Uniduino; 

#if (UNITY_3_0 || UNITY_3_0_0 || UNITY_3_1 || UNITY_3_2 || UNITY_3_3 || UNITY_3_4 || UNITY_3_5)  
public class DigitalRead : Uniduino.Examples.DigitalRead { } // for unity 3.x 
#endif 

namespace Uniduino.Examples 
{ 

    public class digitalread2 : MonoBehaviour { 

     public Arduino arduino; 

     public int pin = 2; 
     public int pinValue; 
     public int testLed = 11; 
     public int licht; 
     public int enable; 
     public int val = 0; 
     public GameObject cam1; 
     public GameObject cam2; 
     void Start() 
     { 
      arduino = Arduino.global; 
      arduino.Log = (s) => Debug.Log("Arduino: " +s); 
      arduino.Setup(ConfigurePins); 

      cam1 = GameObject.Find ("cam1"); 


     } 

     void ConfigurePins() 
     { 
      arduino.pinMode(pin, PinMode.INPUT); 
      arduino.reportDigital((byte)(pin/8), 1); 
      // set the pin mode for the test LED on your board, pin 13 on an Arduino Uno 
      arduino.pinMode(testLed, PinMode.OUTPUT); 

    } 


     void Update() 
     { 
      // read the value from the digital input 
      enable = arduino.digitalRead (pin); 
      licht = arduino.digitalRead (pin); 
      pinValue = arduino.digitalRead(pin); 
      // apply that value to the test LED 
      arduino.digitalWrite(testLed,pinValue); 
      Debug.Log(pinValue); 

      val = arduino.digitalRead (pin); 

      arduino.digitalWrite (testLed, val); 
      val = cam1.active = false; 

      val = cam2.active = true; 



     } 
    } 
} 

ответ

0

GameObject cam1, cam2; 
 
void Start(){ 
 
    cam1 = Find("camera_name"); 
 
    cam2 = Find("camera2_name"); 
 
    cam1.enabled = True; 
 
    cam2.enabled = False; 
 

 
void Update(){ 
 
    if(Input.GetButtonDown... // you need to implement ur arduino && cam1,isActive()) 
 
     cam1.enabled = false; 
 
     cam2.enabled = true; 
 
    if(Input.GetButtonDown... // you need to implement ur arduino && cam2.isActive()) { 
 
     cam2.enabled = false; 
 
     cam1.enabled = true; 
 
}

Там может быть что-то не так. Теперь я не могу использовать Unity Tool. Я также не уверен, что вы можете «cam1.enabled» или нет.

 Смежные вопросы

  • Нет связанных вопросов^_^