Beispiel #1
0
    // Update is called once per frame
    void Update()
    {
        if (jumpGameObject == null)
        {
            jumpGameObject = GameObject.Find("Astronaut");
            jump           = jumpGameObject.GetComponent(typeof(IJump)) as IJump;
            input          = serialInputGameObject.GetComponent(typeof(SerialInput)) as SerialInput;
        }

        DetectJump(input.Value);
    }
Beispiel #2
0
    // Use this for initialization
    void Start()
    {
        // if jump detector already exists
        var sm = GameObject.Find(this.gameObject.name);

        if (sm != null && sm != this.gameObject)
        {
            Destroy(this.gameObject);
        }

        // init buffers
        buffer    = new RingBuffer <float>(bufferSize);
        fftBuffer = new Complex[bufferSize];

        jump  = jumpGameObject.GetComponent(typeof(IJump)) as IJump;
        input = serialInputGameObject.GetComponent(typeof(SerialInput)) as SerialInput;
    }
Beispiel #3
0
    // Use this for initialization
    void Start()
    {
        ports = GetSerialPortNames();

        Debug.Log("Found " + ports.Count + " serial devices...");
        sensitivityValue    = GameObject.Find("SensitivityValue").GetComponent <Text>();
        sensitivitySlider   = GameObject.Find("SensitivitySlider").GetComponent <Slider>();
        serialPortSelection = GameObject.Find("SerialPortSelection").GetComponent <Dropdown>();

        detector    = GameObject.Find("Jump Detection").GetComponent <JumpDetector>();
        serialInput = GameObject.Find("SerialInput").GetComponent <SerialInput>();

        sensitivitySlider.value = detector.threshold;

        serialPortSelection.options.Clear();
        ports.ForEach(e => serialPortSelection.options.Add(new Dropdown.OptionData(e)));
        serialPortSelection.captionText.text = serialInput.deviceName;

        sensitivitySlider.onValueChanged.AddListener(delegate { ValueChangeCheck(); });
        serialPortSelection.onValueChanged.AddListener(delegate { SerialPortChange(); });

        ValueChangeCheck();
    }