importTest.cs 786 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. namespace Receive
  5. {
  6. public class importTest : MonoBehaviour {
  7. int toggleTimer = 30;
  8. bool ledState = false;
  9. public bool startMotor = false;
  10. public string direction = "Up";
  11. // Use this for initialization
  12. void Start () {
  13. StartCoroutine (recieveLoop ());
  14. }
  15. // Update is called once per frame
  16. void Update () {
  17. }
  18. IEnumerator recieveLoop(){
  19. var receive = new Receive {RunLoop = true};
  20. receive.Setup();
  21. int i = 0;
  22. while (receive.RunLoop) {
  23. receive.setMotor (direction,startMotor);
  24. if(i >= toggleTimer){
  25. ledState = !ledState;
  26. i = 0;
  27. }
  28. i++;
  29. receive.toggleLed (ledState);
  30. yield return null;
  31. }
  32. receive.Exit();
  33. }
  34. }
  35. }