/// <summary> /// Creates a planet based on a previously exported Base64 encoded JSON string (exported via the inspector of a planet in the Unity editor). /// </summary> public void CreatePlanetUsingBase64EncodedJSON() { // If a planet already exists in the scene, destroy it if (_planet != null) { DestroyImmediate(_planet.gameObject); } // Use PlanetManager.CreatePlanet method to create a new planet and include the Base64 JSON string as a second argument to force all properties. _planet = PlanetManager.CreatePlanet(Vector3.zero, "eyJjYXRlZ29yeSI6InBsYW5ldCIsInR5cGUiOiJTb2xpZFBsYW5ldCIsInZlcnNpb24iOiIwLjEuMiIsInBsYW5ldCI6eyJwbGFuZXRTZWVkIjo3NTQzODA2OTcsInZhcmlhdGlvblNlZWQiOjAsImJsdWVwcmludEluZGV4IjowLCJibHVlcHJpbnROYW1lIjoiVGVycmVzdHJpYWwiLCJwcm9wZXJ0eUZsb2F0cyI6eyJhbGllbml6YXRpb24iOjAsImNvbnRpbmVudFNlZWQiOjk0LCJjb250aW5lbnRTaXplIjowLjc4NTMyODEsImNvbnRpbmVudENvbXBsZXhpdHkiOjAuMzExNjc2MiwiY29hc3RhbERldGFpbCI6MC4yNDYwMzg3LCJjb2FzdGFsUmVhY2giOjAuNDkyNTEyNCwibGlxdWlkTGV2ZWwiOjAuNTYyLCJsaXF1aWRPcGFjaXR5IjoxLCJsaXF1aWRTaGFsbG93IjowLCJsaXF1aWRTcGVjdWxhclBvd2VyIjowLjUxOTMzNjYsInBvbGFyQ2FwQW1vdW50IjowLjQ2NDE5NjIsImF0bW9zcGhlcmVFeHRlcm5hbFNpemUiOjAuNTU2MjQxMywiYXRtb3NwaGVyZUV4dGVybmFsRGVuc2l0eSI6MC43MTIzMTMzLCJhdG1vc3BoZXJlSW50ZXJuYWxEZW5zaXR5IjowLjk3NTE4NzMsImNsb3Vkc09wYWNpdHkiOjEsImNsb3Vkc1NlZWQiOjExNSwiY2xvdWRzQ292ZXJhZ2UiOjAuNDc5LCJjbG91ZHNMYXllcjEiOjAuNDU1LCJjbG91ZHNMYXllcjIiOjAuODEyLCJjbG91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zaXRpb24iOnsiaW5kZXgiOjYsIm5hbWUiOiJTb2xpZF9UZXJyZXN0cmlhbCJ9LCJwb2xhckljZSI6eyJpbmRleCI6MCwibmFtZSI6IlBvbGFyX0ljZSJ9LCJjbG91ZHMiOnsiaW5kZXgiOjMsIm5hbWUiOiJDbG91ZHNfMDQifSwibGF2YSI6eyJpbmRleCI6MCwibmFtZSI6IkxhdmFfMDEifSwiYmlvbWUxVHlwZSI6eyJpbmRleCI6NSwibmFtZSI6IkJpb21lX1JhaW5fRm9yZXN0In0sImJpb21lMlR5cGUiOnsiaW5kZXgiOjcsIm5hbWUiOiJCaW9tZV9UdW5kcmEifSwiY2l0aWVzIjp7ImluZGV4IjowLCJuYW1lIjoiQ2l0aWVzIn19LCJwcm9wZXJ0eUNvbG9ycyI6eyJzcGVjdWxhckNvbG9yIjp7InIiOjAuMzk4NDk2LCJnIjowLjMyMjIzMDgsImIiOjAuMDQ3MDEwMjF9LCJsaXF1aWRDb2xvciI6eyJyIjowLjAwMzU5MzQ1OCwiZyI6MC4wMTU1NDM1MSwiYiI6MC4wMzQxMTN9LCJpY2VDb2xvciI6eyJyIjowLjk1NDkxNjUsImciOjAuOTI1NTA1LCJiIjowLjkyNTUwNX0sImF0bW9zcGhlcmVDb2xvciI6eyJyIjowLjE1NTMxNzUsImciOjAuNzQ0Njc4MywiYiI6MX0sInR3aWxpZ2h0Q29sb3IiOnsiciI6MC4zODU0NjQsImciOjAuMzE5NjA4NCwiYiI6MC4wODcwNTUzOX0sImNsb3Vkc0NvbG9yIjp7InIiOjEsImciOjEsImIiOjF9LCJsYXZhR2xvd0NvbG9yIjp7InIiOjAuOTY3ODU2OCwiZyI6MC4wNDA3OTc4OSwiYiI6MC4wMTY5NDQxMX0sImNpdGllc0NvbG9yIjp7InIiOjAuOTMzMDU1OCwiZyI6MC45MjQxNzkxLCJiIjowLjYzNTQzM319fX0="); _planet.AddListener(gameObject); // Set the UI text message to indicate that textures are being rebuilt. uiTextMessage.text = "Rebuilding textures..."; }
/// <summary> /// Creates a simple random planet. /// </summary> public void CreateRandomPlanet() { // If a planet already exists in the scene, destroy it if (_planet != null) { DestroyImmediate(_planet.gameObject); } // Use PlanetManager.CreatePlanet method to create a new planet - when only a position is included as an argument it will create a totally random planet // and select a planet blueprint based on the blueprint's probability value. _planet = PlanetManager.CreatePlanet(Vector3.zero); _planet.AddListener(gameObject); // Set the UI text message to indicate that textures are being rebuilt. uiTextMessage.text = "Rebuilding textures..."; }
public void Draw(PlanetManager planetManager) { Planet[] planetsArray = this.planets.ToArray(); for (int i = 0; i < planetsArray.Length; i++) { Planet planet = planetsArray[i]; if (planet.gameObject != null) { planet.orbit.UpdateAngle(); planet.gameObject.transform.position = planet.orbit.CalculatePosition(); } else { planet.gameObject = planetManager.CreatePlanet(planet.prefab, planet.orbit.CalculatePosition()); } } }
void Start() { // Create a random planet at the center of the scene PlanetManager.CreatePlanet(Vector3.zero); // Set planet texture detail mode to LOD (texture resolution for all planet textures are independently // generated at a level of detail specified for a given size of the planet on the screen. PlanetManager.TextureDetailMode = PlanetManager.TextureDetailModes.LOD_Separate; // Set number of LOD steps to 5. PlanetManager.TextureLODSteps = 5; // Set LOD resolution array to: 7 (2048 x 2048), 6 (1024x1024), 5 (512x512), 3 (128x128), 1 (64x64) PlanetManager.TextureLODComposition = new int[5] { 7, 6, 5, 3, 1 }; // Set the planet sizes used to transition between mesh LOD levels // Note: There are only 4 entries in this array because it specifies the size *between* the LOD levels. // The float values in the array represent the ratio between screen height and the height of a planet as seen by the camera. // E.g. the value 0.5f = when the planet takes up half the screen height. PlanetManager.TextureLODPlanetSizes = new float[4] { 0.6f, 0.4f, 0.2f, 0.05f }; }
/// <summary> /// Displays and allows interaction in a custom inspector for Solid Planets Blueprints /// </summary> public override void OnInspectorGUI() { // Call target update _target.Update(); // Update the index dictionaries UpdateIndex(); EditorGUILayout.LabelField("PLANET BLUEPRINT TOOLS", EditorStyles.boldLabel); EditorGUI.indentLevel++; if (GUILayout.Button(new GUIContent("Create Planet", "Create planet using this blueprint"))) { PlanetManager.CreatePlanet(Vector3.zero, -1, _script.gameObject.name); } EditorGUILayout.Space(); if (GUILayout.Button("Export Blueprint to Clipboard (JSON)")) { GUIUtility.systemCopyBuffer = _script.ExportToJSON(); EditorUtility.DisplayDialog("Finished", "Planet Blueprint was saved to clipboard", "Close"); } if (GUILayout.Button("Import Blueprint from Clipboard (JSON)")) { string _str = GUIUtility.systemCopyBuffer; _script.ImportFromJSON(_str); _target.Update(); _target.ApplyModifiedProperties(); _target.Update(); } EditorGUILayout.Space(); if (_script.transform.Find("Ring") == null) { if (GUILayout.Button(new GUIContent("Create Planetary Ring", "Add planetary ring to this blueprint"))) { _script.CreateRing(); } } else { GUILayout.BeginHorizontal(); if (GUILayout.Button(new GUIContent("Remove Planetary Ring", "Remove planetary ring from this blueprint"))) { DestroyImmediate(_script.transform.Find("Ring").gameObject); } if (GUILayout.Button(new GUIContent("Edit Planetary Ring", "Edit planetary ring of this blueprint"))) { Selection.activeGameObject = _script.transform.Find("Ring").gameObject; } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); _ringProbability.floatValue = EditorGUILayout.Slider("Probability to have Ring", _ringProbability.floatValue, 0f, 1f); EditorGUILayout.LabelField((_ringProbability.floatValue * 100).ToString("F1") + "%", GUILayout.MaxWidth(PERCENT_WIDTH)); GUILayout.EndHorizontal(); } EditorGUI.indentLevel--; EditorGUILayout.Space(); // PLANET SETTINGS EditorGUILayout.LabelField("PLANET SETTINGS", EditorStyles.boldLabel); EditorGUI.indentLevel++; RenderPropertyFloat("alienization"); RenderPropertyMaterial("composition"); RenderPropertyColor("specularColor"); EditorGUI.indentLevel--; // CONTINENTS EditorGUILayout.Space(); EditorGUILayout.LabelField("CONTINENTS", EditorStyles.boldLabel); EditorGUI.indentLevel++; RenderPropertyFloat("continentSize"); RenderPropertyFloat("continentComplexity"); EditorGUI.indentLevel--; // COASTS EditorGUILayout.Space(); EditorGUILayout.LabelField("COAST LINES", EditorStyles.boldLabel); EditorGUI.indentLevel++; RenderPropertyFloat("coastalDetail"); RenderPropertyFloat("coastalReach"); EditorGUI.indentLevel--; // LIQUID EditorGUILayout.Space(); EditorGUILayout.LabelField("LIQUID", EditorStyles.boldLabel); EditorGUI.indentLevel++; RenderPropertyFloat("liquidLevel"); RenderPropertyColor("liquidColor"); RenderPropertyFloat("liquidOpacity"); RenderPropertyFloat("liquidShallow"); RenderPropertyFloat("liquidSpecularPower"); EditorGUI.indentLevel--; // ICE EditorGUILayout.Space(); EditorGUILayout.LabelField("ICE", EditorStyles.boldLabel); EditorGUI.indentLevel++; RenderPropertyMaterial("polarIce"); RenderPropertyFloat("polarCapAmount"); RenderPropertyColor("iceColor"); EditorGUI.indentLevel--; // ATMOSPHERE EditorGUILayout.Space(); EditorGUILayout.LabelField("ATMOSPHERE", EditorStyles.boldLabel); EditorGUI.indentLevel++; RenderPropertyColor("atmosphereColor"); RenderPropertyFloat("atmosphereExternalSize"); RenderPropertyFloat("atmosphereExternalDensity"); RenderPropertyFloat("atmosphereInternalDensity"); RenderPropertyColor("twilightColor"); EditorGUI.indentLevel--; // CLOUDS EditorGUILayout.Space(); EditorGUILayout.LabelField("CLOUDS", EditorStyles.boldLabel); EditorGUI.indentLevel++; RenderPropertyFloat("cloudsOpacity"); RenderPropertyMaterial("clouds"); RenderPropertyColor("cloudsColor"); RenderPropertyFloat("cloudsRoughness"); RenderPropertyFloat("cloudsCoverage"); RenderPropertyFloat("cloudsLayer1"); RenderPropertyFloat("cloudsLayer2"); RenderPropertyFloat("cloudsLayer3"); RenderPropertyFloat("cloudsSharpness"); RenderPropertyFloat("cloudsTiling"); RenderPropertyFloat("cloudsSpeed"); RenderPropertyFloat("cloudsHeight"); RenderPropertyFloat("cloudsShadow"); EditorGUI.indentLevel--; // LAVA EditorGUILayout.Space(); EditorGUILayout.LabelField("MOLTEN LAVA", EditorStyles.boldLabel); EditorGUI.indentLevel++; RenderPropertyFloat("lavaAmount"); RenderPropertyMaterial("lava"); RenderPropertyFloat("lavaComplexity"); RenderPropertyFloat("lavaFrequency"); RenderPropertyFloat("lavaDetail"); RenderPropertyFloat("lavaReach"); RenderPropertyFloat("lavaColorVariation"); RenderPropertyFloat("lavaFlowSpeed"); RenderPropertyFloat("lavaGlowAmount"); RenderPropertyColor("lavaGlowColor"); EditorGUI.indentLevel--; // SURFACE EditorGUILayout.Space(); EditorGUILayout.LabelField("SURFACES", EditorStyles.boldLabel); EditorGUI.indentLevel++; RenderPropertyFloat("surfaceRoughness"); RenderPropertyFloat("surfaceTiling"); EditorGUI.indentLevel--; // COMPOSITION EditorGUILayout.Space(); EditorGUILayout.LabelField("BIOMES", EditorStyles.boldLabel); EditorGUI.indentLevel++; RenderPropertyFloat("compositionTiling"); RenderPropertyFloat("compositionChaos"); RenderPropertyFloat("compositionBalance"); RenderPropertyFloat("compositionContrast"); EditorGUI.indentLevel--; // BIOME 1 EditorGUILayout.Space(); EditorGUILayout.LabelField("BIOME 1", EditorStyles.boldLabel); EditorGUI.indentLevel++; RenderPropertyMaterial("biome1Type"); RenderPropertyFloat("biome1Chaos"); RenderPropertyFloat("biome1Balance"); RenderPropertyFloat("biome1Contrast"); RenderPropertyFloat("biome1ColorVariation"); RenderPropertyFloat("biome1Saturation"); RenderPropertyFloat("biome1Brightness"); RenderPropertyFloat("biome1CratersSmall"); RenderPropertyFloat("biome1CratersMedium"); RenderPropertyFloat("biome1CratersLarge"); RenderPropertyFloat("biome1CratersErosion"); RenderPropertyFloat("biome1CratersDiffuse"); //RenderPropertyFloat("biome1CanyonsDiffuse"); RenderPropertyFloat("biome1SurfaceBump"); RenderPropertyFloat("biome1CratersBump"); RenderPropertyFloat("biome1CanyonsBump"); EditorGUI.indentLevel--; // BIOME 2 EditorGUILayout.Space(); EditorGUILayout.LabelField("BIOME 2", EditorStyles.boldLabel); EditorGUI.indentLevel++; RenderPropertyMaterial("biome2Type"); RenderPropertyFloat("biome2Chaos"); RenderPropertyFloat("biome2Balance"); RenderPropertyFloat("biome2Contrast"); RenderPropertyFloat("biome2ColorVariation"); RenderPropertyFloat("biome2Saturation"); RenderPropertyFloat("biome2Brightness"); RenderPropertyFloat("biome2CratersSmall"); RenderPropertyFloat("biome2CratersMedium"); RenderPropertyFloat("biome2CratersLarge"); RenderPropertyFloat("biome2CratersErosion"); RenderPropertyFloat("biome2CratersDiffuse"); //RenderPropertyFloat("biome2CanyonsDiffuse"); RenderPropertyFloat("biome2SurfaceBump"); RenderPropertyFloat("biome2CratersBump"); RenderPropertyFloat("biome2CanyonsBump"); EditorGUI.indentLevel--; // CITIES EditorGUILayout.Space(); EditorGUILayout.LabelField("CITIES & POPULATION", EditorStyles.boldLabel); EditorGUI.indentLevel++; RenderPropertyMaterial("cities"); RenderPropertyFloat("citiesPopulation"); RenderPropertyFloat("citiesAdvancement"); RenderPropertyFloat("citiesGlow"); RenderPropertyFloat("citiesTiling"); RenderPropertyColor("citiesColor"); EditorGUI.indentLevel--; EditorGUILayout.Space(); _target.ApplyModifiedProperties(); }
/// <summary> /// Displays and allows interaction in a custom inspector for Gas Planets Blueprints /// </summary> public override void OnInspectorGUI() { // Call target update _target.Update(); // Update the index dictionaries UpdateIndex(); EditorGUILayout.LabelField("PLANET BLUEPRINT TOOLS", EditorStyles.boldLabel); EditorGUI.indentLevel++; if (GUILayout.Button(new GUIContent("Create Planet", "Create planet using this blueprint"))) { PlanetManager.CreatePlanet(Vector3.zero, -1, _script.gameObject.name); } EditorGUILayout.Space(); if (GUILayout.Button("Export Blueprint to Clipboard (JSON)")) { GUIUtility.systemCopyBuffer = _script.ExportToJSON(); EditorUtility.DisplayDialog("Finished", "Planet Blueprint was saved to clipboard", "Close"); } if (GUILayout.Button("Import Blueprint from Clipboard (JSON)")) { string _str = GUIUtility.systemCopyBuffer; _script.ImportFromJSON(_str); _target.Update(); _target.ApplyModifiedProperties(); _target.Update(); } EditorGUILayout.Space(); if (_script.transform.Find("Ring") == null) { if (GUILayout.Button(new GUIContent("Create Planetary Ring", "Add planetary ring to this blueprint"))) { _script.CreateRing(); } } else { GUILayout.BeginHorizontal(); if (GUILayout.Button(new GUIContent("Remove Planetary Ring", "Remove planetary ring from this blueprint"))) { DestroyImmediate(_script.transform.Find("Ring").gameObject); } if (GUILayout.Button(new GUIContent("Edit Planetary Ring", "Edit planetary ring of this blueprint"))) { Selection.activeGameObject = _script.transform.Find("Ring").gameObject; } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); _ringProbability.floatValue = EditorGUILayout.Slider("Probability to have Ring", _ringProbability.floatValue, 0f, 1f); EditorGUILayout.LabelField((_ringProbability.floatValue * 100).ToString("F1") + "%", GUILayout.MaxWidth(PERCENT_WIDTH)); GUILayout.EndHorizontal(); } EditorGUI.indentLevel--; EditorGUILayout.Space(); // PLANET SETTINGS EditorGUILayout.LabelField("PLANET SETTINGS", EditorStyles.boldLabel); EditorGUI.indentLevel++; RenderPropertyMaterial("gas"); RenderPropertyFloat("horizontalTiling"); RenderPropertyFloat("verticalTiling"); RenderPropertyFloat("turbulence"); RenderPropertyFloat("turbulenceScale"); RenderPropertyFloat("turbulenceDisorder"); RenderPropertyFloat("separation"); RenderPropertyFloat("blurriness"); RenderPropertyFloat("smoothness"); RenderPropertyFloat("palette"); RenderPropertyFloat("detail"); RenderPropertyFloat("detailOffset"); RenderPropertyFloat("contrast"); RenderPropertyFloat("hue"); RenderPropertyFloat("saturation"); RenderPropertyFloat("brightness"); RenderPropertyFloat("banding"); RenderPropertyFloat("solidness"); RenderPropertyFloat("faintness"); RenderPropertyColor("faintnessColor"); RenderPropertyFloat("roughness"); RenderPropertyFloat("stormMaskIndex"); RenderPropertyFloat("stormSquash"); RenderPropertyColor("stormColor"); RenderPropertyFloat("stormTint"); RenderPropertyFloat("stormScale"); RenderPropertyFloat("stormNoise"); RenderPropertyColor("atmosphereColor"); RenderPropertyFloat("atmosphereFalloff"); RenderPropertyColor("twilightColor"); EditorGUI.indentLevel--; EditorGUILayout.Space(); _target.ApplyModifiedProperties(); }