当前位置: 首页>>代码示例>>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;未经允许,请勿转载。