Procedural Planets
Integrated Sebastian Lague's Planet Generator Created Tour function in SectorRenderer which makes the camera follow each terrestrial planet in turn
This commit is contained in:
parent
f8165878e0
commit
53a91351b7
332 changed files with 11904 additions and 78 deletions
|
|
@ -0,0 +1,98 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
[CustomEditor (typeof (CelestialBodyGenerator))]
|
||||
public class GeneratorEditor : Editor {
|
||||
|
||||
CelestialBodyGenerator generator;
|
||||
Editor shapeEditor;
|
||||
Editor shadingEditor;
|
||||
|
||||
bool shapeFoldout;
|
||||
bool shadingFoldout;
|
||||
|
||||
public override void OnInspectorGUI ()
|
||||
{
|
||||
using (var check = new EditorGUI.ChangeCheckScope ()) {
|
||||
DrawDefaultInspector ();
|
||||
if (check.changed) {
|
||||
Regenerate ();
|
||||
}
|
||||
}
|
||||
if (generator.body == null) return;
|
||||
|
||||
if (GUILayout.Button ("Generate")) {
|
||||
Regenerate ();
|
||||
}
|
||||
if (GUILayout.Button ("Randomize Shading")) {
|
||||
var prng = new System.Random ();
|
||||
generator.body.shading.randomize = true;
|
||||
generator.body.shading.seed = prng.Next (-10000, 10000);
|
||||
Regenerate ();
|
||||
}
|
||||
|
||||
if (GUILayout.Button ("Randomize Shape")) {
|
||||
var prng = new System.Random ();
|
||||
generator.body.shape.randomize = true;
|
||||
generator.body.shape.seed = prng.Next (-10000, 10000);
|
||||
Regenerate ();
|
||||
}
|
||||
|
||||
if (GUILayout.Button ("Randomize Both")) {
|
||||
var prng = new System.Random ();
|
||||
generator.body.shading.randomize = true;
|
||||
generator.body.shape.randomize = true;
|
||||
generator.body.shape.seed = prng.Next (-10000, 10000);
|
||||
generator.body.shading.seed = prng.Next (-10000, 10000);
|
||||
Regenerate ();
|
||||
}
|
||||
|
||||
bool randomized = generator.body.shading.randomize || generator.body.shape.randomize;
|
||||
randomized |= generator.body.shading.seed != 0 || generator.body.shape.seed != 0;
|
||||
using (new EditorGUI.DisabledGroupScope (!randomized)) {
|
||||
if (GUILayout.Button ("Reset Randomization")) {
|
||||
var prng = new System.Random ();
|
||||
generator.body.shading.randomize = false;
|
||||
generator.body.shape.randomize = false;
|
||||
generator.body.shape.seed = 0;
|
||||
generator.body.shading.seed = 0;
|
||||
Regenerate ();
|
||||
}
|
||||
}
|
||||
|
||||
// Draw shape/shading object editors
|
||||
DrawSettingsEditor (generator.body.shape, ref shapeFoldout, ref shapeEditor);
|
||||
DrawSettingsEditor (generator.body.shading, ref shadingFoldout, ref shadingEditor);
|
||||
|
||||
SaveState ();
|
||||
}
|
||||
|
||||
void Regenerate () {
|
||||
generator.OnShapeSettingChanged ();
|
||||
generator.OnShadingNoiseSettingChanged ();
|
||||
EditorApplication.QueuePlayerLoopUpdate ();
|
||||
}
|
||||
|
||||
void DrawSettingsEditor (Object settings, ref bool foldout, ref Editor editor) {
|
||||
if (settings != null) {
|
||||
foldout = EditorGUILayout.InspectorTitlebar (foldout, settings);
|
||||
if (foldout) {
|
||||
CreateCachedEditor (settings, null, ref editor);
|
||||
editor.OnInspectorGUI ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnEnable () {
|
||||
shapeFoldout = EditorPrefs.GetBool (nameof (shapeFoldout), false);
|
||||
shadingFoldout = EditorPrefs.GetBool (nameof (shadingFoldout), false);
|
||||
generator = (CelestialBodyGenerator) target;
|
||||
}
|
||||
|
||||
void SaveState () {
|
||||
EditorPrefs.SetBool (nameof (shapeFoldout), shapeFoldout);
|
||||
EditorPrefs.SetBool (nameof (shadingFoldout), shadingFoldout);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 823a5227efa6c4baa801dd74ca50ab82
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
[CustomEditor (typeof (TextureCombiner), true)]
|
||||
public class TextureCombinerEditor : Editor {
|
||||
|
||||
public override void OnInspectorGUI () {
|
||||
DrawDefaultInspector ();
|
||||
|
||||
var textureCombiner = (TextureCombiner) target;
|
||||
|
||||
if (GUILayout.Button ("Save")) {
|
||||
string path = Application.dataPath + "/Resources";
|
||||
textureCombiner.SaveTexture (path);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 441a3534f217d45a6945869ae94c0e63
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
[CustomEditor (typeof (TextureViewer), true)]
|
||||
public class TextureEditor : Editor {
|
||||
|
||||
Editor generatorEditor;
|
||||
bool generatorFoldout;
|
||||
|
||||
public override void OnInspectorGUI () {
|
||||
DrawDefaultInspector ();
|
||||
|
||||
var textureViewer = (TextureViewer) target;
|
||||
|
||||
if (GUILayout.Button ("Generate")) {
|
||||
textureViewer.UpdateTexture ();
|
||||
}
|
||||
|
||||
if (GUILayout.Button ("Save")) {
|
||||
string path = Application.dataPath + "/Resources";
|
||||
textureViewer.SaveTexture (path);
|
||||
}
|
||||
|
||||
if (textureViewer.generator) {
|
||||
bool settingsUpdated = DrawSettingsEditor (textureViewer.generator, ref generatorFoldout, ref generatorEditor);
|
||||
if (settingsUpdated) {
|
||||
textureViewer.UpdateTexture ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool DrawSettingsEditor (Object settings, ref bool foldout, ref Editor editor) {
|
||||
if (settings != null) {
|
||||
foldout = EditorGUILayout.InspectorTitlebar (foldout, settings);
|
||||
if (foldout) {
|
||||
using (var check = new EditorGUI.ChangeCheckScope ()) {
|
||||
CreateCachedEditor (settings, null, ref editor);
|
||||
editor.OnInspectorGUI ();
|
||||
if (check.changed) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void OnEnable () {
|
||||
generatorFoldout = EditorPrefs.GetBool (nameof (generatorFoldout), false);
|
||||
}
|
||||
|
||||
void OnDisable () {
|
||||
EditorPrefs.SetBool (nameof (generatorFoldout), generatorFoldout);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c73be003ed7554257819b982d1816b59
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Loading…
Reference in a new issue