This is a helper class for various random operations.



  • First download the extensions library and put it inside TOZ/Plugins/Extensions folder, if you havent done already.
  • Save the below code as RandomUtil.cs and put it inside TOZ/Plugins/Utilities folder.
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace TOZ {

	public static class RandomUtil {
		//Private variables//
		private static string[] firstNames = new string[12] {
			"Sergio", "Daniel", "Carolina", "David", "Reina", "Saul",
			"Bernard", "Danny", "Dimas", "Yuri", "Ivan", "Laura"
		private static string[] lastNames = new string[12] {
			"Tapia", "Gutierrez", "Rueda", "Galviz", "Yuli", "Rivera",
			"Mamami", "Saucedo", "Dominguez", "Escobar", "Martin", "Crespo"

		//Random name from above strings
		public static string GetName() {
			int a = UnityEngine.Random.Range(0, firstNames.Length);
			int b = UnityEngine.Random.Range(0, lastNames.Length);
			return "{0} {1}".FormatWith(firstNames[a], lastNames[b]);

		//A Random Vector3 inside a triangle
		public static Vector3 GetInsideTriangle(Vector3 p1, Vector3 p2, Vector3 p3) {
			float a = UnityEngine.Random.value;
			float b = UnityEngine.Random.value;
			if ((a + b) > 1f) {
				a = 1f - a;
				b = a - b;
			float c = a - a - b;
			return a * p1 + b * p2 + c * p3;

		public static Vector2 GetInsideRectangle(float x1, float y1, float x2, float y2) {
			float x = UnityEngine.Random.Range(x1, x2);
			float y = UnityEngine.Random.Range(y1, y2);
			return new Vector2(x, y);

		public static Vector3 GetInsideBox(float x1, float y1, float z1, float x2, float y2, float z2) {
			float x = UnityEngine.Random.Range(x1, x2);
			float y = UnityEngine.Random.Range(y1, y2);
			float z = UnityEngine.Random.Range(z1, z2);
			return new Vector3(x, y, z);

		public static Vector2 OnUnitCircle() {
			return UnityEngine.Random.insideUnitCircle.normalized;