Last active
July 16, 2017 04:24
-
-
Save TakaakiIchijo/3679428726b05cf15067b466bf7726b1 to your computer and use it in GitHub Desktop.
RectTransformに自分基準でクリック位置からローカルポジションを取得する関数を生やす
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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