Created
January 2, 2017 01:40
-
-
Save nikhilsinha/0dd61fa78243d3c994df5b82e7f48692 to your computer and use it in GitHub Desktop.
With the hack
This file contains 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 class UiUnitAttacher : MonoBehaviour | |
{ | |
public GameObject Target; | |
private RectTransform _rectTransform; | |
// Use this for initialization | |
void Start() | |
{ | |
_rectTransform = GetComponent<RectTransform>(); | |
} | |
// Update is called once per frame | |
void Update() | |
{ | |
Vector3 pos = Target.transform.position; | |
Vector3 vp = Camera.main.WorldToViewportPoint(pos); | |
vp.x = vp.x * Screen.width; | |
vp.y = vp.y * Screen.height; | |
vp.x -= 50; | |
vp.y += 100; | |
_rectTransform.position = vp; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment