-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathUtils.cs
executable file
·64 lines (55 loc) · 2.04 KB
/
Utils.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using UnityEngine;
using System.Collections.Generic;
using System.Collections;
using System;
namespace UberTools
{
public static class Utils
{
/// Clears texture to 'col'. Slowly, using the CPU. Arg.
public static void ClearTexture(Texture2D texture, Color col)
{
for(int cy=0; cy<texture.height; cy++)
{
for(int cx=0; cx<texture.width; cx++)
{
texture.SetPixel(cx, cy, col);
}
}
texture.Apply();
}
public static bool IsWithinRangeNoY(Vector3 p1, Vector3 p2, float distance)
{
p1.y = p2.y;
return (p1-p2).sqrMagnitude<distance*distance;
}
public static bool IsWithinRangeNoY(Transform p1, Transform p2, float distance)
{
return IsWithinRangeNoY(p1.position, p2.position, distance);
}
public static bool IsWithinRangeNoY(GameObject p1, GameObject p2, float distance)
{
return IsWithinRangeNoY(p1.transform.position, p2.transform.position, distance);
}
public static bool IsWithinRange(Vector3 p1, Vector3 p2, float distance)
{
return (p1-p2).sqrMagnitude<distance*distance;
}
public static bool IsWithinRange(Transform p1, Vector3 p2, float distance)
{
return IsWithinRange(p1.position, p2, distance);
}
public static bool IsWithinRange(Vector3 p1, Transform p2, float distance)
{
return IsWithinRange(p1, p2.position, distance);
}
public static bool IsWithinRange(Transform p1, Transform p2, float distance)
{
return IsWithinRange(p1.position, p2.position, distance);
}
public static bool IsWithinRange(GameObject p1, GameObject p2, float distance)
{
return IsWithinRange(p1.transform.position, p2.transform.position, distance);
}
}
}