
Unity
134
Вклад в тег
Link <link=56><color=#FF88FF><b>example</b></color></link> text.
public TextMeshProUGUI text;
private void LateUpdate()
{
if (Input.GetMouseButton(0) && text != null && Camera.main != null)
{
int i = TMP_TextUtilities.FindIntersectingLink(text, Input.mousePosition, Camera.main);
if (i > -1 && text.textInfo.linkInfo.Length > 0)
{
Debug.Log("## " + text.textInfo.linkInfo[i].GetLinkID()
+ " - " + text.textInfo.linkInfo[i].GetLinkText());
}
}
}
SphereCollider sc = gameObject.AddComponent<SphereCollider>() as SphereCollider;
Vector3 BallisticVel(Vector3 target, Vector3 source, float angle)
{
var dir = target - source; // get target direction
var h = dir.y; // get height difference
dir.y = 0; // retain only the horizontal direction
var dist = dir.magnitude; // get horizontal distance
var a = angle * Mathf.Deg2Rad; // convert angle to radians
dir.y = dist * Mathf.Tan(a); // set dir to the elevation angle
dist += h / Mathf.Tan(a); // correct for small height differences
// calculate the velocity magnitude
var vel = Mathf.Sqrt(dist * Physics.gravity.magnitude / Mathf.Sin(2 * a));
var res = vel * dir.normalized;
if (float.IsNaN(res.x)) res = new Vector3(); // Set zero if vector NaN.
return res;
}