コード例 #1
0
		public void OnEnable ()
		{
			#if UNITY_EDITOR
			//adding delegates
			UnityEditor.EditorApplication.update -= Update;	

			if (isEditor) 
				UnityEditor.EditorApplication.update += Update;	
			#endif

			//finding singleton instance
			instance = FindObjectOfType<MapMagic>();

			//checking terrains consistency
			if (chunks != null)
			foreach (Chunk chunk in chunks.All())
				if (chunk.terrain == null) chunks.Remove(chunk.coord);

			//changing seed on playmode start
			if (changeSeed && Extensions.isPlaying)
			{
				seed=UnityEngine.Random.Range(0,10000000);
				ClearResults();
				Generate(force:true);
			}
		}
コード例 #2
0
ファイル: MapMagic.cs プロジェクト: Moritzjenny/farundil_map
		public void OnEnable ()
		{
			#if UNITY_EDITOR
			//adding delegates
			UnityEditor.EditorApplication.update -= Update;	

			if (isEditor) 
				UnityEditor.EditorApplication.update += Update;	
			#endif

			//finding singleton instance
			instance = FindObjectOfType<MapMagic>();

			//checking terrains consistency
			if (chunks != null)
			foreach (Chunk chunk in chunks.All())
				if (chunk.terrain == null) chunks.Remove(chunk.coord);

			//changing seed on playmode start
			if (changeSeed && Extensions.isPlaying)
			{
				seed = (int)(System.DateTime.Now.Ticks % 1000000);
				ClearResults();
				Generate(force:true);
			}

			if (previewShader == null) previewShader = Shader.Find("MapMagic/TerrainPreview");

			//assigning default shaders for 2019.2 and later
			#if UNITY_2019_2_OR_NEWER
			if (customTerrainMaterial == null)
			{
				Shader terrainShader = Shader.Find("HDRP/TerrainLit");
				if (terrainShader == null) terrainShader = Shader.Find("Lightweight Render Pipeline/Terrain/Lit");
				if (terrainShader == null) terrainShader = Shader.Find("Nature/Terrain/Standard");
				customTerrainMaterial = new Material(terrainShader);
			}
			#endif
		}