SpotLight.Update C# (CSharp) Method

Update() private method

private Update ( ) : void
return void
    void Update()
    {
        if (ExperimentManager.instance.currentTrial == -1) {
            if (ExperimentManager.instance.currentTask == ExperimentManager.Task.TranslationIntensity) {
                targetPosition = ExperimentManager.instance.currentLightTarget;
            }
        }

        if(Input.GetKeyDown(KeyCode.A))
            LightReset();

        if(MouseMode>=0) // light is selected
        {
            selectedTime += Time.deltaTime;
            SelectedMode();

            if(InteractionMode ==1) //translation and rotation
            {
                if(MouseMode ==1)//translation
                    OnMouseTranslation();
                else if(MouseMode ==2)
                {
                    Vector2 rot = new Vector2(0f,0f);
                    rot.x = Input.GetAxis("Mouse X")*rotation_factor;
                    rot.y = 0f-Input.GetAxis("Mouse Y")*rotation_factor;
                    OnMouseRotation(rot);
                }
                else if(MouseMode ==4)
                    TranslationZZ();

            }

            else if(InteractionMode ==2)//translation and intensity
            {
                if(MouseMode ==1)//translation
                {
                    OnMouseTranslation();
                    OnTragetMode();
                }
                else if(MouseMode ==4)
                {
                    TranslationZZ();
                    OnTragetMode();
                }

            }
        }
        else
        {
            DeselectedMode();
        }

        if (ExperimentManager.instance.currentTask == ExperimentManager.Task.Setup) {
            targetPosition = ExperimentManager.instance.currentLightTarget;
            transform.LookAt(targetPosition);
        }
    }

Usage Example

        /// <summary>
        /// To get key events, remember that you must call before to Keyboard.Focus(this). Usually you call to this method on MouseDown.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void UserControl_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Up)
            {
                spot.AngleXInDegrees += 10;
            }
            if (e.Key == Key.Down)
            {
                spot.AngleYInDegrees += 10;
            }

            spot.Update();
        }
All Usage Examples Of SpotLight::Update