Integrated Sebastian Lague's Planet Generator Created Tour function in SectorRenderer which makes the camera follow each terrestrial planet in turn
21 lines
No EOL
644 B
C#
21 lines
No EOL
644 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public static class Normalizer {
|
|
|
|
public static void Normalize (System.Func<int, float> getValue, System.Action<int, float> setValue, int length) {
|
|
float min = float.PositiveInfinity;
|
|
float max = float.NegativeInfinity;
|
|
|
|
for (int i = 0; i < length; i++) {
|
|
float value = getValue (i);
|
|
min = System.Math.Min (min, value);
|
|
max = System.Math.Max (max, value);
|
|
}
|
|
for (int i = 0; i < length; i++) {
|
|
setValue (i, Mathf.InverseLerp (min, max, getValue (i)));
|
|
}
|
|
}
|
|
|
|
} |