-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSafeZone.cs
More file actions
26 lines (23 loc) · 918 Bytes
/
SafeZone.cs
File metadata and controls
26 lines (23 loc) · 918 Bytes
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
using UnityEngine;
namespace uMMORPG
{
[RequireComponent(typeof(BoxCollider))]
public class SafeZone : MonoBehaviour
{
public Color gizmoColor = new Color(0, 1, 1, 0.25f);
public Color gizmoWireColor = new Color(1, 1, 1, 0.8f);
// draw the zone all the time, otherwise it's not too obvious where the
// zones are
void OnDrawGizmos()
{
BoxCollider collider = GetComponent<BoxCollider>();
// we need to set the gizmo matrix for proper scale & rotation
Gizmos.matrix = Matrix4x4.TRS(transform.position, transform.rotation, transform.lossyScale);
Gizmos.color = gizmoColor;
Gizmos.DrawCube(collider.center, collider.size);
Gizmos.color = gizmoWireColor;
Gizmos.DrawWireCube(collider.center, collider.size);
Gizmos.matrix = Matrix4x4.identity;
}
}
}