當前位置: 首頁>>代碼示例>>C#>>正文


C# UnityEngine.Terrain類代碼示例

本文整理匯總了C#中UnityEngine.Terrain的典型用法代碼示例。如果您正苦於以下問題:C# Terrain類的具體用法?C# Terrain怎麽用?C# Terrain使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Terrain類屬於UnityEngine命名空間,在下文中一共展示了Terrain類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: InitializeDefaults

 internal void InitializeDefaults(Terrain terrain, int index)
 {
   this.m_Terrain = terrain;
   this.m_PrototypeIndex = index;
   DetailPrototype detailPrototype = this.m_PrototypeIndex != -1 ? this.m_Terrain.terrainData.detailPrototypes[this.m_PrototypeIndex] : new DetailPrototype();
   this.m_Detail = detailPrototype.prototype;
   this.m_NoiseSpread = detailPrototype.noiseSpread;
   this.m_MinWidth = detailPrototype.minWidth;
   this.m_MaxWidth = detailPrototype.maxWidth;
   this.m_MinHeight = detailPrototype.minHeight;
   this.m_MaxHeight = detailPrototype.maxHeight;
   this.m_HealthyColor = detailPrototype.healthyColor;
   this.m_DryColor = detailPrototype.dryColor;
   switch (detailPrototype.renderMode)
   {
     case DetailRenderMode.GrassBillboard:
       Debug.LogError((object) "Detail meshes can't be rendered as billboards");
       this.m_RenderMode = DetailMeshRenderMode.Grass;
       break;
     case DetailRenderMode.VertexLit:
       this.m_RenderMode = DetailMeshRenderMode.VertexLit;
       break;
     case DetailRenderMode.Grass:
       this.m_RenderMode = DetailMeshRenderMode.Grass;
       break;
   }
   this.OnWizardUpdate();
 }
開發者ID:BlakeTriana,項目名稱:unity-decompiled,代碼行數:28,代碼來源:DetailMeshWizard.cs

示例2: DeriveScale

        public static Vector3 DeriveScale(Terrain terrain, float resolution
            , out int widthCount, out int depthCount)
        {
            widthCount = 0;
            depthCount = 0;

            if (terrain == null || terrain.terrainData == null || resolution <= 0)
                return Vector3.zero;

            Vector3 scale = terrain.terrainData.heightmapScale;
            widthCount = terrain.terrainData.heightmapWidth;
            depthCount = terrain.terrainData.heightmapHeight;

            if (resolution > 0 && resolution < 1)
            {
                Vector3 size = terrain.terrainData.size;
                widthCount = Mathf.FloorToInt(size.x / scale.x * resolution);
                depthCount = Mathf.FloorToInt(size.z / scale.z * resolution);

                scale.x = size.x / (float)widthCount;
                scale.z = size.z / (float)depthCount;

                // For the vertices along the maximum bounds...
                widthCount++;
                depthCount++;
            }

            return scale;
        }
開發者ID:GamesDesignArt,項目名稱:unity3d_nav_critterai,代碼行數:29,代碼來源:TerrainUtil.cs

示例3: InitializeDefaults

 private void InitializeDefaults(Terrain terrain)
 {
     base.m_Terrain = terrain;
     object[] objArray1 = new object[] { "Width ", terrain.terrainData.heightmapWidth, " Height ", terrain.terrainData.heightmapHeight };
     base.helpString = string.Concat(objArray1);
     this.OnWizardUpdate();
 }
開發者ID:randomize,項目名稱:VimConfig,代碼行數:7,代碼來源:ExportRawHeightmap.cs

示例4: RemoveTree

		internal static void RemoveTree(Terrain terrain, int index)
		{
			TerrainData terrainData = terrain.terrainData;
			if (terrainData == null)
			{
				return;
			}
			Undo.RegisterCompleteObjectUndo(terrainData, "Remove tree");
			terrainData.RemoveTreePrototype(index);
		}
開發者ID:guozanhua,項目名稱:UnityDecompiled,代碼行數:10,代碼來源:TerrainEditorUtility.cs

示例5: InitializeDefaults

		internal void InitializeDefaults(Terrain terrain, int index)
		{
			this.m_Terrain = terrain;
			this.m_PrototypeIndex = index;
			DetailPrototype detailPrototype;
			if (this.m_PrototypeIndex == -1)
			{
				detailPrototype = new DetailPrototype();
				detailPrototype.renderMode = DetailRenderMode.GrassBillboard;
			}
			else
			{
				detailPrototype = this.m_Terrain.terrainData.detailPrototypes[this.m_PrototypeIndex];
			}
			this.m_DetailTexture = detailPrototype.prototypeTexture;
			this.m_MinWidth = detailPrototype.minWidth;
			this.m_MaxWidth = detailPrototype.maxWidth;
			this.m_MinHeight = detailPrototype.minHeight;
			this.m_MaxHeight = detailPrototype.maxHeight;
			this.m_NoiseSpread = detailPrototype.noiseSpread;
			this.m_HealthyColor = detailPrototype.healthyColor;
			this.m_DryColor = detailPrototype.dryColor;
			this.m_Billboard = (detailPrototype.renderMode == DetailRenderMode.GrassBillboard);
			this.OnWizardUpdate();
		}
