예제 #1
0
    /// <summary>
    /// Converts a point in the anchor coordinates to rect coordinates. For example place the rect in a specific position and the returned value will be the anchor coordinates if the anchors were in that specific position.
    /// </summary>
    /// <param name="tr"></param>
    public static Vector2 GetRectCoordinateFromAnchorCoordinate(RectTransform tr, Vector2 anchorCoordinate)
    {
        Vector2 parentSize = RteRectTools.GetParentSizeIgnoringAnchors(tr);

        return(new Vector2(parentSize.x * anchorCoordinate.x, parentSize.y * anchorCoordinate.y));
    }
예제 #2
0
    /// <summary>
    /// Converts a point in the rect coordinates to anchor coordinates. The returned value will be the anchor coordinates if the anchors were in that specific position position in rect coordinates.
    /// </summary>
    /// <param name="tr"></param>
    public static Vector2 GetAnchorCoordianteFromRectCoordinate(RectTransform tr, Vector2 rectCoordinate)
    {
        Vector2 parentSize = RteRectTools.GetParentSizeIgnoringAnchors(tr);

        return(FixNaN(new Vector2(rectCoordinate.x / parentSize.x, rectCoordinate.y / parentSize.y)));
    }