// Update is called once per frame
    void Update()
    {
        if (iAmBeingHeld)
        {
            CaptureLight();
        }

        //if the light is selcted and the canvas is not active
        if (LevelManager.selectedLight != null)
        {
            if (LevelManager.selectedLight == this.gameObject)
            {
                StartCoroutine(PanelToggle(1));
            }

            else
            {
                StartCoroutine(PanelToggle(0));
            }
        }

        if (LevelManager.selectedLight == null)
        {
            if (gameObject.transform.GetChild(0).gameObject.activeSelf)
            {
                StartCoroutine(PanelToggle(0));
            }
        }

        //Rotation logic for lights
        if (Input.GetMouseButton(0))
        {
            Vector3 posOnScreen = Camera.main.WorldToScreenPoint(gameObject.transform.position);
            float   distance    = Vector3.Distance(new Vector3(Input.mousePosition.x, Input.mousePosition.y, lm.zpos),
                                                   new Vector3(posOnScreen.x, posOnScreen.y, lm.zpos));

            if (LevelManager.selectedLight != null)
            {
                if (LevelManager.selectedLight == this.gameObject)
                {
                    Debug.Log("Radius is: " + transform.GetComponentInChildren <CircleButons>().radius);
                    if ((distance > transform.GetComponentInChildren <CircleButons>().radius&&
                         distance < transform.GetComponentInChildren <CircleButons>().radius + 100f) || rotating)
                    {
                        RotationLogic();
                    }
                }
            }
        }

        //If the rotating variable is set to true, then reset it to false when the mouse button is released
        if (Input.GetMouseButtonUp(0))
        {
            if (rotating)
            {
                rotating = false;
            }
        }

        //If the light is currently under selection and delete button is pressed, the light must be deleted
        if (LevelManager.selectedLight == this.gameObject)
        {
            if (Input.GetKeyDown(KeyCode.Delete))
            {
                lm.DeleteLight(this.gameObject);
            }
        }
    }