開發者ID:guozanhua,項目名稱:UnityDecompiled,代碼行數:25,代碼來源:DetailTextureWizard.cs

示例6: OnWizardUpdate

	void OnWizardUpdate() {
		this.helpString = 	"This tool exports the splatmap (layer weight texture) of a terrain to a PNG image.\n"+
							"Optionally, the alpha channel is saved to a separate image.\n";
        if( Selection.activeGameObject != null ) this.terrain = Selection.activeGameObject.GetComponent<Terrain>();
		if(this.terrain == null) this.terrain = GameObject.FindObjectOfType(typeof(Terrain)) as Terrain;
		this.isValid = this.terrain != null && this.terrain.terrainData != null;
	}
開發者ID:keyward,項目名稱:EnemyOfMyEnemy,代碼行數:7,代碼來源:ExportSplatmap.cs

示例7: RemoveDetail

 internal static void RemoveDetail(Terrain terrain, int index)
 {
   TerrainData terrainData = terrain.terrainData;
   if ((Object) terrainData == (Object) null)
     return;
   Undo.RegisterCompleteObjectUndo((Object) terrainData, "Remove detail object");
   terrainData.RemoveDetailPrototype(index);
 }
開發者ID:BlakeTriana,項目名稱:unity-decompiled,代碼行數:8,代碼來源:TerrainEditorUtility.cs

示例8: UpdateMaterials

 /// <summary>
 ///   <para>Schedules an update of the albedo and emissive textures of a system that contains the renderer or the terrain.</para>
 /// </summary>
 /// <param name="renderer">The Renderer to use when searching for a system to update.</param>
 /// <param name="terrain">The Terrain to use when searching for systems to update.</param>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <param name="width"></param>
 /// <param name="height"></param>
 public static void UpdateMaterials(Terrain terrain)
 {
   if ((Object) terrain == (Object) null)
     throw new ArgumentNullException("terrain");
   if ((Object) terrain.terrainData == (Object) null)
     throw new ArgumentException("Invalid terrainData.");
   DynamicGI.UpdateMaterialsForTerrain(terrain, new Rect(0.0f, 0.0f, 1f, 1f));
 }
開發者ID:BlakeTriana,項目名稱:unity-decompiled,代碼行數:17,代碼來源:DynamicGI.cs

示例9: InitializeImportRaw

 internal void InitializeImportRaw(Terrain terrain, string path)
 {
     base.m_Terrain = terrain;
     this.m_Path = path;
     this.PickRawDefaults(this.m_Path);
     base.helpString = "Raw files must use a single channel and be either 8 or 16 bit.";
     this.OnWizardUpdate();
 }
開發者ID:CarlosHBC,項目名稱:UnityDecompiled,代碼行數:8,代碼來源:ImportRawHeightmap.cs

示例10: RemoveDetail

 internal static void RemoveDetail(Terrain terrain, int index)
 {
     TerrainData terrainData = terrain.terrainData;
     if (terrainData != null)
     {
         Undo.RegisterCompleteObjectUndo(terrainData, "Remove detail object");
         terrainData.RemoveDetailPrototype(index);
     }
 }
開發者ID:randomize,項目名稱:VimConfig,代碼行數:9,代碼來源:TerrainEditorUtility.cs

示例11: Setup

 public override void Setup(Renderer render, IFPV_Object parent)
 {
     terrain = GetComponent<Terrain>();
     _parent = parent;
     _render = render;
     _originalLayer = gameObject.layer;
     isVisible = true;
     viewChanged = false;
 }
開發者ID:jimmikaelkael,項目名稱:-Unity-First-Person-View,代碼行數:9,代碼來源:FPV_Renderer_Terrain.cs

示例12: Init

        public void Init(Terrain _terrain, MapDataGround.Tile[,] tiles, float[,] height, byte[,] zones)
        {
            InitGlobal();
            InitWorld();

            terrain = _terrain;

            InitTerrain(tiles, height, zones);
        }
開發者ID:cyanpunk,項目名稱:muonline,代碼行數:9,代碼來源:MapTerrain.cs

示例13: OnWizardUpdate

	void OnWizardUpdate() {
		this.helpString =	"This tool replaces the selected terrain's splatmap (layer weight texture) with another image.\n\n" +
							"The texture format must be uncompressed (set to \"Truecolor\" in inspector).\n\n" +
							"This tool cannot add or remove texture layers. The terrain must have all its layers defined\n" + 
							"before importing. If only 2 layers are present, just the red and green channels are imported.\n";
		
        if( Selection.activeGameObject != null ) this.terrain = Selection.activeGameObject.GetComponent<Terrain>();
		if(this.terrain == null) this.terrain = GameObject.FindObjectOfType(typeof(Terrain)) as Terrain;
		this.isValid = this.newSplatmap != null && this.terrain != null && this.terrain.terrainData != null;		
	}
開發者ID:keyward,項目名稱:EnemyOfMyEnemy,代碼行數:10,代碼來源:ImportSplatmap.cs

示例14: Initialize

        public static void Initialize()
        {
            if (Loaded == false) {

                LSDatabase database = LSFSettingsManager.GetSettings ().Database;
                _currentDatabase = database;
                Loaded = true;
                LockstepManager.Setup();
            }
            Terrain = GameObject.FindObjectOfType<Terrain> ();
        }
開發者ID:citizenparker,項目名稱:Lockstep-Framework,代碼行數:11,代碼來源:LSDatabaseManager.cs

示例15: PlaceTrees

		public static void PlaceTrees(Terrain terrain, float xBase, float yBase)
		{
			if (terrain.terrainData.treePrototypes.Length == 0)
			{
				return;
			}
			TreePainter.selectedTree = Mathf.Min(TerrainInspectorUtil.GetPrototypeCount(terrain.terrainData) - 1, TreePainter.selectedTree);
			if (!TerrainInspectorUtil.PrototypeIsRenderable(terrain.terrainData, TreePainter.selectedTree))
			{
				return;
			}
			int num = 0;
			TreeInstance instance = default(TreeInstance);
			instance.position = new Vector3(xBase, 0f, yBase);
			instance.color = TreePainter.GetTreeColor();
			instance.lightmapColor = Color.white;
			instance.prototypeIndex = TreePainter.selectedTree;
			instance.heightScale = TreePainter.GetTreeHeight();
			instance.widthScale = ((!TreePainter.lockWidthToHeight) ? TreePainter.GetTreeWidth() : instance.heightScale);
			instance.rotation = TreePainter.GetTreeRotation();
			bool flag = Event.current.type == EventType.MouseDrag || TreePainter.brushSize > 1f;
			if (!flag || TerrainInspectorUtil.CheckTreeDistance(terrain.terrainData, instance.position, instance.prototypeIndex, TreePainter.spacing))
			{
				terrain.AddTreeInstance(instance);
				num++;
			}
			Vector3 prototypeExtent = TerrainInspectorUtil.GetPrototypeExtent(terrain.terrainData, TreePainter.selectedTree);
			prototypeExtent.y = 0f;
			float num2 = TreePainter.brushSize / (prototypeExtent.magnitude * TreePainter.spacing * 0.5f);
			int num3 = (int)(num2 * num2 * 0.5f);
			num3 = Mathf.Clamp(num3, 0, 100);
			int num4 = 1;
			while (num4 < num3 && num < num3)
			{
				Vector2 insideUnitCircle = UnityEngine.Random.insideUnitCircle;
				insideUnitCircle.x *= TreePainter.brushSize / terrain.terrainData.size.x;
				insideUnitCircle.y *= TreePainter.brushSize / terrain.terrainData.size.z;
				Vector3 position = new Vector3(xBase + insideUnitCircle.x, 0f, yBase + insideUnitCircle.y);
				if (position.x >= 0f && position.x <= 1f && position.z >= 0f && position.z <= 1f && TerrainInspectorUtil.CheckTreeDistance(terrain.terrainData, position, TreePainter.selectedTree, TreePainter.spacing * 0.5f))
				{
					instance = default(TreeInstance);
					instance.position = position;
					instance.color = TreePainter.GetTreeColor();
					instance.lightmapColor = Color.white;
					instance.prototypeIndex = TreePainter.selectedTree;
					instance.heightScale = TreePainter.GetTreeHeight();
					instance.widthScale = ((!TreePainter.lockWidthToHeight) ? TreePainter.GetTreeWidth() : instance.heightScale);
					instance.rotation = TreePainter.GetTreeRotation();
					terrain.AddTreeInstance(instance);
					num++;
				}
				num4++;
			}
		}
開發者ID:guozanhua,項目名稱:UnityDecompiled,代碼行數:54,代碼來源:TreePainter.cs


注:本文中的UnityEngine.Terrain類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。