Assets/FlexibleColorPicker/Scripts/FlexibleColorPicker.cs
/// <summary>
/// Get normalized position in the case of a world space (or screen space camera) 
/// type cavnvas render mode.
/// </summary>
Get normalized position in the case of a world space (or screen space camera)
type cavnvas render mode.
Get normalized position in the case of a world space ( or screen space camera ) type cavnvas render mode .
private static Vector2 GetNormWorldSpace(Canvas canvas, RectTransform rect, BaseEventData e) {
        Vector2 screenPoint = ((PointerEventData)e).position;
        Ray pointerRay = canvas.worldCamera.ScreenPointToRay(screenPoint);
        Plane canvasPlane = new Plane(canvas.transform.forward, canvas.transform.position);
        float enter;
        canvasPlane.Raycast(pointerRay, out enter);
        Vector3 worldPoint = pointerRay.origin + enter * pointerRay.direction;
        Vector2 localPoint = rect.worldToLocalMatrix.MultiplyPoint(worldPoint);
        float x = Mathf.Clamp01((localPoint.x / rect.rect.size.x) + rect.pivot.x);
        float y = Mathf.Clamp01((localPoint.y / rect.rect.size.y) + rect.pivot.y);
        return new Vector2(x, y);
    }
private static Vector2 GetNormWorldSpace ( Canvas canvas , RectTransform rect , BaseEventData e ) { Vector2 screenPoint = ( ( PointerEventData ) e ) . position ; Ray pointerRay = canvas . worldCamera . ScreenPointToRay ( screenPoint ) ; Plane canvasPlane = new Plane ( canvas . transform . forward , canvas . transform . position ) ; float enter ; canvasPlane . Raycast ( pointerRay , out enter ) ; Vector3 worldPoint = pointerRay . origin + enter * pointerRay . direction ; Vector2 localPoint = rect . worldToLocalMatrix . MultiplyPoint ( worldPoint ) ; float x = Mathf . Clamp01 ( ( localPoint . x / rect . rect . size . x ) + rect . pivot . x ) ; float y = Mathf . Clamp01 ( ( localPoint . y / rect . rect . size . y ) + rect . pivot . y ) ; return new Vector2 ( x , y ) ; }
Get normalized position in the case of a world space (or screen space camera)
type cavnvas render mode.
Get normalized position in the case of a world space ( or screen space camera ) type cavnvas render mode .
canvas
Canvas
rect
RectTransform
e
BaseEventData