Beispiel #1
0
    void ChangeLightIntensity(IntensityDirection direction)
    {
        //direction is the name of the local direction variable
        float dt = Time.deltaTime;

        //print(direction);

        switch (direction)
        {
        case IntensityDirection.Increase:
            lt.intensity += dt * lightIntensityMultiplier;
            break;

        case IntensityDirection.Same:
            // lt.intensity -= dt * lightIntensityMultiplier;
            break;

        case IntensityDirection.Decrease:
            lt.intensity -= dt * lightIntensityMultiplier;
            break;
        }

        lt.intensity = Mathf.Clamp(lt.intensity, minIntensity, maxIntensity);
        //Debug.Log(lt.intensity);

        oldValues = curValues;
    }
Beispiel #2
0
    // Update is called once per frame
    void Update()
    {
        //catch if SP is closed, make sure it's open
        if (!sp.SerialPort.IsOpen)
        {
            sp.OpenSerialPort();
        }

        str       = sp.RawData;
        curValues = splitString(str);

        //init values with specific array member
        int o = oldValues[8];
        int c = curValues[8];

        Debug.Log(c);

        if (o < c)
        {
            myDir = IntensityDirection.Increase;
        }
        if (o == c)
        {
            myDir = IntensityDirection.Same;
        }
        if (o > c)
        {
            myDir = IntensityDirection.Decrease;
        }

        ChangeLightIntensity(myDir);
    }