Beispiel #1
0
        public override void OnGUI()
        {
            var positionId = EditorGUIUtility.GetControlID(kCenterGizmoHash, FocusType.Passive);
            var radiusId   = EditorGUIUtility.GetControlID(kRadiusGizmoHash, FocusType.Passive);

            var position = GetValue(kExposureGizmoPosition);
            var radius   = GetValue(kExposureGizmoRadius);

            var cameraPosition = GetValue(kCameraPosition);
            var zoom           = GetValue(kZoom);

            var actualPosition = position * zoom + cameraPosition;
            var actualRadius   = radius * zoom;

            Handles.color  = Handles.xAxisColor;
            actualPosition = EditorGUIX.PositionHandle2D(positionId, actualPosition, Styles.kPositionSize);
            Handles.color  = Handles.yAxisColor;
            actualRadius   = EditorGUIX.RadiusHandle2D(radiusId, actualPosition, actualRadius);

            var newPosition = (actualPosition - cameraPosition) / zoom;
            var newRadius   = actualRadius / zoom;

            if ((position - newPosition).sqrMagnitude > Styles.kPositionThreshold ||
                Mathf.Abs(newRadius - radius) > Styles.kRadiusThreshold)
            {
                SetValue(kExposureGizmoPosition, newPosition);
                SetValue(kExposureGizmoRadius, newRadius);
                ExecuteCommand(kCmdProcessFromColorCorrection);
            }
        }