public override void Update() { base.Update(); InventoryLight.intensity = Mathf.Lerp(InventoryLight.intensity, TargetLightIntensity, 0.25f); if (ScreenTarget != null) { //figure out how big the list is gColliderBounds = NGUIMath.CalculateAbsoluteWidgetBounds(tr); //now get the actual final on-screen point from our ngui cameara so we can check against edges gColliderBounds.center = ScreenTarget.position; if (ScreenTargetCamera != null) { gScreenBounds.SetMinMax(ScreenTargetCamera.WorldToScreenPoint(gColliderBounds.min), ScreenTargetCamera.WorldToScreenPoint(gColliderBounds.max)); //gScreenBounds.center = ScreenTargetCamera.WorldToScreenPoint(ScreenTarget.position); } else { gScreenBounds.SetMinMax(NGUICamera.WorldToScreenPoint(gColliderBounds.min), NGUICamera.WorldToScreenPoint(gColliderBounds.max)); //gScreenBounds.center = NGUICamera.WorldToScreenPoint(ScreenTarget.position); } //keep the center from going off screen gScreenOffset = Vector3.zero; if (gScreenBounds.max.x > Screen.width) { gScreenOffset.x = Screen.width - gScreenBounds.max.x; } if (gScreenBounds.max.y > Screen.height) { gScreenOffset.y = Screen.height - gScreenBounds.max.y; } if (gScreenBounds.min.x < 0) { gScreenOffset.x = 0f - gScreenBounds.min.x; } if (gScreenBounds.min.y < 0) { gScreenOffset.y = 0f - gScreenBounds.min.y; } gWorldPoint = NGUICamera.ScreenToWorldPoint(gScreenBounds.center + gScreenOffset); gWorldPoint.z = tr.position.z; tr.position = gWorldPoint; } }