Initial commit

This commit is contained in:
gunnbr committed 2021-01-11 22:20:43 -08:00
1 parent ee9615239e
commit 16feac691f
4093 files changed
+1030491

No files matched your search

@@ -0,0 +1,588 @@
using System;
using System.Text;
using UnityEngine;
using System.Collections.Generic;
using System.Linq;
using UnityEngine.SceneManagement;
#if UNITY_EDITOR
using UnityEditor.SceneManagement;
using UnityEditor;
#endif
namespace Gaia
{
/// <summary>
/// This object stores Gaia defaults. There should be only one of these in your project. Gaia will automatically pick these up and use them.
/// </summary>
public class GaiaDefaults : ScriptableObject
{
[Tooltip("Unique identifier for these defaults."), HideInInspector]
public string m_defaultsID = Guid.NewGuid().ToString();
[Tooltip("The absolute height of the sea or water table in meters. All spawn criteria heights are calculated relative to this. Used to populate initial sea level in new resources files.")]
public float m_seaLevel = 50f;
[Tooltip("The beach height in meters. Beaches are spawned at sea level and are extended for this height above sea level. This is used when creating default spawn rules in order to create a beach in the zone between water and land. Only used to populate initial beach height in new resources files.")]
public float m_beachHeight = 5f;
[Header("Base Terrain:")]
[Space(5)]
[Tooltip("The accuracy of the mapping between the terrain maps (heightmap, textures, etc) and the generated terrain; higher values indicate lower accuracy but lower rendering overhead.")]
[Range(1, 200)]
public int m_pixelError = 5;
[Tooltip("The maximum distance at which terrain textures will be displayed at full resolution. Beyond this distance, a lower resolution composite image will be used for efficiency.")]
[Range(0, 2000)]
public int m_baseMapDist = 1024;
#if UNITY_2019_1_OR_NEWER
[Tooltip("The shadow casting mode for the terrain.")]
public UnityEngine.Rendering.ShadowCastingMode m_shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.On;
#else
[Tooltip("Whether or not the terrain casts shadows.")]
public bool m_castShadows = true;
#endif
[Tooltip("The material used to render the terrain. This should use a suitable shader, for example Nature/Terrain/Diffuse. The default terrain shader is used if no material is supplied.")]
public Material m_material;
[Tooltip("The Physic Material used for the terrain surface to specify its friction and bounce.")]
public PhysicMaterial m_physicsMaterial;
[Header("Tree & Detail Objects:")]
[Space(5)]
[Tooltip("Draw trees, grass & details.")]
public bool m_draw = true;
[Tooltip("The distance (from camera) beyond which details will be culled.")]
[Range(0, 10000)]
public int m_detailDistance = 120;
[Tooltip("The number of detail/grass objects in a given unit of area. The value can be set lower to reduce rendering overhead.")]
[Range(0f, 1f)]
public float m_detailDensity = 1.0f;
[Tooltip("The distance (from camera) beyond which trees will be culled.")]
[Range(0, 2000)]
public int m_treeDistance = 500;
[Tooltip("The distance (from camera) at which 3D tree objects will be replaced by billboard images.")]
[Range(5, 2000)]
public int m_billboardStart = 50;
[Tooltip("Distance over which trees will transition between 3D objects and billboards.There is often a rotation effect as this kicks in.")]
[Range(0, 200)]
public int m_fadeLength = 20;
[Tooltip("The maximum number of visible trees that will be represented as solid 3D meshes. Beyond this limit, trees will be replaced with billboards.")]
[Range(0, 10000)]
public int m_maxMeshTrees = 50;
[Header("Wind Settings:")]
[Space(5)]
[Tooltip("The speed of the wind as it blows grass.")]
[Range(0f, 1f)]
public float m_speed = 0.35f;
[Tooltip("The size of the “ripples” on grassy areas as the wind blows over them.")]
[Range(0f, 1f)]
public float m_size = 0.12f;
[Tooltip("The degree to which grass objects are bent over by the wind.")]
[Range(0f, 1f)]
public float m_bending = 0.1f;
[Tooltip("Overall color tint applied to grass objects.")]
public Color m_grassTint = new Color(180f / 255f, 180f / 255f, 180f / 255f, 1f);
[Header("Resolution Settings:")]
[Space(5)]
[Tooltip("The size of terrain tile in X & Z axis (in world units).")]
public int m_terrainSize = 2048;
[Tooltip("The height of the terrain in world unit meters")]
public int m_terrainHeight = 700;
[Tooltip("This value increases or decreases the spawn density for all spawners in the scene (higher = more spawns)")]
public float m_spawnDensity = 1;
[Tooltip("Pixel resolution of the terrain’s heightmap (should be a power of two plus one e.g. 513 = 512 + 1). Higher resolutions allow for more detailed terrain features, at the cost of poorer performance.")]
public int m_heightmapResolution = 1025;
[Tooltip("Resolution of the map that determines the separate patches of details/grass. Higher resolution gives smaller and more detailed patches.")]
public int m_detailResolution = 1024;
[Tooltip("Length/width of the square of patches rendered with a single draw call.")]
public int m_detailResolutionPerPatch = 8;
[Tooltip("Resolution of the “splatmap” that controls the blending of the different terrain textures. Higher resolutions consumer more memory, but provide more accurate texturing.")]
public int m_controlTextureResolution = 1024;
[Tooltip("Resolution of the composite texture used on the terrain when viewed from a distance greater than the Basemap Distance (see above).")]
public int m_baseMapSize = 1024;
/// <summary>
/// Create the terrain defined by these settings
/// </summary>
//public void CreateTerrain()
//{
// Terrain[,] world;
// GaiaSettings gaiaSettings = GaiaUtils.GetGaiaSettings();
// //Update the session
// GaiaSessionManager sessionMgr = GaiaSessionManager.GetSessionManager();
// if (sessionMgr != null && sessionMgr.IsLocked() != true)
// {
// //Update terrain settings in session
// sessionMgr.m_session.m_terrainWidth = gaiaSettings.m_tilesX * m_terrainSize;
// sessionMgr.m_session.m_terrainDepth = gaiaSettings.m_tilesZ * m_terrainSize;
// sessionMgr.m_session.m_terrainHeight = m_terrainHeight;
// sessionMgr.AddDefaults(this);
// sessionMgr.SetSeaLevel(m_seaLevel);
// //Then add the operation
// GaiaOperation op = new GaiaOperation();
// op.m_description = "Creating terrain";
// op.m_isActive = true;
// op.m_operationDateTime = DateTime.Now.ToString();
// op.m_operationType = GaiaOperation.OperationType.CreateWorld;
// sessionMgr.AddOperation(op);
// }
// //Create the terrains array
// world = new Terrain[gaiaSettings.m_tilesX, gaiaSettings.m_tilesZ];
// //And iterate through and create each terrain
// for (int x = 0; x < gaiaSettings.m_tilesX; x++)
// {
// for (int z = 0; z < gaiaSettings.m_tilesZ; z++)
// {
// GameObject terrainGO = CreateTile(x, z, ref world, null, null, null);
// //Parent it to the scene -either below the terrain object, or if selected, as one scene each
// GameObject gaiaObj = GaiaUtils.GetTerrainObject();
// terrainGO.transform.SetParent(gaiaObj.transform);
// }
// }
// //Now join them together and remove their seams
// RemoveWorldSeams(ref world);
//}
/// <summary>
/// Update the defaults if possible from the currently selected terrain
/// </summary>
public void UpdateFromTerrain()
{
Terrain terrain = GetActiveTerrain();
if (terrain == null)
{
Debug.Log("Could not update from active terrain - no current active terrain");
return;
}
m_baseMapDist = (int)terrain.basemapDistance;
#if UNITY_2019_1_OR_NEWER
m_shadowCastingMode = terrain.shadowCastingMode;
#else
m_castShadows = terrain.castShadows;
#endif
m_detailDensity = terrain.detailObjectDensity;
m_detailDistance = (int)terrain.detailObjectDistance;
m_pixelError = (int)terrain.heightmapPixelError;
m_billboardStart = (int)terrain.treeBillboardDistance;
m_fadeLength = (int)terrain.treeCrossFadeLength;
m_treeDistance = (int)terrain.treeDistance;
m_maxMeshTrees = terrain.treeMaximumFullLODCount;
#if (!UNITY_2019_2_OR_NEWER)
if (terrain.materialType == Terrain.MaterialType.Custom)
{
#endif
m_material = terrain.materialTemplate;
#if (!UNITY_2019_2_OR_NEWER)
}
#endif
TerrainCollider collider = terrain.GetComponent<TerrainCollider>();
if (collider != null)
{
m_physicsMaterial = collider.material;
}
TerrainData terrainData = terrain.terrainData;
m_controlTextureResolution = terrainData.alphamapResolution;
m_baseMapSize = terrainData.baseMapResolution;
m_detailResolution = terrainData.detailResolution;
//m_detailResolutionPerPatch = terrainData.
m_heightmapResolution = terrainData.heightmapResolution;
m_bending = terrainData.wavingGrassAmount;
m_size = terrainData.wavingGrassSpeed;
m_speed = terrainData.wavingGrassStrength;
m_grassTint = terrainData.wavingGrassTint;
m_terrainSize = (int)terrainData.size.x;
m_terrainHeight = (int)terrainData.size.y;
}
/// <summary>
/// Takes a spawner preset list and assembles arrays with the new prototypes in them. If a reference Terrain is passed in, the arrays will contain the existing prototypes on the terrain + only the additional stuff from the preset list, no duplicates.
/// </summary>
/// <param name="spawnerPresetList"></param>
/// <param name="terrainLayers"></param>
/// <param name="terrainDetails"></param>
/// <param name="terrainTrees"></param>
/// <param name="referenceTerrain"></param>
public static void GetPrototypes(List<BiomeSpawnerListEntry> spawnerPresetList, ref TerrainLayer[] terrainLayers, ref DetailPrototype[] terrainDetails, ref TreePrototype[] terrainTrees, Terrain referenceTerrain = null)
{
//Early out when no spawner preset list
if (spawnerPresetList == null || spawnerPresetList.Count == 0)
{
return;
}
//collect the splat prototypes in a GaiaSplatPrototype List first, then build a terrain layer array from that later
List<GaiaSplatPrototype> presetSplatPrototypes = new List<GaiaSplatPrototype>();
List<DetailPrototype> presetTerrainDetails = new List<DetailPrototype>();
List<TreePrototype> presetTerrainTrees = new List<TreePrototype>();
//if there is a reference terrain, start by pre-filling those lists with the prototypes from the terrain
if (referenceTerrain != null)
{
foreach (TerrainLayer layer in referenceTerrain.terrainData.terrainLayers)
{
presetSplatPrototypes.Add(new GaiaSplatPrototype(layer));
}
foreach (DetailPrototype detailPrototype in referenceTerrain.terrainData.detailPrototypes)
{
presetTerrainDetails.Add(detailPrototype);
}
foreach (TreePrototype treePrototype in referenceTerrain.terrainData.treePrototypes)
{
presetTerrainTrees.Add(treePrototype);
}
}
foreach (BiomeSpawnerListEntry preset in spawnerPresetList.Where(x => x.m_autoAssignPrototypes == true))
{
if (preset == null)
{
//Skip entries missing information
continue;
}
if (preset.m_spawnerSettings == null)
{
continue;
}
if (preset.m_spawnerSettings.m_resources == null)
{
continue;
}
GaiaResource resources = preset.m_spawnerSettings.m_resources;
foreach (SpawnRule sr in preset.m_spawnerSettings.m_spawnerRules)
{
//skip if resource is not maintained properly (=null)
if (sr.ResourceIsNull(preset.m_spawnerSettings))
{
Debug.Log("Spawn Rule " + sr.m_name + " in " + preset.m_spawnerSettings.name + " has missing resources maintained. This rule might not work properly when spawning later.");
continue;
}
switch (sr.m_resourceType)
{
case GaiaConstants.SpawnerResourceType.TerrainTexture:
ResourceProtoTexture protoTexture = resources.m_texturePrototypes[sr.m_resourceIdx];
if (protoTexture != null)
{
GaiaSplatPrototype newSplat = new GaiaSplatPrototype();
newSplat.normalMap = protoTexture.m_normal;
newSplat.normalScale = protoTexture.m_normalScale;
newSplat.smoothness = protoTexture.m_smoothness;
newSplat.metallic = protoTexture.m_metallic;
newSplat.diffuseRemapMin = protoTexture.m_diffuseRemapMin;
newSplat.diffuseRemapMax = protoTexture.m_diffuseRemapMax;
newSplat.maskMapRemapMin = protoTexture.m_maskMapRemapMin;
newSplat.maskMapRemapMax = protoTexture.m_maskMapRemapMax;
newSplat.specularColor = protoTexture.m_specularColor;
newSplat.tileOffset = new Vector2(protoTexture.m_offsetX, protoTexture.m_offsetY);
newSplat.tileSize = new Vector2(protoTexture.m_sizeX, protoTexture.m_sizeY);
newSplat.texture = protoTexture.m_texture;
newSplat.maskMap = protoTexture.m_maskmap;
//Only add as a new prototype if not a fully equal prototype already exists in the list
if (!presetSplatPrototypes.Exists(x => x.texture == newSplat.texture &&
x.normalMap == newSplat.normalMap &&
x.tileOffset == newSplat.tileOffset &&
x.tileSize == newSplat.tileSize
))
{
presetSplatPrototypes.Add(newSplat);
}
}
break;
case GaiaConstants.SpawnerResourceType.TerrainDetail:
ResourceProtoDetail protoDetail = resources.m_detailPrototypes[sr.m_resourceIdx];
if (protoDetail != null)
{
DetailPrototype newTerrainDetail = new DetailPrototype();
newTerrainDetail.renderMode = protoDetail.m_renderMode;
newTerrainDetail.prototypeTexture = protoDetail.m_detailTexture;
newTerrainDetail.prototype = protoDetail.m_detailProtoype;
newTerrainDetail.dryColor = protoDetail.m_dryColour;
newTerrainDetail.healthyColor = protoDetail.m_healthyColour;
newTerrainDetail.maxHeight = protoDetail.m_maxHeight;
newTerrainDetail.maxWidth = protoDetail.m_maxWidth;
newTerrainDetail.minHeight = protoDetail.m_minHeight;
newTerrainDetail.minWidth = protoDetail.m_minWidth;
newTerrainDetail.noiseSpread = protoDetail.m_noiseSpread;
if ((protoDetail.m_renderMode == DetailRenderMode.Grass && protoDetail.m_detailProtoype == null) || protoDetail.m_renderMode == DetailRenderMode.GrassBillboard)
{
if (!presetTerrainDetails.Exists(x => x.prototypeTexture == newTerrainDetail.prototypeTexture &&
x.prototype == newTerrainDetail.prototype &&
x.dryColor == newTerrainDetail.dryColor &&
x.healthyColor == newTerrainDetail.healthyColor &&
x.maxHeight == newTerrainDetail.maxHeight &&
x.maxWidth == newTerrainDetail.maxWidth &&
x.minHeight == newTerrainDetail.minHeight &&
x.minWidth == newTerrainDetail.minWidth &&
x.noiseSpread == newTerrainDetail.noiseSpread
))
{
presetTerrainDetails.Add(newTerrainDetail);
}
}
else
{
if (!presetTerrainDetails.Exists(x => x.prototype == newTerrainDetail.prototype &&
x.prototype == newTerrainDetail.prototype &&
x.dryColor == newTerrainDetail.dryColor &&
x.healthyColor == newTerrainDetail.healthyColor &&
x.maxHeight == newTerrainDetail.maxHeight &&
x.maxWidth == newTerrainDetail.maxWidth &&
x.minHeight == newTerrainDetail.minHeight &&
x.minWidth == newTerrainDetail.minWidth &&
x.noiseSpread == newTerrainDetail.noiseSpread
))
{
presetTerrainDetails.Add(newTerrainDetail);
}
}
}
break;
case GaiaConstants.SpawnerResourceType.TerrainTree:
ResourceProtoTree protoTree = resources.m_treePrototypes[sr.m_resourceIdx];
if (protoTree != null)
{
TreePrototype newTree = new TreePrototype();
newTree.bendFactor = protoTree.m_bendFactor;
newTree.prefab = protoTree.m_desktopPrefab;
if (!presetTerrainTrees.Exists(x => x.bendFactor == newTree.bendFactor &&
x.prefab == newTree.prefab))
{
presetTerrainTrees.Add(newTree);
}
}
break;
}
}
}
//now look at the existing terrain layers on the terrain again, and add only the additional new Splat Prototypes as new layers - all the other ones must exist on the terrains already
List<GaiaSplatPrototype> additionalSplatPrototypes = new List<GaiaSplatPrototype>();
List<DetailPrototype> additionalTerrainDetails = new List<DetailPrototype>();
List<TreePrototype> additionalTerrainTrees = new List<TreePrototype>();
//Do we have a refernece terrain? The only the splat prototypes with a higher index then what is currently present on the terrain already are relevant
if (referenceTerrain != null)
{
for (int i = referenceTerrain.terrainData.terrainLayers.Length; i <= presetSplatPrototypes.Count - 1; i++)
{
additionalSplatPrototypes.Add(presetSplatPrototypes[i]);
}
for (int i = referenceTerrain.terrainData.detailPrototypes.Length; i <= presetTerrainDetails.Count - 1; i++)
{
additionalTerrainDetails.Add(presetTerrainDetails[i]);
}
for (int i = referenceTerrain.terrainData.treePrototypes.Length; i <= presetTerrainTrees.Count - 1; i++)
{
additionalTerrainTrees.Add(presetTerrainTrees[i]);
}
}
else
{
//no reference terrain - we take preset prototypes collected before
additionalSplatPrototypes = presetSplatPrototypes;
additionalTerrainDetails = presetTerrainDetails;
additionalTerrainTrees = presetTerrainTrees;
}
//convert Gaia Splat Prototypes into actual terrain layer files
string layername = string.Format("Gaia_-{0:yyyyMMdd-HHmmss}", DateTime.Now);
TerrainLayer[] additionalTerrainLayers = GaiaSplatPrototype.CreateTerrainLayers(layername, additionalSplatPrototypes.ToArray());
if (referenceTerrain != null)
{
//got a reference terrain? return the existing prototypes so they are not altered and attach the truly new ones
terrainLayers = referenceTerrain.terrainData.terrainLayers;
terrainLayers = terrainLayers.Concat(additionalTerrainLayers).ToArray();
terrainDetails = referenceTerrain.terrainData.detailPrototypes;
terrainDetails = terrainDetails.Concat(additionalTerrainDetails.ToArray()).ToArray();
terrainTrees = referenceTerrain.terrainData.treePrototypes;
terrainTrees = terrainTrees.Concat(additionalTerrainTrees.ToArray()).ToArray();
}
else
{
//no reference terrain, just return all the new stuff directly
terrainLayers = additionalTerrainLayers;
terrainDetails = additionalTerrainDetails.ToArray();
terrainTrees = additionalTerrainTrees.ToArray();
}
}
public GaiaOperation GetTerrainCreationOperation(GaiaResource resources)
{
// //Then add the operation
// GaiaOperation op = new GaiaOperation();
// op.m_description = "Creating terrain";
// op.m_generatedByID = m_defaultsID;
// op.m_generatedByName = this.name;
// op.m_generatedByType = this.GetType().ToString();
// op.m_isActive = true;
// op.m_operationDateTime = DateTime.Now.ToString();
// op.m_operationType = GaiaOperation.OperationType.CreateTerrain;
//#if UNITY_EDITOR
// op.m_operationDataJson = new string[2];
// string ap = AssetDatabase.GetAssetPath(this);
// if (string.IsNullOrEmpty(ap))
// {
// op.m_operationDataJson[0] = "GaiaDefaults.asset";
// }
// else
// {
// op.m_operationDataJson[0] = AssetDatabase.GetAssetPath(this);
// }
// ap = AssetDatabase.GetAssetPath(resources);
// if (string.IsNullOrEmpty(ap))
// {
// op.m_operationDataJson[1] = "GaiaResources.asset";
// }
// else
// {
// op.m_operationDataJson[1] = AssetDatabase.GetAssetPath(resources);
// }
//#endif
//return op;
return null;
}
/// <summary>
/// Get the currently active terrain - or any terrain
/// </summary>
/// <returns>A terrain if there is one</returns>
public static Terrain GetActiveTerrain()
{
//Grab active terrain if we can
Terrain terrain = Terrain.activeTerrain;
if (terrain != null && terrain.isActiveAndEnabled)
{
return terrain;
}
//Then check rest of terrains
for (int idx = 0; idx < Terrain.activeTerrains.Length; idx++)
{
terrain = Terrain.activeTerrains[idx];
if (terrain != null && terrain.isActiveAndEnabled)
{
return terrain;
}
}
if (terrain == null)
{
Terrain findTerrainComponent = FindObjectOfType<Terrain>();
if (findTerrainComponent != null && findTerrainComponent.isActiveAndEnabled)
{
terrain = findTerrainComponent;
return terrain;
}
}
return null;
}
/// <summary>
/// Set these assets into the terrain provided
/// </summary>
/// <param name="terrain"></param>
public static void ApplyPrototypesToTerrain(Terrain terrain, TerrainLayer[] terrainLayers, DetailPrototype[] terrainDetails, TreePrototype[] terrainTrees)
{
// Do a terrain check
if (terrain == null)
{
Debug.LogWarning("Can not apply assets to terrain no terrain has been supplied.");
return;
}
if (terrainLayers != null && terrainLayers.Length > 0)
terrain.terrainData.terrainLayers = terrainLayers;
if (terrainDetails != null && terrainLayers.Length > 0)
terrain.terrainData.detailPrototypes = terrainDetails;
if (terrainTrees != null && terrainLayers.Length > 0)
terrain.terrainData.treePrototypes = terrainTrees;
terrain.Flush();
}
/// <summary>
/// Update the terrain tiles to relate properly to each other
/// </summary>
/// <param name="tiles"></param>
private void RemoveWorldSeams(ref Terrain[,] world)
{
GaiaSettings gaiaSettings = GaiaUtils.GetGaiaSettings();
//Set the neighbours of terrain to remove seams.
for (int x = 0; x < gaiaSettings.m_tilesX; x++)
{
for (int z = 0; z < gaiaSettings.m_tilesZ; z++)
{
Terrain right = null;
Terrain left = null;
Terrain bottom = null;
Terrain top = null;
if (x > 0) left = world[(x - 1), z];
if (x < gaiaSettings.m_tilesX - 1) right = world[(x + 1), z];
if (z > 0) bottom = world[x, (z - 1)];
if (z < gaiaSettings.m_tilesZ - 1) top = world[x, (z + 1)];
world[x, z].SetNeighbors(left, top, right, bottom);
}
}
}
///// <summary>
///// Serialise this as json
///// </summary>
///// <returns></returns>
//public string SerialiseJson()
//{
// fsData data;
// fsSerializer serializer = new fsSerializer();
// serializer.TrySerialize(this, out data);
// return fsJsonPrinter.CompressedJson(data);
//}
///// <summary>
///// Deserialise the suplied json into this object
///// </summary>
///// <param name="json">Source json</param>
//public void DeSerialiseJson(string json)
//{
// fsData data = fsJsonParser.Parse(json);
// fsSerializer serializer = new fsSerializer();
// var defaults = this;
// serializer.TryDeserialize<GaiaDefaults>(data, ref defaults);
//}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: de82eef1d1f4fe64bb00feb5caaadbd7
timeCreated: 1541099956
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: 527453cdc5a5bb749910422439df2557, type: 3}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,37 @@
using System.Collections.Generic;
using UnityEngine;
namespace Gaia
{
public enum DeletionTaskType { File, Directory}
public enum MaintenanceCheckType { Contains, Equals }
[System.Serializable]
public class DeletionTask
{
public string m_pathContains = "";
public DeletionTaskType m_taskType = DeletionTaskType.File;
public bool m_includeSubDirectories = true;
public MaintenanceCheckType m_checkType = MaintenanceCheckType.Contains;
public string m_Name = "";
public string m_fileExtension = "";
}
[System.Serializable]
public class RenameTask
{
public string m_oldPath = "";
public string m_newPath = "";
}
public class GaiaMaintenanceProfile : ScriptableObject
{
public List<DeletionTask> m_deletionTasks = new List<DeletionTask>();
public List<RenameTask> m_renameTasks = new List<RenameTask>();
public string[] meshColliderPrefabPaths;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: fa0e0327a29786245b7ca9f0083c1a21
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: dffcb73693a3ab445abdc7e1ad4b8bb3, type: 3}
userData:
assetBundleName:
assetBundleVariant:
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 2fbb2be698c926948831ff4e8f1d7162
timeCreated: 1540439134
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: 0d9969fbfa47c174d91e2b1158223852, type: 3}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,292 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System;
using System.Text;
using static Gaia.GaiaConstants;
#if UNITY_EDITOR
using UnityEditor;
#endif
using Gaia.Pipeline;
namespace Gaia
{
/// <summary>
/// This object stores Gaia settings. It remembers what you have been working on, and resets these when you start up the Gaia Manager window.
/// </summary>
public class GaiaSettings : ScriptableObject
{
[Header("Current Settings")]
//[Tooltip("Shows Tips about following the general terrain generation workflow with Gaia in some of the Gaia Tools.")]
//public bool m_workflowTipsEnabled = true;
[Tooltip("The currently selected Controller Type")]
public GaiaConstants.EnvironmentControllerType m_currentController = GaiaConstants.EnvironmentControllerType.FirstPerson;
[Tooltip("Used to set the custom player object that gaia will attach scripts to")]
public GameObject m_customPlayerObject;
[Tooltip("Used to set the custom camera object that gaia will attach scripts to")]
public Camera m_customPlayerCamera;
[Tooltip("Target size.")]
public GaiaConstants.EnvironmentSize m_currentSize = GaiaConstants.EnvironmentSize.Is2048MetersSq;
[Tooltip("Current target environment.")]
public GaiaConstants.EnvironmentTarget m_currentEnvironment = GaiaConstants.EnvironmentTarget.Desktop;
[Tooltip("Current target renderer.")]
public GaiaConstants.EnvironmentRenderer m_currentRenderer = GaiaConstants.EnvironmentRenderer.BuiltIn;
[Tooltip("Current defaults object.")]
public GaiaDefaults m_currentDefaults;
[Range(1, 20), Tooltip("Number of tiles in X direction for a new terrain.")]
public int m_tilesX = 1;
[Range(1, 20), Tooltip("Number of tiles in Z direction for a new terrain.")]
public int m_tilesZ = 1;
[Tooltip("If terrains should be created in new scenes per default.")]
public bool m_createTerrainScenes = false;
[Tooltip("If scenes should be unloaded after creation per default.")]
public bool m_unloadTerrainScenes = false;
[Tooltip("If scenes should be unloaded after creation per default.")]
public bool m_floatingPointFix = false;
public GaiaConstants.EnvironmentSizePreset m_targeSizePreset = GaiaConstants.EnvironmentSizePreset.Large;
[Tooltip("Default Random Terrain Generation stamp spawn settings.")]
public SpawnerSettings m_defaultStampSpawnSettings;
[Tooltip("Default World Biome Mask settings.")]
public SpawnerSettings m_defaultBiomeMaskSettings;
public ComputeShader m_spawnSimulateComputeShader;
public ComputeShader m_terrainHeightsComputeShader;
//[Tooltip("Current terrain resources object.")]
//public GaiaResource m_currentResources;
//[Tooltip("Current game object resources object.")]
//public GaiaResource m_currentGameObjectResources;
[Tooltip("Current size divisor.")]
public float m_currentSizeDivisor = 1f;
[Tooltip("Current prefab name for the player object.")]
public string m_currentPlayerPrefabName = "FPSController";
[Tooltip("This prefab is what is sapwnned and attached to the Fly camera if the fly camera is being used in Gaia.")]
public GameObject m_flyCamUI;
[Tooltip("Current prefab name for the water object.")]
public string m_currentWaterPrefabName = "Water4Advanced";
[Tooltip("This setting will write baked collision data as image files to the disk when saving the scene. This allows you to close a scene and continue working on it later without having to re-bake collision data.")]
public bool m_saveCollisionCacheWhenSaving = false;
//[Tooltip("The selected sky to set up from the Gaia Manager Standard Tab")]
//public GaiaConstants.GaiaLightingProfileType m_currentSkies;
[Tooltip("When using dynamically loaded terrains, Gaia will keep terrain scenes in memory until this memory usage is reached before it starts to unload them again.")]
public long m_terrainUnloadMemoryTreshold = 4294967296;
[Tooltip("The default Terrain Layer that is used on the world map")]
public TerrainLayer m_worldmapLayer;
[Tooltip("Sets if ambient audio should be spawned or not into the scene")]
public bool m_enableAmbientAudio = true;
[Tooltip("Sets if post processing should be added to the scene")]
public bool m_enablePostProcessing = true;
[Tooltip("Enables the location manager system for the current scene. Allows you to create bookmarks to remember your player position and rotation of the camera")]
public bool m_enableLocationManager = true;
[Tooltip("Enables the loading screen system for the current scene. ")]
public bool m_enableLoadingScreen = true;
[Tooltip("The selected Post FX to set up from the Gaia Manager Standard Tab")]
public GaiaConstants.PostFX m_currentPostFX;
[Tooltip("The selected Water to set up from the Gaia Manager Standard Tab")]
public GaiaConstants.Water m_currentWater;
[Tooltip("The selected Water to set up from the Gaia Manager Standard Tab")]
public GaiaConstants.GaiaWaterProfileType m_currentWaterPro;
[Tooltip("Enables underwater features to be setup by Gaia.")]
public bool m_enableUnderwaterEffects = true;
[Tooltip("Whether a wind zone will be set up when creating a new terrain")]
public bool m_createWind;
public GaiaConstants.GaiaGlobalWindType m_windType = GaiaConstants.GaiaGlobalWindType.Calm;
[Tooltip("Whether a screen shotter will be set up when creating a new terrain")]
public bool m_createScreenShotter;
[Tooltip("If enabled this will focus the scene view camera at the created player spawned in the scene")]
public bool m_focusPlayerOnSetup = false;
[Tooltip("Default threshold for floating point fix")]
public float m_FPFDefaultThreshold = 5000;
[Tooltip("Name of the package for the XR controller")]
public string m_XRControllerPackageName = "GaiaXRController.unitypackage";
[Header("User Directory Settings")]
[Tooltip("Path for biome settings files. Must include 'Assets\' at the beginning.")]
public string m_biomesDirectory = "Assets/Gaia User Data/Biomes";
//[Tooltip("Path for exported files. Must include 'Assets\' at the beginning.")]
//public string m_exportsDirectory = "Assets/Gaia User Data/Exports";
[Tooltip("Path for screenshots. Must include 'Assets\' at the beginning.")]
public string m_screenshotsDirectory = "Assets/Gaia User Data/Screenshots";
[Tooltip("Path for session storage. Must include 'Assets\' at the beginning.")]
public string m_sessionsDirectory = "Assets/Gaia User Data/Sessions";
//[Tooltip("Path for terrain Texture layer storage. Must include 'Assets\' at the beginning.")]
//public string m_terrainLayersDirectory = "Assets/Gaia User Data/Terrain Layers";
[Tooltip("Path for general settings files (e.g Stamper Settings, Mask export settings, etc.) Must include 'Assets\' at the beginning.")]
public string m_userSettingsDirectory = "Assets/Gaia User Data/Settings";
[Tooltip("Path for Saved User Stamps. Must include 'Assets\' at the beginning.")]
public string m_userStampsDirectory = "Assets/Gaia User Data/Stamps";
[Header("Color Settings")]
[Tooltip("The color for the main action button in the Gaia tools (e.g. 'Stamp', etc.)")]
public Color m_actionButtonColor = new Color(0.4666667f, 0.6666667f, 0.2352941f);
[Tooltip("The color for the main action button in the Gaia tools (e.g. 'Stamp', etc.) - Pro Skin")]
public Color m_actionButtonProColor = new Color(0.2117647f, 0.3176471f, 0.09019608f);
[Tooltip("The color that indicates the stamp preview is active in the stamper.")]
public Color m_stamperPreviewButtonColor = new Color(0.5f, 0.5f, 1f, 1f);
[Tooltip("The color in which positive height changes are displayed in the stamp preview")]
public Color m_stamperPositiveHeightChangeColor = new Color(0.5611f, 0.9716f, 0.5362f, 1f);
[Tooltip("The color in which negative height changes are displayed in the stamp preview.")]
public Color m_stamperNegativeHeightChangeColor = new Color(0.8f, 0.8f, 0.8f, 1f);
[Tooltip("The color for the sea level tinting for the stamp preview.")]
public Color m_stamperSeaLevelTintColor = new Color(0f, 0.2151f, 0.7843f, 0.5f);
[Tooltip("The normal map influence for the stamp preview. (Can make the stamp shape easier to read)")]
[Range(0.0f, 1.0f)]
public float m_stamperNormalMapColorPower = 0.3f;
[Header("Stamper Settings")]
[Tooltip("Time in milliseconds to hide the stamp preview after stamping. Set to 0 for keeping it off after stamping, Set to 1 to immediately reactivate after stamping.")]
public long m_stamperAutoHidePreviewMilliseconds = 2000;
[Tooltip("Time in milliseconds to wait until triggering the automatic texture spawning in the stamper.")]
public long m_autoTextureTreshold = 250;
[Tooltip("Default Stamp that is loaded in when creating a new stamper.")]
public Texture2D m_defaultStamp;
[Header("Spawner Settings")]
[Tooltip("If enabled will hide all objects in the 'Gaia Game Object Spawns'")]
public bool m_hideObjectsInHierachy = false;
[Tooltip("The color spectrum from which the spawner chooses its preset visualisation colors.")]
public Gradient m_spawnerColorGradient = new Gradient() {
colorKeys = new GradientColorKey[] {
new GradientColorKey(new Color(0.7686275f,0.3960784f,0.3921569f),0),
new GradientColorKey(new Color(0.9411765f,0.9137255f,0.6f),0.25f),
new GradientColorKey(new Color(0.7215686f,0.7882353f,0.6156863f),0.5f),
new GradientColorKey(new Color(0.6078432f,0.4470588f,0.4352941f),0.75f),
new GradientColorKey(new Color(0.9333333f,0.6941177f,0.3568628f),1.0f),
}
};
[Tooltip("Time in milliseconds to hide the spawner preview after spawning. Set to 0 for keeping it off after spawning, Set to 1 to immediately reactivate after spawning.")]
public long m_spawnerAutoHidePreviewMilliseconds = 2000;
[Tooltip("The range that is used for spawners in world spawn mode to iterate over the World. Higher = faster spawns, but also more RAM consumption during spawning.")]
public int m_spawnerWorldSpawnRange = 1024;
[Tooltip("The spawner will display a warning when the number of game object spawns in a 100 x 100 area exceeds this threshold.")]
public int m_gameObjectCountWarningThreshold = 50;
[Tooltip("Prefab that will be used as a stand-in for trees in tree spawners")]
public GameObject m_boxStandInPrefab;
[Header("Publisher Settings")]
[Tooltip("Publisher name for exported extensions.")]
public string m_publisherName = "";
[Tooltip("Default prefab name for the first person player object.")]
public string m_fpsPlayerPrefabName = "FPSController";
[Tooltip("Default prefab name for the third person player object.")]
public string m_3pPlayerPrefabName = "ThirdPersonController";
[Tooltip("Default prefab name for the roller ball player object.")]
public string m_rbPlayerPrefabName = "RollerBall";
[Tooltip("Default prefab name for the car object")]
public string m_carPlayerPrefabName = "Gaia Car";
[Tooltip("Default prefab name for the light weight water object.")]
public string m_waterMobilePrefabName = "WaterBasicDaytime";
[Tooltip("Default prefab name for the water object.")]
public string m_waterPrefabName = "Water4Advanced";
[Tooltip("Show or hide tooltips in all custom editors.")]
public bool m_showTooltips = true;
[Header("Alternative Configurations")]
[Tooltip("Ultra light defaults object.")]
public GaiaDefaults m_ultraLightDefaults;
[Tooltip("Ultra light resources object.")]
public GaiaResource m_ultraLightResources;
[Tooltip("Ultra light gameobject resources object.")]
public GaiaResource m_ultraLightGameObjectResources;
[Tooltip("Mobile defaults object.")]
public GaiaDefaults m_mobileDefaults;
[Tooltip("Mobile resources object.")]
public GaiaResource m_mobileResources;
[Tooltip("Mobile game object resources object.")]
public GaiaResource m_mobileGameObjectResources;
[Tooltip("Desktop defaults object.")]
public GaiaDefaults m_desktopDefaults;
[Tooltip("Desktop resources object.")]
public GaiaResource m_desktopResources;
[Tooltip("Desktop game object resources object.")]
public GaiaResource m_desktopGameObjectResources;
[Tooltip("Powerful desktop defaults object.")]
public GaiaDefaults m_powerDesktopDefaults;
[Tooltip("Powerful desktop resources object.")]
public GaiaResource m_powerDesktopResources;
[Tooltip("Powerful desktop resources object.")]
public GaiaResource m_powerDesktopGameObjectResources;
[Header("Skies and Water Profiles")]
public GaiaLightingProfile m_gaiaLightingProfile;
public GaiaWaterProfile m_gaiaWaterProfile;
//public int m_selectedWaterProfile;
[Header("Pipeline Profile")]
public string m_gaiaProURL = "GaiaProURL";
public UnityPipelineProfile m_pipelineProfile;
[Header("Scene GUI Config")]
public PositionType m_terrainOpListPositionType = PositionType.Relative;
public Vector2 m_terrainOpListPosition;
public PositionType m_terrainOpListSizeType = PositionType.Relative;
public Vector2 m_terrainOpListSize;
public PositionType m_gaiaPanelPositionType = PositionType.Relative;
public Vector2 m_gaiaPanelPosition;
public PositionType m_gaiaPanelSizeType = PositionType.Relative;
public Vector2 m_gaiaPanelSize;
[Tooltip("Delay in milliseconds until the Tile X / Z sliders start loading in the terrains when changing the values (Gaia Pro Only)")]
public int m_gaiaPanelSliderDelay = 1000;
[Header("News")]
public long m_lastWebUpdate = 0;
public bool m_hideHeroMessage = false;
public string m_latestNewsTitle = "Latest News";
public string m_latestNewsBody = "Here is the news";
public string m_latestNewsUrl = "http://www.procedural-worlds.com/blog/";
public Texture2D m_latestNewsImage;
[Header("Misc UI Textures")]
public Texture2D m_originUIProBackgroundPro;
public Texture2D m_originUIBackground;
public Texture2D m_originUIUnfoldUp;
public Texture2D m_originUIUnfoldDown;
public Texture2D m_originUIProUnfoldUp;
public Texture2D m_originUIProUnfoldDown;
[Header("Icons")]
public Texture2D m_IconCancel;
public Texture2D m_IconCopy;
public Texture2D m_IconDown;
public Texture2D m_IconUp;
public Texture2D m_IconDuplicate;
public Texture2D m_IconPaste;
public Texture2D m_IconRemove;
public Texture2D m_IconVisible;
public Texture2D m_IconVisibleDisabled;
[Header("Pro Skin Icons")]
public Texture2D m_IconProCancel;
public Texture2D m_IconProCopy;
public Texture2D m_IconProDown;
public Texture2D m_IconProUp;
public Texture2D m_IconProDuplicate;
public Texture2D m_IconProPaste;
public Texture2D m_IconProRemove;
public Texture2D m_IconProVisible;
public Texture2D m_IconProVisibleDisabled;
public Color GetActionButtonColor()
{
#if UNITY_EDITOR
if (EditorGUIUtility.isProSkin)
{
return m_actionButtonProColor;
}
else
{
return m_actionButtonColor;
}
#else
return m_actionButtonColor;
#endif
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: cf0b22f014ec7be40896c70f04417587
timeCreated: 1540439723
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: dffcb73693a3ab445abdc7e1ad4b8bb3, type: 3}
userData:
assetBundleName:
assetBundleVariant:
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 6f2cc3b961cd7b449baebfe88a931494
timeCreated: 1443565835
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,107 @@
using System;
using UnityEngine;
namespace Gaia
{
/// <summary>
/// determines how the scale is set when a tree
/// </summary>
public enum SpawnScale { Fixed, Fitness, Random, FitnessRandomized }
/// <summary>
/// Used to control how the terrain world proptotypes work
/// </summary>
public struct ProtoDNAInst
{
public ResourceProtoDNA dna;
public Vector3 locationWU;
public Vector3 locationTU;
public int age;
}
[System.Serializable]
public class ResourceProtoDNA
{
[Tooltip("Radius from centre of object in world units for bounded area checks. Make this larger if you want more free space around your object when it is spawned.")]
public float m_boundsRadius = 1f; //The radius of this object - used to help calculate free area
//[Tooltip("The maximum distance a seed can be thrown when a new instance is spawned. Used to control spread area random clustered spawning.")]
//public float m_seedThrow = 12; //The distance a seed can be thrown
//[Tooltip("The minimum scale that this can be rendered into the world. For terrain details this is the minimum strength that detail will render at.")]
//public float m_minScale = 0.5f; //The minimum size this can grow as a % scale of original model
//[Tooltip("The maximum scale that this can be rendered into the world. For terrain details this is the maximum strength that detail will render at.")]
//public float m_maxScale = 1.5f; //The maximum size this can grow as a % scale of original model
//[Tooltip("Randomise the scale somewhere between minimum and maximum scale. If not selected then the scale will be proportionally influenced by the locations fitness.")]
//public bool m_rndScaleInfluence = false; //Allow the scale to be randomly influenced, otherwise pure fitness based
public float m_scaleMultiplier = 1f;
[Tooltip("Custom parameter to be interpreted by an extension if there is one. Use 'nograss' to exclude grass being grown within the volumne covered by the area bounds.")]
public string m_extParam = "";
[HideInInspector]
public int m_protoIdx = 0; //The prototype we are describing - internal use only - do not touch
/// <summary>
/// Update the prototype index
/// </summary>
/// <param name="protoIdx"></param>
public void Update(int protoIdx)
{
m_protoIdx = protoIdx;
}
/// <summary>
/// Update based on what we know
/// </summary>
/// <param name="protoIdx">The prototype we refer to</param>
/// <param name="width">The width in world units</param>
/// <param name="height">The height in world units</param>
public void Update(int protoIdx, float width, float height)
{
m_protoIdx = protoIdx;
//m_width = width;
//m_height = height;
m_boundsRadius = width;
//m_seedThrow = Mathf.Max(m_width, m_height) * 1.5f;
}
/// <summary>
/// Update based on what we know
/// </summary>
/// <param name="protoIdx">The prototype we refer to</param>
/// <param name="width">The width in world units</param>
/// <param name="height">The height in world units</param>
/// <param name="minscale">The minimim scale we will draw at</param>
/// <param name="maxscale">The maximum scale we will draw at</param>
public void Update(int protoIdx, float width, float height, float minscale, float maxscale)
{
m_protoIdx = protoIdx;
//m_width = width;
//m_height = height;
//m_boundsRadius = m_width;
//m_seedThrow = Mathf.Max(m_width, m_height) * 3;
//m_minScale = minscale;
//m_maxScale = maxscale;
}
/// <summary>
/// Return a scale between min and max that accounts for the fitness of the object
/// </summary>
/// <param name="fitness">Fitness - range of 0..1</param>
/// <returns>Scale</returns>
//public float GetScale(float fitness)
//{
// return m_minScale + ((m_maxScale - m_minScale) * fitness);
//}
/// <summary>
/// Return a scale between min and max that accounts for the fitness of the object, plus a random override
/// </summary>
/// <param name="fitness">Fitness - range of 0..1</param>
/// <param name="random">Random value - range of 0..1</param>
/// <returns>Scale</returns>
//public float GetScale(float fitness, float random)
//{
// return m_minScale + ((m_maxScale - m_minScale) * fitness * random);
//}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 14995611f77c54346aabfa826ed169ee
timeCreated: 1440036091
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,220 @@
using System;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using static Gaia.GaiaConstants;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace Gaia
{
/// <summary>
/// Used to serialise the detail prototypes
/// </summary>
[System.Serializable]
public class ResourceProtoDetail
{
[Tooltip("Resource name.")]
public string m_name;
[Tooltip("Render mode.")]
public DetailRenderMode m_renderMode = DetailRenderMode.Grass;
[Tooltip("Detail prototype - used by vertex lit render mode.")]
public GameObject m_detailProtoype;
[HideInInspector]
public string m_detailPrototypeFileName; // Used for re-association
[Tooltip("The texture that represents the grass and used by grass and billboard grass render mode.")]
public Texture2D m_detailTexture;
[HideInInspector]
public string m_detailTextureFileName; // Used for re-association
[Tooltip("Minimum width. Lower limit of the width of the clumps of grass that are generated.")]
public float m_minWidth = 1f;
[Tooltip("Maximum width. Upper limit of the width of the clumps of grass that are generated.")]
public float m_maxWidth = 2f;
[Tooltip("Minimum height. Lower limit of the height of the clumps of grass that are generated.")]
public float m_minHeight = 1f;
[Tooltip("Maximum height. Upper limit of the height of the clumps of grass that are generated.")]
public float m_maxHeight = 2f;
[Tooltip("Controls the approximate size of the alternating patches, with higher values indicating more variation within a given area."), Range(0f, 1f)]
public float m_noiseSpread = 0.3f;
[Tooltip("Healthy grass clump colour.")]
public Color m_healthyColour = Color.white;
[Tooltip("Dry grass clump colour.")]
public Color m_dryColour = Color.white;
[Tooltip("DNA - Used by the spawner to control how and where the grass will be spawned.")]
public ResourceProtoDNA m_dna;
[Tooltip("SPAWN CRITERIA - Spawn criteria are run against the terrain to assess its fitness in a range of 0..1 for use by this resource. If you add multiple criteria then the fittest one will be selected.")]
public SpawnCritera[] m_spawnCriteria = new SpawnCritera[0];
[Tooltip("SPAWN EXTENSIONS - Spawn extensions allow fitness, spawning and post spawning extensions to be made to the spawning system.")]
public SpawnRuleExtension[] m_spawnExtensions = new SpawnRuleExtension[0];
//[Tooltip("SPAWN MASKS - This list of masks can be used to determine where the terrain detail will appear on the terrain.")]
//public ImageMask[] m_imageMasks = new ImageMask[0];
public bool m_dnaFoldedOut;
/// <summary>
/// Initialise the detail
/// </summary>
/// <param name="spawner">The spawner it belongs to</param>
public void Initialise(Spawner spawner)
{
foreach (SpawnCritera criteria in m_spawnCriteria)
{
criteria.Initialise(spawner);
}
}
/// <summary>
/// Determine whether this has active criteria
/// </summary>
/// <returns>True if has actrive criteria</returns>
public bool HasActiveCriteria()
{
for (int idx = 0; idx < m_spawnCriteria.Length; idx++)
{
if (m_spawnCriteria[idx].m_isActive)
{
return true;
}
}
return false;
}
/// <summary>
/// Set up the asset associations, return true if something changes. Can only be run when the editor is present.
/// </summary>
/// <returns>True if something changes</returns>
public bool SetAssetAssociations()
{
bool isModified = false;
#if UNITY_EDITOR
if (m_detailProtoype != null)
{
string fileName = Path.GetFileName(AssetDatabase.GetAssetPath(m_detailProtoype));
if (fileName != m_detailPrototypeFileName)
{
m_detailPrototypeFileName = fileName;
isModified = true;
}
}
else
{
if (!string.IsNullOrEmpty(m_detailPrototypeFileName))
{
m_detailPrototypeFileName = "";
isModified = true;
}
}
if (m_detailTexture != null)
{
string fileName = Path.GetFileName(AssetDatabase.GetAssetPath(m_detailTexture));
if (fileName != m_detailTextureFileName)
{
m_detailTextureFileName = fileName;
isModified = true;
}
}
else
{
if (!string.IsNullOrEmpty(m_detailTextureFileName))
{
m_detailTextureFileName = "";
isModified = true;
}
}
#endif
return isModified;
}
/// <summary>
/// Associate any unallocated assets to this resource. Return true if something changes.
/// </summary>
/// <returns>True if the prototype was in some way modified</returns>
public bool AssociateAssets()
{
bool isModified = false;
#if UNITY_EDITOR
if (m_detailProtoype == null)
{
if (!string.IsNullOrEmpty(m_detailPrototypeFileName))
{
m_detailProtoype = GaiaUtils.GetAsset(m_detailPrototypeFileName, typeof(UnityEngine.GameObject)) as GameObject;
if (m_detailProtoype != null)
{
isModified = true;
}
}
}
if (m_detailTexture == null)
{
if (!string.IsNullOrEmpty(m_detailTextureFileName))
{
m_detailTexture = GaiaUtils.GetAsset(m_detailTextureFileName, typeof(UnityEngine.Texture2D)) as Texture2D;
if (m_detailTexture != null)
{
isModified = true;
}
}
}
#endif
return isModified;
}
/// <summary>
/// Determine whether this has active criteria that checks textures
/// </summary>
/// <returns>True if has active criteria that checks textures</returns>
public bool ChecksTextures()
{
for (int idx = 0; idx < m_spawnCriteria.Length; idx++)
{
if (m_spawnCriteria[idx].m_isActive && m_spawnCriteria[idx].m_checkTexture)
{
return true;
}
}
return false;
}
/// <summary>
/// Determine whether this has active criteria that checks proximity
/// </summary>
/// <returns>True if has active criteria that checks proximity</returns>
public bool ChecksProximity()
{
for (int idx = 0; idx < m_spawnCriteria.Length; idx++)
{
if (m_spawnCriteria[idx].m_isActive && m_spawnCriteria[idx].m_checkProximity)
{
return true;
}
}
return false;
}
/// <summary>
/// Add tags to the list if they are not already there
/// </summary>
/// <param name="tagList">The list to add the tags to</param>
public void AddTags(ref List<string> tagList)
{
for (int idx = 0; idx < m_spawnCriteria.Length; idx++)
{
if (m_spawnCriteria[idx].m_isActive && m_spawnCriteria[idx].m_checkProximity)
{
if (!tagList.Contains(m_spawnCriteria[idx].m_proximityTag))
{
tagList.Add(m_spawnCriteria[idx].m_proximityTag);
}
}
}
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 07a438ffe6a52ee4f91f96a9b90caa48
timeCreated: 1440036091
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,13 @@
using UnityEngine;
using System.Collections;
namespace Gaia
{
/// <summary>
/// Scriptable object wrapper about a detail
/// </summary>
public class ResourceProtoDetailSO : ScriptableObject
{
public ResourceProtoDetail m_detail;
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 47264cce5425d76428a30f4d5a9650cf
timeCreated: 1440409340
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,306 @@
using System;
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.IO;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace Gaia
{
[System.Serializable]
public class ResourceProtoGameObjectInstance
{
[Tooltip("Instance name.")]
public string m_name;
[Tooltip("Desktop prefab.")]
public GameObject m_desktopPrefab;
[HideInInspector]
public string m_desktopPrefabFileName; // Used for re-association
//[Tooltip("Mobile prefab - future proofing here - not currently used.")]
//public GameObject m_mobilePrefab;
//[HideInInspector]
//public string m_mobilePrefabFileName; // Used for re-association
//V1.5 from here
[Tooltip("Minimum number of instances to spawn.")]
public int m_minInstances = 1;
[Tooltip("Maximum number of instances to spawn.")]
public int m_maxInstances = 1;
[Tooltip("The failure chance of each spawn attempt."), Range(0f, 1f)]
public float m_failureRate = 0f;
[Tooltip("Minimum X offset from spawn point in meters to intantiate at. Can use this to move objects relative to the spawn point chosen.")]
public float m_minSpawnOffsetX = 0f;
[Tooltip("Maximum X offset from spawn point in meters to intantiate at. Can use this to move objects relative to the spawn point chosen.")]
public float m_maxSpawnOffsetX = 0f;
[Tooltip("Minimum Y offset from terrain in meters to intantiate at. Can use this to move embed or raise objects from the terrain.")]
public float m_minSpawnOffsetY = -0.3f;
[Tooltip("Maximum Y offset from terrain in meters to intantiate at. Can use this to move embed or raise objects from the terrain.")]
public float m_maxSpawnOffsetY = -0.1f;
[Tooltip("Minimum Z offset from spawn point in meters to intantiate at. Can use this to move objects relative to the spawn point chosen.")]
public float m_minSpawnOffsetZ = 0f;
[Tooltip("Maximum Z offset from spawn point in meters to intantiate at. Can use this to move objects relative to the spawn point chosen.")]
public float m_maxSpawnOffsetZ = 0f;
[Tooltip("Rotate the object to the terrain normal. Allows natural slope following. Great for things like trees to give them a little more variation in your scene.")]
public bool m_rotateToSlope = false;
[Tooltip("Should the Y-Offset be applied in the direction of the terrain slope rather than straight upwards")]
public bool m_yOffsetToSlope = false;
[Tooltip("Minimum X rotation from spawned rotation to intantiate at. Can use this to rotate objects relative to spawn point rotation.")]
[Range(-180f, 180f)]
public float m_minRotationOffsetX = 0f;
[Tooltip("Maximum X rotation from spawned rotation to intantiate at. Can use this to rotate objects relative to spawn point rotation."), Range(-180f, 180f)]
public float m_maxRotationOffsetX = 0f;
[Tooltip("Minimum Y rotation from spawned rotation to intantiate at. Can use this to rotate objects relative to spawn point rotation."), Range(-180f, 180f)]
public float m_minRotationOffsetY = -180f;
[Tooltip("Maximum Y rotation from spawned rotation to intantiate at. Can use this to rotate objects relative to spawn point rotation."), Range(-180f, 180f)]
public float m_maxRotationOffsetY = 180f;
[Tooltip("Minimum Z rotation from spawned rotation to intantiate at. Can use this to rotate objects relative to spawn point rotation."), Range(-180f, 180f)]
public float m_minRotationOffsetZ = 0f;
[Tooltip("Maximum Z rotation from spawned rotation to intantiate at. Can use this to rotate objects relative to spawn point rotation."), Range(-180f, 180f)]
public float m_maxRotationOffsetZ = 0f;
[Tooltip("Minimum scale."), Range(0f, 20f)]
public float m_minScale = 1f;
[Tooltip("Maximum scale."), Range(0f, 20)]
public float m_maxScale = 1f;
[Tooltip("Influence scale between min and max scale based on distance from spawn point centre.")]
public AnimationCurve m_scaleByDistance = new AnimationCurve(new Keyframe(0f, 1f), new Keyframe(1f, 1f));
[Tooltip("Local bounds radius of this instance.")]
public float m_localBounds = 5f;
[Tooltip("Will only spawn on virgin terrain.")]
public bool m_virginTerrain = true;
[Tooltip("Custom parameter to be interpreted by an extension if there is one.")]
public string m_extParam = "";
public SpawnScale m_spawnScale = SpawnScale.Fixed;
public bool m_commonScale = true;
public Vector3 m_minXYZScale = new Vector3(0.75f, 0.75f, 0.75f);
public Vector3 m_maxXYZScale = new Vector3(1.5f, 1.5f, 1.5f);
public float m_scaleRandomPercentage = 0.5f;
public Vector3 m_XYZScaleRandomPercentage = new Vector3(0.5f, 0.5f, 0.5f);
//Just a control flag to store if this instance is folded out
[HideInInspector]
public bool m_foldedOut;
}
[System.Serializable]
public class ResourceProtoGameObject
{
[Tooltip("Resource name.")]
public string m_name;
[Tooltip("The game objects that will be instantiated when this is spawned.")]
public ResourceProtoGameObjectInstance[] m_instances = new ResourceProtoGameObjectInstance[0];
[Tooltip("DNA - Used by the spawner to control how and where the game objects will be spawned.")]
public ResourceProtoDNA m_dna = new ResourceProtoDNA();
[Tooltip("SPAWN CRITERIA - Spawn criteria are run against the terrain to assess its fitness in a range of 0..1 for use by this resource. If you add multiple criteria then the fittest one will be selected.")]
public SpawnCritera[] m_spawnCriteria = new SpawnCritera[0];
[Tooltip("SPAWN EXTENSIONS - Spawn extensions allow fitness, spawning and post spawning extensions to be made to the spawning system.")]
public SpawnRuleExtension[] m_spawnExtensions = new SpawnRuleExtension[0];
[Tooltip("Set this to true if you want this included in tree based spawner creation.")]
public bool m_canSpawnAsTree = false;
//[Tooltip("SPAWN MASKS - This list of masks can be used to determine where the terrain detail will appear on the terrain.")]
//public ImageMask[] m_imageMasks = new ImageMask[0];
//just a control flag to store if the instances list is folded out or not
[HideInInspector]
public bool m_instancesFoldOut;
public bool m_dnaFoldedOut;
/// <summary>
/// Initialise the game object
/// </summary>
/// <param name="spawner">The spawner it belongs to</param>
public void Initialise(Spawner spawner)
{
foreach (SpawnCritera criteria in m_spawnCriteria)
{
criteria.Initialise(spawner);
}
}
/// <summary>
/// Determine whether this has active criteria
/// </summary>
/// <returns>True if has actrive criteria</returns>
public bool HasActiveCriteria()
{
for (int idx = 0; idx < m_spawnCriteria.Length; idx++)
{
if (m_spawnCriteria[idx].m_isActive)
{
return true;
}
}
return false;
}
/// <summary>
/// Set up the asset associations, return true if something changes. Can only be run when the editor is present.
/// </summary>
/// <returns>True if something changes</returns>
public bool SetAssetAssociations()
{
bool isModified = false;
#if UNITY_EDITOR
ResourceProtoGameObjectInstance goInstance;
for (int idx = 0; idx < m_instances.GetLength(0); idx++)
{
goInstance = m_instances[idx];
if (goInstance.m_desktopPrefab != null)
{
string fileName = Path.GetFileName(AssetDatabase.GetAssetPath(goInstance.m_desktopPrefab));
if (fileName != goInstance.m_desktopPrefabFileName)
{
goInstance.m_desktopPrefabFileName = fileName;
isModified = true;
}
}
else
{
if (!string.IsNullOrEmpty(goInstance.m_desktopPrefabFileName))
{
goInstance.m_desktopPrefabFileName = "";
isModified = true;
}
}
//if (goInstance.m_mobilePrefab != null)
//{
// string fileName = Path.GetFileName(AssetDatabase.GetAssetPath(goInstance.m_mobilePrefab));
// if (fileName != goInstance.m_mobilePrefabFileName)
// {
// goInstance.m_mobilePrefabFileName = fileName;
// isModified = true;
// }
//}
//else
//{
// if (!string.IsNullOrEmpty(goInstance.m_mobilePrefabFileName))
// {
// goInstance.m_mobilePrefabFileName = "";
// isModified = true;
// }
//}
}
#endif
return isModified;
}
/// <summary>
/// Associate any unallocated assets to this resource. Return true if something changes.
/// </summary>
/// <returns>True if the prototype was in some way modified</returns>
public bool AssociateAssets()
{
bool isModified = false;
#if UNITY_EDITOR
ResourceProtoGameObjectInstance goInstance;
for (int idx = 0; idx < m_instances.GetLength(0); idx++)
{
goInstance = m_instances[idx];
if (goInstance.m_desktopPrefab == null)
{
if (!string.IsNullOrEmpty(goInstance.m_desktopPrefabFileName))
{
goInstance.m_desktopPrefab = GaiaUtils.GetAsset(goInstance.m_desktopPrefabFileName, typeof(UnityEngine.GameObject)) as GameObject;
if (goInstance.m_desktopPrefab != null)
{
isModified = true;
}
}
}
//if (goInstance.m_mobilePrefab == null)
//{
// if (!string.IsNullOrEmpty(goInstance.m_mobilePrefabFileName))
// {
// goInstance.m_mobilePrefab = GaiaUtils.GetAsset(goInstance.m_mobilePrefabFileName, typeof(UnityEngine.GameObject)) as GameObject;
// if (goInstance.m_mobilePrefab != null)
// {
// isModified = true;
// }
// }
//}
}
#endif
return isModified;
}
/// <summary>
/// Determine whether this has active criteria that checks textures
/// </summary>
/// <returns>True if has active criteria that checks textures</returns>
public bool ChecksTextures()
{
for (int idx = 0; idx < m_spawnCriteria.Length; idx++)
{
if (m_spawnCriteria[idx].m_isActive && m_spawnCriteria[idx].m_checkTexture)
{
return true;
}
}
return false;
}
/// <summary>
/// Determine whether this has active criteria that checks proximity
/// </summary>
/// <returns>True if has active criteria that checks proximity</returns>
public bool ChecksProximity()
{
for (int idx = 0; idx < m_spawnCriteria.Length; idx++)
{
if (m_spawnCriteria[idx].m_isActive && m_spawnCriteria[idx].m_checkProximity)
{
return true;
}
}
return false;
}
/// <summary>
/// Add tags to the list if they are not already there
/// </summary>
/// <param name="tagList">The list to add the tags to</param>
public void AddTags(ref List<string> tagList)
{
for (int idx = 0; idx < m_spawnCriteria.Length; idx++)
{
if (m_spawnCriteria[idx].m_isActive && m_spawnCriteria[idx].m_checkProximity)
{
if (!tagList.Contains(m_spawnCriteria[idx].m_proximityTag))
{
tagList.Add(m_spawnCriteria[idx].m_proximityTag);
}
}
}
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: f52dba1238c03674ab746782455dece9
timeCreated: 1440036091
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,13 @@
using UnityEngine;
using System.Collections;
namespace Gaia
{
/// <summary>
/// Scriptable object wrapper around a game object prototype
/// </summary>
public class ResourceProtoGameObjectSO : ScriptableObject
{
public ResourceProtoGameObject m_gameObject;
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: f24a4406166844e48a6ba3a1b9a66a62
timeCreated: 1440409542
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,262 @@
using System;
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.IO;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace Gaia
{
[System.Serializable]
public class ResourceProtoSpawnExtensionInstance
{
public string m_name;
public GameObject m_spawnerPrefab;
//[HideInInspector]
public string m_spawnerPrefabFileName; // Used for re-association
////[Tooltip("Mobile prefab - future proofing here - not currently used.")]
////public GameObject m_mobilePrefab;
////[HideInInspector]
//public string m_mobilePrefabFileName; // Used for re-association
//V1.5 from here
public int m_minSpawnerRuns = 1;
public int m_maxSpawnerRuns = 1;
public float m_failureRate = 0f;
public float m_minSpawnOffsetX = 0f;
public float m_maxSpawnOffsetX = 0f;
//[Tooltip("Minimum Y offset from terrain in meters to intantiate at. Can use this to move embed or raise objects from the terrain.")]
public float m_minSpawnOffsetY = -0.3f;
//[Tooltip("Maximum Y offset from terrain in meters to intantiate at. Can use this to move embed or raise objects from the terrain.")]
public float m_maxSpawnOffsetY = -0.1f;
public float m_minSpawnOffsetZ = 0f;
public float m_maxSpawnOffsetZ = 0f;
//[Tooltip("Rotate the object to the terrain normal. Allows natural slope following. Great for things like trees to give them a little more variation in your scene.")]
//public bool m_rotateToSlope = false;
//[Tooltip("Minimum X rotation from spawned rotation to intantiate at. Can use this to rotate objects relative to spawn point rotation.")]
[Range(-180f, 180f)]
public float m_minRotationOffsetX = 0f;
//[Tooltip("Maximum X rotation from spawned rotation to intantiate at. Can use this to rotate objects relative to spawn point rotation."), Range(-180f, 180f)]
public float m_maxRotationOffsetX = 0f;
//[Tooltip("Minimum Y rotation from spawned rotation to intantiate at. Can use this to rotate objects relative to spawn point rotation."), Range(-180f, 180f)]
public float m_minRotationOffsetY = -180f;
//[Tooltip("Maximum Y rotation from spawned rotation to intantiate at. Can use this to rotate objects relative to spawn point rotation."), Range(-180f, 180f)]
public float m_maxRotationOffsetY = 180f;
//[Tooltip("Minimum Z rotation from spawned rotation to intantiate at. Can use this to rotate objects relative to spawn point rotation."), Range(-180f, 180f)]
public float m_minRotationOffsetZ = 0f;
//[Tooltip("Maximum Z rotation from spawned rotation to intantiate at. Can use this to rotate objects relative to spawn point rotation."), Range(-180f, 180f)]
public float m_maxRotationOffsetZ = 0f;
//[Tooltip("Get object scale from parent scale.")]
//public bool m_useParentScale = true;
//[Tooltip("Minimum scale."), Range(0f, 20f)]
public float m_minScale = 1f;
//[Tooltip("Maximum scale."), Range(0f, 20)]
public float m_maxScale = 1f;
//[Tooltip("Influence scale between min and max scale based on distance from spawn point centre.")]
public AnimationCurve m_scaleByDistance = new AnimationCurve(new Keyframe(0f, 1f), new Keyframe(1f, 1f));
//[Tooltip("Local bounds radius of this instance.")]
//public float m_localBounds = 5f;
//[Tooltip("Will only spawn on virgin terrain.")]
//public bool m_virginTerrain = true;
//[Tooltip("Custom parameter to be interpreted by an extension if there is one.")]
//public string m_extParam = "";
public SpawnScale m_spawnScale = SpawnScale.Fixed;
public bool m_commonScale = true;
public Vector3 m_minXYZScale = new Vector3(0.75f, 0.75f, 0.75f);
public Vector3 m_maxXYZScale = new Vector3(1.5f, 1.5f, 1.5f);
public float m_scaleRandomPercentage = 0.5f;
public Vector3 m_XYZScaleRandomPercentage = new Vector3(0.5f, 0.5f, 0.5f);
//Just a control flag to store if this instance is folded out
[HideInInspector]
public bool m_foldedOut;
public bool m_invalidPrefabSupplied;
}
[System.Serializable]
public class ResourceProtoSpawnExtension
{
public string m_name;
public ResourceProtoSpawnExtensionInstance[] m_instances = new ResourceProtoSpawnExtensionInstance[0];
public ResourceProtoDNA m_dna = new ResourceProtoDNA();
//[Tooltip("SPAWN MASKS - This list of masks can be used to determine where the terrain detail will appear on the terrain.")]
//public ImageMask[] m_imageMasks = new ImageMask[0];
//just a control flag to store if the instances list is folded out or not
[HideInInspector]
public bool m_instancesFoldOut;
public bool m_dnaFoldedOut;
/// <summary>
/// Set up the asset associations, return true if something changes. Can only be run when the editor is present.
/// </summary>
/// <returns>True if something changes</returns>
public bool SetAssetAssociations()
{
bool isModified = false;
#if UNITY_EDITOR
ResourceProtoSpawnExtensionInstance goInstance;
for (int idx = 0; idx < m_instances.GetLength(0); idx++)
{
goInstance = m_instances[idx];
if (goInstance.m_spawnerPrefab != null)
{
string fileName = Path.GetFileName(AssetDatabase.GetAssetPath(goInstance.m_spawnerPrefab));
if (fileName != goInstance.m_spawnerPrefabFileName)
{
goInstance.m_spawnerPrefabFileName = fileName;
isModified = true;
}
}
else
{
if (!string.IsNullOrEmpty(goInstance.m_spawnerPrefabFileName))
{
goInstance.m_spawnerPrefabFileName = "";
isModified = true;
}
}
//if (goInstance.m_mobilePrefab != null)
//{
// string fileName = Path.GetFileName(AssetDatabase.GetAssetPath(goInstance.m_mobilePrefab));
// if (fileName != goInstance.m_mobilePrefabFileName)
// {
// goInstance.m_mobilePrefabFileName = fileName;
// isModified = true;
// }
//}
//else
//{
// if (!string.IsNullOrEmpty(goInstance.m_mobilePrefabFileName))
// {
// goInstance.m_mobilePrefabFileName = "";
// isModified = true;
// }
//}
}
#endif
return isModified;
}
/// <summary>
/// Associate any unallocated assets to this resource. Return true if something changes.
/// </summary>
/// <returns>True if the prototype was in some way modified</returns>
public bool AssociateAssets()
{
bool isModified = false;
#if UNITY_EDITOR
ResourceProtoSpawnExtensionInstance goInstance;
for (int idx = 0; idx < m_instances.GetLength(0); idx++)
{
goInstance = m_instances[idx];
if (goInstance.m_spawnerPrefab == null)
{
if (!string.IsNullOrEmpty(goInstance.m_spawnerPrefabFileName))
{
goInstance.m_spawnerPrefab = GaiaUtils.GetAsset(goInstance.m_spawnerPrefabFileName, typeof(UnityEngine.GameObject)) as GameObject;
if (goInstance.m_spawnerPrefab != null)
{
isModified = true;
}
}
}
//if (goInstance.m_mobilePrefab == null)
//{
// if (!string.IsNullOrEmpty(goInstance.m_mobilePrefabFileName))
// {
// goInstance.m_mobilePrefab = GaiaUtils.GetAsset(goInstance.m_mobilePrefabFileName, typeof(UnityEngine.GameObject)) as GameObject;
// if (goInstance.m_mobilePrefab != null)
// {
// isModified = true;
// }
// }
//}
}
#endif
return isModified;
}
/// <summary>
/// Determine whether this has active criteria that checks textures
/// </summary>
/// <returns>True if has active criteria that checks textures</returns>
//public bool ChecksTextures()
//{
// for (int idx = 0; idx < m_spawnCriteria.Length; idx++)
// {
// if (m_spawnCriteria[idx].m_isActive && m_spawnCriteria[idx].m_checkTexture)
// {
// return true;
// }
// }
// return false;
//}
/// <summary>
/// Determine whether this has active criteria that checks proximity
/// </summary>
/// <returns>True if has active criteria that checks proximity</returns>
//public bool ChecksProximity()
//{
// for (int idx = 0; idx < m_spawnCriteria.Length; idx++)
// {
// if (m_spawnCriteria[idx].m_isActive && m_spawnCriteria[idx].m_checkProximity)
// {
// return true;
// }
// }
// return false;
//}
/// <summary>
/// Add tags to the list if they are not already there
/// </summary>
///// <param name="tagList">The list to add the tags to</param>
//public void AddTags(ref List<string> tagList)
//{
// for (int idx = 0; idx < m_spawnCriteria.Length; idx++)
// {
// if (m_spawnCriteria[idx].m_isActive && m_spawnCriteria[idx].m_checkProximity)
// {
// if (!tagList.Contains(m_spawnCriteria[idx].m_proximityTag))
// {
// tagList.Add(m_spawnCriteria[idx].m_proximityTag);
// }
// }
// }
//}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 2a3926b638425d341a5626924e73fec5
timeCreated: 1440036091
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using static Gaia.GaiaConstants;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace Gaia
{
public enum ProbeType { ReflectionProbe, LightProbe }
/// <summary>
/// Used to serialise the detail prototypes
/// </summary>
[System.Serializable]
public class ResourceProtoProbe
{
[Tooltip("Resource name.")]
public string m_name;
[Tooltip("Probe Type - what kind of probe this is")]
public ProbeType m_probeType = ProbeType.ReflectionProbe;
[Tooltip("Holds settings for reflection probes.")]
public ReflectionProbeData m_reflectionProbeData = new ReflectionProbeData();
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: a0f438a1d6172774d9f091ec73531257
timeCreated: 1440036091
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,132 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
namespace Gaia
{
public enum BorderMaskStyle {ImageMask, DistanceMask, None}
/// <summary>
/// Stores the settings for how often and at which size etc. a stamp from a certain feature (=stamp directory) appears
/// </summary>
///
[System.Serializable]
public class StampFeatureSettings
{
/// <summary>
/// The stamp directory name where stamps for this feature will be pulled from
/// </summary>
public string m_featureType;
/// <summary>
/// The influence setting for the stamp.
/// </summary>
public ImageMaskInfluence m_stampInfluence = ImageMaskInfluence.Global;
/// <summary>
/// The secondary mask used in the stamp to blend the stamp borders with the terrain.
/// </summary>
public BorderMaskStyle m_borderMaskStyle;
/// <summary>
/// The directory name where stamps for the secondary image mask will be pulled from
/// </summary>
public string m_borderMaskType = "Masks";
/// <summary>
/// The operation to perform for this stamp
/// </summary>
public GaiaConstants.TerrainGeneratorFeatureOperation m_operation = GaiaConstants.TerrainGeneratorFeatureOperation.RaiseHeight;
/// <summary>
/// only used internally to calculate the spawn chances during spawning
/// </summary>
public float m_stackedChance;
/// <summary>
/// The minimum width of the stamp
/// </summary>
public float m_minWidth = 50f;
/// <summary>
/// The maximum width of the stamp
/// </summary>
public float m_maxWidth = 200f;
/// <summary>
/// Whether the width should be tied to the strength of the spawn mask. If not, it will be rolled randomly.
/// </summary>
public bool m_tieWidthToStrength = true;
/// <summary>
/// The minimum height of the stamp
/// </summary>
public float m_minHeight = 1f;
/// <summary>
/// The maximum height of the stamp
/// </summary>
public float m_maxHeight = 5f;
/// <summary>
/// The minimum strength for a mix operation
/// </summary>
public float m_minMixStrength = 0.10f;
/// <summary>
/// The maximum strength for a mix operation
/// </summary>
public float m_maxMixStrength = 0.25f;
/// <summary>
/// The minimum mid point for a mix operation
/// </summary>
public float m_minMixMidPoint= 0.25f;
/// <summary>
/// The maximum mid point for a mix operation
/// </summary>
public float m_maxMixMidPoint = 0.75f;
/// <summary>
/// Whether the height should be tied to the strength of the spawn mask. If not, it will be rolled randomly.
/// </summary>
public bool m_tieHeightToStrength = true;
/// <summary>
/// The minimum height difference from the terrain surface of the stamp
/// </summary>
public float m_minYOffset = -1f;
/// <summary>
/// The maximum height difference from the terrain surface of the stamp
/// </summary>
public float m_maxYOffset = 1f;
/// <summary>
/// The chance that the stamp will be inverted
/// </summary>
public float m_invertChance = 0f;
/// <summary>
/// A mapping between the strength of the mask stack and the spawn chance - useful if you want to remap different feature types to different strengths of a mask
/// </summary>
public AnimationCurve m_chanceStrengthMapping = ImageMask.NewAnimCurveStraightUpwards();
/// <summary>
/// Whether these settings are currently folded out in the editor or not.
/// </summary>
public bool m_isFoldedOut = true;
private StampFeatureSettings x;
public StampFeatureSettings()
{
}
public StampFeatureSettings(StampFeatureSettings original)
{
GaiaUtils.CopyFields(original,this);
m_chanceStrengthMapping = new AnimationCurve(original.m_chanceStrengthMapping.keys);
}
}
/// <summary>
/// Prototype for stamps and their fitness
/// </summary>
[System.Serializable]
public class ResourceProtoStampDistribution
{
[Tooltip("Stamp name.")]
public string m_name;
[Tooltip("Feature Chances.")]
public List <StampFeatureSettings> m_featureSettings = new List<StampFeatureSettings>();
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 59a0e62871af8f14ba56e276c96101c4
timeCreated: 1442702659
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,272 @@
using System;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace Gaia
{
/// <summary>
/// Prototype for textures and their fitness
/// </summary>
[System.Serializable]
public class ResourceProtoTexture
{
[Tooltip("Resource name.")]
public string m_name;
[Tooltip("Resource texture.")]
public Texture2D m_texture;
#if SUBSTANCE_PLUGIN_ENABLED
public int substanceSourceIndex;
public Substance.Game.Substance m_substanceMaterial;
#endif
[HideInInspector]
public string m_textureFileName; //Used for re-association
[Tooltip("Resource normal.")]
public Texture2D m_normal;
public Texture2D m_maskmap;
public Texture2D m_CTSSmoothnessMap;
public Texture2D m_CTSRoughnessMap;
public Texture2D m_CTSHeightMap;
public Texture2D m_CTSAmbientOcclusionMap;
[HideInInspector]
public string m_normalFileName; //Used for re-association
[Tooltip("The width over which the image will stretch on the terrain’s surface.")]
public float m_sizeX = 10;
[Tooltip("The height over which the image will stretch on the terrain’s surface.")]
public float m_sizeY = 10;
[Tooltip("How far from the terrain’s anchor point the tiling will start.")]
public float m_offsetX = 0;
[Tooltip("How far from the terrain’s anchor point the tiling will start.")]
public float m_offsetY = 0;
[Tooltip("Controls the overall metalness of the surface."), Range(0f, 1f)]
public float m_metallic = 0f;
[Tooltip("Controls the overall smoothness of the surface."), Range(0f, 1f)]
public float m_smoothness = 0f;
[Tooltip("SPAWN CRITERIA - Spawn criteria are run against the terrain to assess its fitness in a range of 0..1 for use by this resource. If you add multiple criteria then the fittest one will be selected.")]
public SpawnCritera[] m_spawnCriteria = new SpawnCritera[0];
private string m_maskmapFileName;
/// <summary>
/// The GUID of a terrain layer that was created for this texture resource.
/// </summary>
public string m_LayerGUID;
public float m_normalScale = 1f;
public Vector4 m_diffuseRemapMax = new Vector4(1f,1f,1f,1f);
public Vector4 m_diffuseRemapMin = new Vector4(0f,0f,0f,0f);
public Vector4 m_maskMapRemapMax = new Vector4(1f,1f,1f,1f);
public Vector4 m_maskMapRemapMin = new Vector4(0f,0f,0f,0f);
public Color m_specularColor = new Color();
public bool m_channelRemapFoldedOut;
//[Tooltip("SPAWN MASKS - This list of masks can be used to determine where the texture will appear on the terrain.")]
//public ImageMask[] m_imageMasks = new ImageMask[0];
//[Tooltip("SPAWN EXTENSIONS - Spawn extensions allow fitness, spawning and post spawning extensions to be made to the spawning system.")]
//public SpawnRuleExtension[] m_spawnExtensions = new SpawnRuleExtension[0];
/// <summary>
/// Used to help locate the physical textures
/// </summary>
/// <summary>
/// Initialise the texture
/// </summary>
/// <param name="spawner">The spawner it belongs to</param>
public void Initialise(Spawner spawner)
{
foreach (SpawnCritera criteria in m_spawnCriteria)
{
criteria.Initialise(spawner);
}
}
/// <summary>
/// Determine whether this has active criteria
/// </summary>
/// <returns>True if has actrive criteria</returns>
public bool HasActiveCriteria()
{
for (int idx = 0; idx < m_spawnCriteria.Length; idx++)
{
if (m_spawnCriteria[idx].m_isActive)
{
return true;
}
}
return false;
}
/// <summary>
/// Set up the asset associations, return true if something changes. Can only be run when the editor is present.
/// </summary>
/// <returns>True if something changes</returns>
public bool SetAssetAssociations()
{
bool isModified = false;
#if UNITY_EDITOR
if (m_texture != null)
{
string fileName = Path.GetFileName(AssetDatabase.GetAssetPath(m_texture));
if (fileName != m_textureFileName)
{
m_textureFileName = fileName;
isModified = true;
}
}
else
{
if (!string.IsNullOrEmpty(m_textureFileName))
{
m_textureFileName = "";
isModified = true;
}
}
if (m_normal != null)
{
string fileName = Path.GetFileName(AssetDatabase.GetAssetPath(m_normal));
if (fileName != m_normalFileName)
{
m_normalFileName = fileName;
isModified = true;
}
}
else
{
if (!string.IsNullOrEmpty(m_normalFileName))
{
m_normalFileName = "";
isModified = true;
}
}
if (m_maskmap != null)
{
string fileName = Path.GetFileName(AssetDatabase.GetAssetPath(m_maskmap));
if (fileName != m_maskmapFileName)
{
m_maskmapFileName = fileName;
isModified = true;
}
}
else
{
if (!string.IsNullOrEmpty(m_maskmapFileName))
{
m_maskmapFileName = "";
isModified = true;
}
}
#endif
return isModified;
}
/// <summary>
/// Associate any unallocated assets to this resource. Return true if something changes.
/// </summary>
/// <returns>True if the prototype was in some way modified</returns>
public bool AssociateAssets()
{
bool isModified = false;
#if UNITY_EDITOR
if (m_texture == null)
{
if (!string.IsNullOrEmpty(m_textureFileName))
{
m_texture = GaiaUtils.GetAsset(m_textureFileName, typeof(UnityEngine.Texture2D)) as Texture2D;
if (m_texture != null)
{
isModified = true;
}
}
}
if (m_normal == null)
{
if (!string.IsNullOrEmpty(m_normalFileName))
{
m_normal = GaiaUtils.GetAsset(m_normalFileName, typeof(UnityEngine.Texture2D)) as Texture2D;
if (m_normal != null)
{
isModified = true;
}
}
}
if (m_maskmap == null)
{
if (!string.IsNullOrEmpty(m_maskmapFileName))
{
m_maskmap = GaiaUtils.GetAsset(m_maskmapFileName, typeof(UnityEngine.Texture2D)) as Texture2D;
if (m_maskmap != null)
{
isModified = true;
}
}
}
#endif
return isModified;
}
/// <summary>
/// Determine whether this has active criteria that checks textures
/// </summary>
/// <returns>True if has active criteria that checks textures</returns>
public bool ChecksTextures()
{
for (int idx = 0; idx < m_spawnCriteria.Length; idx++)
{
if (m_spawnCriteria[idx].m_isActive && m_spawnCriteria[idx].m_checkTexture)
{
return true;
}
}
return false;
}
/// <summary>
/// Determine whether this has active criteria that checks proximity
/// </summary>
/// <returns>True if has active criteria that checks proximity</returns>
public bool ChecksProximity()
{
for (int idx = 0; idx < m_spawnCriteria.Length; idx++)
{
if (m_spawnCriteria[idx].m_isActive && m_spawnCriteria[idx].m_checkProximity)
{
return true;
}
}
return false;
}
/// <summary>
/// Add tags to the list if they are not already there
/// </summary>
/// <param name="tagList">The list to add the tags to</param>
public void AddTags(ref List<string> tagList)
{
for (int idx = 0; idx < m_spawnCriteria.Length; idx++)
{
if (m_spawnCriteria[idx].m_isActive && m_spawnCriteria[idx].m_checkProximity)
{
if (!tagList.Contains(m_spawnCriteria[idx].m_proximityTag))
{
tagList.Add(m_spawnCriteria[idx].m_proximityTag);
}
}
}
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 82240f9e89cd1ca4badcd7127f0842b5
timeCreated: 1440036091
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,13 @@
using UnityEngine;
using System.Collections;
namespace Gaia
{
/// <summary>
/// Scriptable object wrapper around a texture
/// </summary>
public class ResourceProtoTextureSO : ScriptableObject
{
public ResourceProtoTexture m_texture;
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: f13372eb6f5ed24499a9386b1c297258
timeCreated: 1440406665
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,266 @@
using System;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace Gaia
{
/// <summary>
/// Used to serialise the tree prototypes
/// </summary>
[System.Serializable]
public class ResourceProtoTree
{
[Tooltip("Resource name.")]
public string m_name;
[Tooltip("Desktop prefab.")]
public GameObject m_desktopPrefab;
[HideInInspector]
public string m_desktopPrefabFileName; // Used for re-association
//[Tooltip("Mobile prefab - future proofing here - not currently used.")]
//public GameObject m_mobilePrefab;
[HideInInspector]
public string m_mobilePrefabFileName; // Used for re-association
[Tooltip("How much the tree bends in the wind - only used by unity tree creator trees, ignored by SpeedTree trees.")]
public float m_bendFactor;
[Tooltip("The colour of healthy trees - only used by unity tree creator trees, ignored by SpeedTree trees.")]
public Color m_healthyColour = Color.white;
[Tooltip("The colour of dry trees - only used by unity tree creator trees, ignored by SpeedTree trees.")]
public Color m_dryColour = Color.white;
[Tooltip("The spawn scale used for this tree")]
public SpawnScale m_spawnScale = SpawnScale.Fitness;
[Tooltip("Minimum width in world units.")]
public float m_minWidth = 0.75f;
[Tooltip("Maximum width in world units.")]
public float m_maxWidth = 1.5f;
[Tooltip("Minimum height in world units.")]
public float m_minHeight = 0.75f; //Height in world units
[Tooltip("Maximum height in world units.")]
public float m_maxHeight = 1.5f; //Height in world units
public float m_widthRandomPercentage = 0.5f;
public float m_heightRandomPercentage = 0.5f;
/// The "last used fields" are filled when the tree is being spawned and can then be used to re-scle the tree when the user refreshes the prototype
public SpawnScale m_lastUsedSpawnScale = SpawnScale.Fitness;
public float m_lastUsedMinWidth = 0.75f;
public float m_lastUsedMaxWidth = 1.5f;
public float m_lastUsedMinHeight = 0.75f; //Height in world units
public float m_lastUsedMaxHeight = 1.5f; //Height in world units
public float m_lastUsedWidthRandomPercentage = 0.5f;
public float m_lastUsedHeightRandomPercentage = 0.5f;
[Tooltip("SPAWN CRITERIA - Spawn criteria are run against the terrain to assess its fitness in a range of 0..1 for use by this resource. If you add multiple criteria then the fittest one will be selected.")]
public SpawnCritera[] m_spawnCriteria = new SpawnCritera[0];
[Tooltip("SPAWN EXTENSIONS - Spawn extensions allow fitness, spawning and post spawning extensions to be made to the spawning system.")]
public SpawnRuleExtension[] m_spawnExtensions = new SpawnRuleExtension[0];
//[Tooltip("SPAWN MASKS - This list of masks can be used to determine where the terrain detail will appear on the terrain.")]
//public ImageMask[] m_imageMasks = new ImageMask[0];
public bool m_instancesFoldOut;
public bool m_dnaFoldedOut;
/// <summary>
/// Initialise the tree
/// </summary>
/// <param name="spawner">The spawner it belongs to</param>
public void Initialise(Spawner spawner)
{
foreach (SpawnCritera criteria in m_spawnCriteria)
{
criteria.Initialise(spawner);
}
}
/// <summary>
/// Determine whether this has active criteria
/// </summary>
/// <returns>True if has actrive criteria</returns>
public bool HasActiveCriteria()
{
for (int idx = 0; idx < m_spawnCriteria.Length; idx++)
{
if (m_spawnCriteria[idx].m_isActive)
{
return true;
}
}
return false;
}
/// <summary>
/// Set up the asset associations, return true if something changes. Can only be run when the editor is present.
/// </summary>
/// <returns>True if something changes</returns>
public bool SetAssetAssociations()
{
bool isModified = false;
#if UNITY_EDITOR
if (m_desktopPrefab != null)
{
string fileName = Path.GetFileName(AssetDatabase.GetAssetPath(m_desktopPrefab));
if (fileName != m_desktopPrefabFileName)
{
m_desktopPrefabFileName = fileName;
isModified = true;
}
}
else
{
if (!string.IsNullOrEmpty(m_desktopPrefabFileName))
{
m_desktopPrefabFileName = "";
isModified = true;
}
}
//if (m_mobilePrefab != null)
//{
// string fileName = Path.GetFileName(AssetDatabase.GetAssetPath(m_mobilePrefab));
// if (fileName != m_mobilePrefabFileName)
// {
// m_mobilePrefabFileName = fileName;
// isModified = true;
// }
//}
//else
//{
// if (!string.IsNullOrEmpty(m_mobilePrefabFileName))
// {
// m_mobilePrefabFileName = "";
// isModified = true;
// }
//}
#endif
return isModified;
}
/// <summary>
/// Associate any unallocated assets to this resource. Return true if something changes.
/// </summary>
/// <returns>True if the prototype was in some way modified</returns>
public bool AssociateAssets()
{
bool isModified = false;
#if UNITY_EDITOR
if (m_desktopPrefab == null)
{
if (!string.IsNullOrEmpty(m_desktopPrefabFileName))
{
m_desktopPrefab = GaiaUtils.GetAsset(m_desktopPrefabFileName, typeof(UnityEngine.GameObject)) as GameObject;
if (m_desktopPrefab != null)
{
isModified = true;
}
}
}
//if (m_mobilePrefab == null)
//{
// if (!string.IsNullOrEmpty(m_mobilePrefabFileName))
// {
// m_mobilePrefab = GaiaUtils.GetAsset(m_mobilePrefabFileName, typeof(UnityEngine.GameObject)) as GameObject;
// if (m_mobilePrefab != null)
// {
// isModified = true;
// }
// }
//}
#endif
return isModified;
}
/// <summary>
/// Determine whether this has active criteria that checks textures
/// </summary>
/// <returns>True if has active criteria that checks textures</returns>
public bool ChecksTextures()
{
for (int idx = 0; idx < m_spawnCriteria.Length; idx++)
{
if (m_spawnCriteria[idx].m_isActive && m_spawnCriteria[idx].m_checkTexture)
{
return true;
}
}
return false;
}
/// <summary>
/// Determine whether this has active criteria that checks proximity
/// </summary>
/// <returns>True if has active criteria that checks proximity</returns>
public bool ChecksProximity()
{
for (int idx = 0; idx < m_spawnCriteria.Length; idx++)
{
if (m_spawnCriteria[idx].m_isActive && m_spawnCriteria[idx].m_checkProximity)
{
return true;
}
}
return false;
}
/// <summary>
/// Add tags to the list if they are not already there
/// </summary>
/// <param name="tagList">The list to add the tags to</param>
public void AddTags(ref List<string> tagList)
{
for (int idx = 0; idx < m_spawnCriteria.Length; idx++)
{
if (m_spawnCriteria[idx].m_isActive && m_spawnCriteria[idx].m_checkProximity)
{
if (!tagList.Contains(m_spawnCriteria[idx].m_proximityTag))
{
tagList.Add(m_spawnCriteria[idx].m_proximityTag);
}
}
}
}
/// <summary>
/// Stores the current spawn scale settings in the "last used" fields
/// </summary>
public void StoreLastUsedScaleSettings()
{
m_lastUsedSpawnScale = m_spawnScale;
m_lastUsedMinWidth = m_minWidth;
m_lastUsedMaxWidth = m_maxWidth;
m_lastUsedMinHeight = m_minHeight;
m_lastUsedMaxHeight = m_maxHeight;
m_lastUsedWidthRandomPercentage = m_widthRandomPercentage;
m_lastUsedHeightRandomPercentage = m_heightRandomPercentage;
}
/// <summary>
/// Compares the current spawn scale settings agains the "last used" settings to determine whether the scaling was changed
/// after the tree was spawned and the tree needs to be rescaled
/// </summary>
/// <returns></returns>
public bool NeedsRescale()
{
return m_lastUsedSpawnScale != m_spawnScale ||
m_lastUsedMinWidth != m_minWidth ||
m_lastUsedMaxWidth != m_maxWidth ||
m_lastUsedMinHeight != m_minHeight ||
m_lastUsedMaxHeight != m_maxHeight ||
m_lastUsedWidthRandomPercentage != m_widthRandomPercentage ||
m_lastUsedHeightRandomPercentage != m_heightRandomPercentage;
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 7b2acb27a8e2a2543a094fd169d53c3f
timeCreated: 1440036091
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,13 @@
using UnityEngine;
using System.Collections;
namespace Gaia
{
/// <summary>
/// Scriptable object wrapper around a tree
/// </summary>
public class ResourceProtoTreeSO : ScriptableObject
{
public ResourceProtoTree m_tree;
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 9a2733403bfd7df4d9af743971fa1bfb
timeCreated: 1440409081
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,19 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
namespace Gaia
{
/// <summary>
/// Prototype for a world biome mask
/// </summary>
[System.Serializable]
public class ResourceProtoWorldBiomeMask
{
[Tooltip("World Biome Mask name.")]
public string m_name;
[Tooltip("Associated Biome preset.")]
public BiomePreset m_biomePreset;
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: ad576717173ca624d89dabcc21723ed0
timeCreated: 1442702659
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,435 @@
using UnityEngine;
using System.Collections;
using System;
namespace Gaia
{
public class ResourceVisualiser : MonoBehaviour {
[Tooltip("Choose the resources - these are the resources that will be managed.")]
public GaiaResource m_resources;
[Tooltip("Visualiser range - controls how far the visualiser extends. Make smaller on lower powered computers.")]
public float m_range = 200f;
[Tooltip("Visualiser resolution. Make larger on lower powered computers."), Range(3f, 50f)]
public float m_resolution = 25f;
[Tooltip("Minimum fitness - points with fitness less than this value will not be shown."), Range(0f, 1f)]
public float m_minimumFitness = 0f;
[Tooltip("Controls which layers are checked for collisions. Must at least include the layer the terrain is on. Add additional layers if other collisions need to be detected as well. Influences terrain detection, tree detection and game object detection.")]
public LayerMask m_fitnessCollisionLayers;
[Tooltip("Colour of high fitness locations.")]
public Color m_fitColour = Color.green;
[Tooltip("Colour of low fitness locations.")]
public Color m_unfitColour = Color.red;
[HideInInspector]
public Spawner m_spawner;
[HideInInspector]
public Vector3 m_lastHitPoint;
[HideInInspector]
public string m_lastHitObjectname;
[HideInInspector]
public float m_lastHitFitness;
[HideInInspector]
public float m_lastHitHeight;
[HideInInspector]
public float m_lastHitTerrainHeight;
[HideInInspector]
public float m_lastHitTerrainRelativeHeight;
[HideInInspector]
public float m_lastHitTerrainSlope;
[HideInInspector]
public float m_lastHitAreaSlope;
[HideInInspector]
public bool m_lastHitWasVirgin = true;
[HideInInspector]
public Gaia.GaiaConstants.SpawnerResourceType m_selectedResourceType; //The resource type we are showing
[HideInInspector]
public int m_selectedResourceIdx; //The actual resouce we are showing
#pragma warning disable 414
[HideInInspector]
private DateTime m_lastUpdateDate = DateTime.Now;
#pragma warning restore 414
[HideInInspector]
private DateTime m_lastCacheUpdateDate = DateTime.Now;
/// <summary>
/// Used to visualise resource fitness
/// </summary>
private UnityHeightMap m_terrainHeightMap;
/// <summary>
/// Knock ourselves out if we happen to be left there in play mode
/// </summary>
void Awake()
{
gameObject.SetActive(false);
}
/// <summary>
/// Std unity enable
/// </summary>
void OnEnable()
{
Initialise();
}
/// <summary>
/// Initialise as much as we can
/// </summary>
public void Initialise()
{
m_fitnessCollisionLayers = Gaia.TerrainHelper.GetActiveTerrainLayer();
m_spawner = GetComponent<Spawner>();
if (m_spawner == null)
{
m_spawner = gameObject.AddComponent<Spawner>();
m_spawner.m_spawnCollisionLayers = m_fitnessCollisionLayers;
m_spawner.hideFlags = HideFlags.HideInInspector;
m_spawner.m_settings.m_resources = m_resources;
m_spawner.m_settings.m_spawnRange = m_range;
//m_spawner.m_showGizmos = false;
m_spawner.Initialise();
}
else
{
m_spawner.m_spawnCollisionLayers = m_fitnessCollisionLayers;
m_spawner.Initialise();
}
}
/// <summary>
/// Pick up latest terrain information
/// </summary>
public void Visualise()
{
m_terrainHeightMap = new UnityHeightMap(Gaia.TerrainHelper.GetActiveTerrain());
}
public SpawnInfo GetSpawnInfo(Vector3 location)
{
SpawnInfo spawnInfo = new SpawnInfo();
spawnInfo.m_textureStrengths = new float[Terrain.activeTerrain.terrainData.alphamapLayers];
if (m_spawner.CheckLocation(location, ref spawnInfo))
{
spawnInfo.m_fitness = GetFitness(ref spawnInfo);
}
else
{
spawnInfo.m_fitness = 0f;
}
return spawnInfo;
}
/// <summary>
/// Return the value of the fittest object in the spawn criteria
/// </summary>
/// <param name="spawner">The spawner we belong to</param>
/// <param name="location">The location we are checking</param>
/// <param name="slope"></param>
/// <returns>Fitness in range 0..1f</returns>
public float GetFitness(ref SpawnInfo spawnInfo)
{
//Get the filters
SpawnCritera[] filters;
switch (m_selectedResourceType)
{
case GaiaConstants.SpawnerResourceType.TerrainDetail:
{
filters = spawnInfo.m_spawner.m_settings.m_resources.m_detailPrototypes[m_selectedResourceIdx].m_spawnCriteria;
break;
}
case GaiaConstants.SpawnerResourceType.TerrainTexture:
{
filters = spawnInfo.m_spawner.m_settings.m_resources.m_texturePrototypes[m_selectedResourceIdx].m_spawnCriteria;
break;
}
case GaiaConstants.SpawnerResourceType.TerrainTree:
{
filters = spawnInfo.m_spawner.m_settings.m_resources.m_treePrototypes[m_selectedResourceIdx].m_spawnCriteria;
break;
}
default:
{
filters = spawnInfo.m_spawner.m_settings.m_resources.m_gameObjectPrototypes[m_selectedResourceIdx].m_spawnCriteria;
break;
}
}
//Drop out if we have no filters
if (filters == null || filters.Length == 0)
{
return 0f;
}
//Now calculate fitness
float maxFitness = float.MinValue;
int filterIdx;
SpawnCritera filter;
float fitness = 0f;
for (filterIdx = 0; filterIdx < filters.Length; filterIdx++)
{
filter = filters[filterIdx];
//Check to see of this filter needs a bounds check
if (filter.m_checkType == GaiaConstants.SpawnerLocationCheckType.BoundedAreaCheck)
{
if (!spawnInfo.m_spawner.CheckLocationBounds(ref spawnInfo, GetMaxScaledRadius(ref spawnInfo)))
{
return 0f;
}
}
//Now calculate and process fitness
fitness = filter.GetFitness(ref spawnInfo);
if (fitness > maxFitness)
{
maxFitness = fitness;
if (maxFitness >= 1f)
{
return maxFitness;
}
}
}
if (maxFitness == float.MinValue)
{
return 0f;
}
else
{
return maxFitness;
}
}
/// <summary>
/// Return the value of the least fittest object in the spawn criteria
/// </summary>
/// <param name="spawner">The spawner we belong to</param>
/// <param name="location">The location we are checking</param>
/// <param name="slope"></param>
/// <returns>Fitness in range 0..1f</returns>
public float GetMinFitness(ref SpawnInfo spawnInfo)
{
//Get the filters
SpawnCritera[] filters;
switch (m_selectedResourceType)
{
case GaiaConstants.SpawnerResourceType.TerrainDetail:
{
if (m_selectedResourceIdx >= spawnInfo.m_spawner.m_settings.m_resources.m_detailPrototypes.Length)
{
return 0f;
}
filters = spawnInfo.m_spawner.m_settings.m_resources.m_detailPrototypes[m_selectedResourceIdx].m_spawnCriteria;
break;
}
case GaiaConstants.SpawnerResourceType.TerrainTexture:
{
if (m_selectedResourceIdx >= spawnInfo.m_spawner.m_settings.m_resources.m_texturePrototypes.Length)
{
return 0f;
}
filters = spawnInfo.m_spawner.m_settings.m_resources.m_texturePrototypes[m_selectedResourceIdx].m_spawnCriteria;
break;
}
case GaiaConstants.SpawnerResourceType.TerrainTree:
{
if (m_selectedResourceIdx >= spawnInfo.m_spawner.m_settings.m_resources.m_treePrototypes.Length)
{
return 0f;
}
filters = spawnInfo.m_spawner.m_settings.m_resources.m_treePrototypes[m_selectedResourceIdx].m_spawnCriteria;
break;
}
default:
{
if (m_selectedResourceIdx >= spawnInfo.m_spawner.m_settings.m_resources.m_gameObjectPrototypes.Length)
{
return 0f;
}
filters = spawnInfo.m_spawner.m_settings.m_resources.m_gameObjectPrototypes[m_selectedResourceIdx].m_spawnCriteria;
break;
}
}
//Drop out if we have no filters
if (filters == null || filters.Length == 0)
{
return 0f;
}
//Now calculate fitness
float minFitness = float.MaxValue;
int filterIdx;
SpawnCritera filter;
float fitness = 0f;
for (filterIdx = 0; filterIdx < filters.Length; filterIdx++)
{
filter = filters[filterIdx];
//Check to see of this filter needs a bounds check
if (filter.m_checkType == GaiaConstants.SpawnerLocationCheckType.BoundedAreaCheck)
{
if (!spawnInfo.m_spawner.CheckLocationBounds(ref spawnInfo, GetMaxScaledRadius(ref spawnInfo)))
{
return 0f;
}
}
//Now calculate and process fitness
fitness = filter.GetFitness(ref spawnInfo);
if (fitness < minFitness)
{
minFitness = fitness;
if (minFitness <= 0f)
{
return minFitness;
}
}
}
if (minFitness == float.MaxValue)
{
return 0f;
}
else
{
return minFitness;
}
}
/// <summary>
/// Return the maximum scaled radius of the thing referred to by the rule
/// </summary>
/// <param name="spawnInfo">Spawner information</param>
/// <returns>Maximum scaled radius</returns>
public float GetMaxScaledRadius(ref SpawnInfo spawnInfo)
{
//switch (m_selectedResourceType)
//{
// case GaiaConstants.SpawnerResourceType.TerrainTexture:
// {
// return 1f; //Makes no sense, so return arbitrary value
// }
// case GaiaConstants.SpawnerResourceType.TerrainDetail:
// {
// return spawnInfo.m_spawner.m_settings.m_resources.m_detailPrototypes[m_selectedResourceIdx].m_dna.m_boundsRadius * spawnInfo.m_spawner.m_settings.m_resources.m_detailPrototypes[m_selectedResourceIdx].m_dna.m_maxScale;
// }
// case GaiaConstants.SpawnerResourceType.TerrainTree:
// {
// return spawnInfo.m_spawner.m_settings.m_resources.m_treePrototypes[m_selectedResourceIdx].m_dna.m_boundsRadius * spawnInfo.m_spawner.m_settings.m_resources.m_treePrototypes[m_selectedResourceIdx].m_dna.m_maxScale;
// }
// default:
// {
// return spawnInfo.m_spawner.m_settings.m_resources.m_gameObjectPrototypes[m_selectedResourceIdx].m_dna.m_boundsRadius * spawnInfo.m_spawner.m_settings.m_resources.m_gameObjectPrototypes[m_selectedResourceIdx].m_dna.m_maxScale;
// }
//}
return 0f;
}
/// <summary>
/// Draw gizmos
/// </summary>
void OnDrawGizmos()
{
if (m_resources == null)
{
return;
}
if (m_spawner == null)
{
return;
}
if (m_terrainHeightMap == null)
{
return;
}
//Lets visualise fitness
float x, y = transform.position.y, z;
float xStart = transform.position.x - m_range;
float xEnd = transform.position.x + m_range;
float zStart = transform.position.z - m_range;
float zEnd = transform.position.z + m_range;
float ballsize = Mathf.Clamp(m_resolution * 0.25f, 0.5f, 5f);
m_spawner.m_settings.m_spawnRange = m_range;
m_spawner.m_spawnerBounds = new Bounds(transform.position, new Vector3(m_range * 2f, m_range * 20f, m_range * 2f));
SpawnInfo spawnInfo = new SpawnInfo();
Vector3 location = new Vector3();
float fitness = 0f;
//Create caches
if ((DateTime.Now - m_lastCacheUpdateDate).TotalSeconds > 5)
{
m_lastCacheUpdateDate = DateTime.Now;
m_spawner.DeleteSpawnCaches();
m_spawner.CreateSpawnCaches(m_selectedResourceType, m_selectedResourceIdx);
//Also update the location so make moving it easier
Terrain terrain = TerrainHelper.GetTerrain(transform.position);
if (terrain != null)
{
transform.position = new Vector3(transform.position.x, terrain.SampleHeight(transform.position) + 5f, transform.position.z );
}
}
//Set up the texture layer array in spawn info
spawnInfo.m_textureStrengths = new float[Terrain.activeTerrain.terrainData.alphamapLayers];
//Now visualise fitness
for (x = xStart; x < xEnd; x += m_resolution)
{
for (z = zStart; z < zEnd; z += m_resolution)
{
location.Set(x, y, z);
if (m_spawner.CheckLocation(location, ref spawnInfo))
{
fitness = GetFitness(ref spawnInfo);
if (fitness < m_minimumFitness)
{
continue;
}
Gizmos.color = Color.Lerp(m_unfitColour, m_fitColour, fitness);
Gizmos.DrawSphere(spawnInfo.m_hitLocationWU, ballsize);
}
}
}
//Now draw water
//Water
if (m_resources != null)
{
BoundsDouble bounds = new BoundsDouble();
if (TerrainHelper.GetTerrainBounds(ref bounds) == true)
{
bounds.center = new Vector3Double(bounds.center.x, GaiaSessionManager.GetSessionManager().GetSeaLevel(), bounds.center.z);
bounds.size = new Vector3Double(bounds.size.x, 0.05f, bounds.size.z);
Gizmos.color = new Color(Color.blue.r, Color.blue.g, Color.blue.b, Color.blue.a / 4f);
Gizmos.DrawCube(bounds.center, bounds.size);
}
}
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: afedc5dcc2bd010409c4a96f55cd407e
timeCreated: 1440036091
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,45 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace Gaia
{
public class UserFiles : ScriptableObject
{
public bool m_autoAddNewFiles = true;
public bool m_updateFilesWithGaiaUpdate = true;
public List<BiomePreset> m_gaiaManagerBiomePresets = new List<BiomePreset>();
public List<SpawnerSettings> m_gaiaManagerSpawnerSettings = new List<SpawnerSettings>();
public List<ExportTerrainSettings> m_exportTerrainSettings = new List<ExportTerrainSettings>();
public void PruneNonExisting()
{
#if UNITY_EDITOR
for (int i = m_gaiaManagerBiomePresets.Count - 1; i >= 0; i--)
{
if (String.IsNullOrEmpty(AssetDatabase.GetAssetPath(m_gaiaManagerBiomePresets[i])))
{
m_gaiaManagerBiomePresets.RemoveAt(i);
}
}
for (int i = m_gaiaManagerSpawnerSettings.Count - 1; i >= 0; i--)
{
if (String.IsNullOrEmpty(AssetDatabase.GetAssetPath(m_gaiaManagerSpawnerSettings[i])))
{
m_gaiaManagerSpawnerSettings.RemoveAt(i);
}
}
for (int i = m_exportTerrainSettings.Count - 1; i >= 0; i--)
{
if (String.IsNullOrEmpty(AssetDatabase.GetAssetPath(m_exportTerrainSettings[i])))
{
m_exportTerrainSettings.RemoveAt(i);
}
}
#endif
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f8de3696d9750f843be255e541faa3f9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: