Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save TakaakiIchijo/3679428726b05cf15067b466bf7726b1 to your computer and use it in GitHub Desktop.
Save TakaakiIchijo/3679428726b05cf15067b466bf7726b1 to your computer and use it in GitHub Desktop.
RectTransformに自分基準でクリック位置からローカルポジションを取得する関数を生やす
using UnityEngine;
public static class RectTransformExtension
{
public static Vector2 GetLocalPosition(this RectTransform rectTransform, Vector2 screenPosition, Camera camera)
{
Vector2 result = Vector2.zero;
RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform, screenPosition, camera, out result);
return result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment