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


C# Collider.GetType方法代碼示例

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


在下文中一共展示了Collider.GetType方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: DrawWireCollider

        public static void DrawWireCollider(Collider c)
        {
            if (c == null) throw new System.ArgumentNullException("c");

            if (c is BoxCollider)
            {
                var box = c as BoxCollider;
                DrawWireRectoid(box.transform.TransformPoint(box.center), box.transform.rotation, Vector3.Scale(box.size, box.transform.lossyScale));
            }
            else if (c is SphereCollider)
            {
                var sphereGeom = com.spacepuppy.Geom.Sphere.FromCollider(c as SphereCollider);
                DrawWireSphere(sphereGeom.Center, c.transform.rotation, sphereGeom.Radius);
            }
            else if (c is CapsuleCollider)
            {
                var capGeom = com.spacepuppy.Geom.Capsule.FromCollider(c as CapsuleCollider);
                DrawWireCapsule(capGeom.Start, capGeom.End, capGeom.Radius);
            }
            else if (c is CharacterController)
            {
                var capGeom = com.spacepuppy.Geom.Capsule.FromCollider(c as CharacterController);
                DrawWireCapsule(capGeom.Start, capGeom.End, capGeom.Radius);
            }
            else if (c is MeshCollider)
            {
                //not supported
                throw new System.ArgumentException("Unsupported collider type '" + c.GetType().Name + "'.", "c");
            }
            else
            {
                //not supported
                throw new System.ArgumentException("Unsupported collider type '" + c.GetType().Name + "'.", "c");
            }

        }
開發者ID:Gege00,項目名稱:spacepuppy-unity-framework,代碼行數:36,代碼來源:HandlesHelper.cs

示例2: GetSurfaceIndex

		int GetSurfaceIndex(Collider col, Vector3 worldPos) {
			string textureName = "";

			// Case when the ground is a terrain.
			if(col.GetType() == typeof(TerrainCollider)) {
				Terrain terrain = col.GetComponent<Terrain>();
				TerrainData terrainData = terrain.terrainData;
				float[] textureMix = GetTerrainTextureMix(worldPos, terrainData, terrain.GetPosition());
				int textureIndex = GetTextureIndex(worldPos, textureMix);
				textureName = terrainData.splatPrototypes[textureIndex].texture.name;
			}
			// Case when the ground is a normal mesh.
			else {
				textureName = GetMeshMaterialAtPoint(worldPos);
			}
			// Searching for the found texture / material name in registered materials.
			foreach(var material in registeredTextures) {
				if(material.texture.name == textureName) {
					return material.surfaceIndex;
				}
			}

			return -1;
		}
開發者ID:ratfr0,項目名稱:Ascension2.0,代碼行數:24,代碼來源:SurfaceManager.cs

示例3: IsMeshCollider

 /// <summary>
 /// Determines whether [is mesh collider] [the specified collider].
 /// </summary>
 /// <param name="collider">The collider.</param>
 /// <returns>
 ///   <c>true</c> if [is mesh collider] [the specified collider]; otherwise, <c>false</c>.
 /// </returns>
 public static bool IsMeshCollider(Collider collider)
 {
     return collider.GetType() == typeof(MeshCollider);
 }
開發者ID:alloyapple,項目名稱:Decoration-Beginning-of-Spring,代碼行數:11,代碼來源:MaterialUtilities.cs

示例4: OnTriggerEnter

 private void OnTriggerEnter(Collider other)
 {
     Console.WriteLine(other.GetType());
     DoActivateTrigger();
 }
開發者ID:petrickow,項目名稱:TopperDowny,代碼行數:5,代碼來源:ActivateTrigger.cs

示例5: UpdateAreaRange

		/// <summary>
		/// Overload to skip the need for an Area to exist so this can be used during setup.
		/// </summary>
		protected void UpdateAreaRange(Collider col, Component col2D)  // Component is for 4.0 compatability
		{
			Vector3 normRange = this.GetNormalizedRange();

			if (col is SphereCollider)
            {
                var collider = (SphereCollider)col;
                collider.radius = normRange.x;
            }
            else if (col is BoxCollider)
            {
                var collider = (BoxCollider)col;
                collider.size = normRange;
            }
            else if (col is CapsuleCollider)
            {
                var collider = (CapsuleCollider)col;
                collider.radius = normRange.x;
                collider.height = normRange.y;
            }
            else if (col2D is CircleCollider2D)
            {
                var collider = (CircleCollider2D)col2D;
                collider.radius = normRange.x;
            }
            else if (col2D is BoxCollider2D)
            {
                var collider = (BoxCollider2D)col2D;
                collider.size = new Vector2(normRange.x, normRange.y);
            }
			else
            {
				string colType;
				string colName;
				if (col != null)
				{
					colType = col.GetType().Name;
					colName = col.name;
				}
				else if (col2D != null)
				{
					colType = col2D.GetType().Name;
					colName = col2D.name;
				}
				else
				{
					throw new System.NullReferenceException("No Collider Found!");
				}

				Debug.LogWarning
				(
					string.Format
					(
						"Unsupported collider type '{0}' for collider '{1}'.",
						colType,
						colName
					)
				);
            }
        }
開發者ID:TripleLoopGames,項目名稱:space-roaches,代碼行數:63,代碼來源:AreaTargetTracker.cs


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