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
Vector3 GetClosestPointOnBounds(Bounds bounds, Vector3 point) | |
{ | |
var boundPoint1 = bounds.min; | |
var boundPoint2 = bounds.max; | |
var points = new Vector3[] { | |
new Vector3(boundPoint1.x, boundPoint1.y), | |
new Vector3(boundPoint1.x, boundPoint2.y), | |
new Vector3(boundPoint2.x, boundPoint2.y), | |
new Vector3(boundPoint2.x, boundPoint1.y), |
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
void DrawBezierCurve(Vector3 point0, Vector3 point1, Vector3 point2, Vector3 point3, Vector3 point4) | |
{ | |
lineRenderer.positionCount = 50; | |
float t = 0f; | |
Vector3 B; | |
for (int i = 0; i < lineRenderer.positionCount; i++) | |
{ | |
B = 1 * (1 - t) * (1 - t) * (1 - t) * (1 - t) * point0 |
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 Newtonsoft.Json; | |
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using UnityEngine; | |
public class GuardianJsonRecorder : MonoBehaviour | |
{ | |
void Update() | |
{ |
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
// this is an adaptation to Unity of the algorithm described | |
//. in https://stackoverflow.com/questions/3749678/expand-fill-of-convex-polygon/3897471 | |
using UnityEngine; | |
using System.Linq; | |
using System.Collections.Generic; | |
static class ConvexHull | |
{ | |
public static Vector2[] ExpandConvexHull(Vector2[] poly, float distance) | |
{ |
NewerOlder