当前位置: 首页>>代码示例>>C#>>正文


C# Bounds.IntersectRay方法代码示例

本文整理汇总了C#中UnityEngine.Bounds.IntersectRay方法的典型用法代码示例。如果您正苦于以下问题:C# Bounds.IntersectRay方法的具体用法?C# Bounds.IntersectRay怎么用?C# Bounds.IntersectRay使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UnityEngine.Bounds的用法示例。


在下文中一共展示了Bounds.IntersectRay方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ClampToBounds

 public static Vector3 ClampToBounds( this Vector3 v, Bounds bounds )
 {
     Vector3 clamp = v;
     Ray clampRay = new Ray( Vector2.zero, v );
     float dist;
     if( bounds.IntersectRay( clampRay, out dist ) ) {
         clamp = Vector3.ClampMagnitude( v, dist );
     }
     return clamp;
 }
开发者ID:rhys-vdw,项目名称:birdy-hawk,代码行数:10,代码来源:Vector3Extensions.cs

示例2: Internal_RaycastRef

 internal bool Internal_RaycastRef(Ray ray, ref UIHotSpot.Hit hit)
 {
     Bounds bound = new Bounds(this.center, this.size);
     if (!bound.IntersectRay(ray, out hit.distance))
     {
         return false;
     }
     hit.point = ray.GetPoint(hit.distance);
     hit.normal = -ray.direction;
     return true;
 }
开发者ID:HexHash,项目名称:LegacyRust,代码行数:11,代码来源:UIBoxHotSpot.cs

示例3: BoundsWithinPoints

    // BoundsWithinPoints                                                                                      //
    // Cchecks if passed bounds contains either point (return false)                                           //
    // Then Fires rays between both points to check if the bounds are contained within both rays (return true) //
    public static bool BoundsWithinPoints( Vector3 point_a, Vector3 point_b, Bounds bounds )
    {
        // If the start or end point are within the object, do nothing
        if( bounds.Contains( point_a ) || bounds.Contains( point_b ) )
        {
            return false;
        }

        // If the object is fully on both rays
        Ray ray_forward = new Ray( point_a, point_b - point_a );
        Ray ray_backward = new Ray( point_b, point_a - point_b );
        if( bounds.IntersectRay( ray_forward ) && bounds.IntersectRay( ray_backward ))
        {
            return true;
        }
        else
        {
            return false;
        }
    }
开发者ID:tomob95,项目名称:Portfolio,代码行数:23,代码来源:TiCuttingUtilities.cs

示例4: HandleIntersectionRouting

        void HandleIntersectionRouting()
        {
            FastList<NodeLaneMarker> nodeMarkers;
            if (m_nodeMarkers.TryGetValue(m_selectedNode, out nodeMarkers))
            {
                Ray mouseRay = Camera.main.ScreenPointToRay(Input.mousePosition);
                NodeLaneMarker hoveredMarker = null;
                Bounds bounds = new Bounds(Vector3.zero, Vector3.one);
                for (int i = 0; i < nodeMarkers.m_size; i++)
                {
                    NodeLaneMarker marker = nodeMarkers.m_buffer[i];

                    if (!IsActive(marker))
                        continue;

                    bounds.center = marker.m_position;
                    if (bounds.IntersectRay(mouseRay))
                    {
                        hoveredMarker = marker;
                        marker.m_size = 2f;
                    }
                    else
                        marker.m_size = 1f;
                }

                if (hoveredMarker != null && Input.GetMouseButtonUp(0))
                {
                    if (m_selectedMarker == null)
                    {
                        m_selectedMarker = hoveredMarker;
                    }
                    else if (RoadManager.RemoveLaneConnection(m_selectedMarker.m_lane, hoveredMarker.m_lane))
                    {
                        m_selectedMarker.m_connections.Remove(hoveredMarker);
                    }
                    else if (RoadManager.AddLaneConnection(m_selectedMarker.m_lane, hoveredMarker.m_lane))
                    {
                        m_selectedMarker.m_connections.Add(hoveredMarker);
                    }
                }
            }

            if (Input.GetMouseButtonUp(1))
            {
                if (m_selectedMarker != null)
                    m_selectedMarker = null;
                else
                    m_selectedNode = 0;
            }
        }
开发者ID:Rovanion,项目名称:csl-traffic,代码行数:50,代码来源:RoadCustomizerTool.cs

示例5: IsPickingParticle

	// Control --------------------------------------------------------------------------
	public bool IsPickingParticle(Ray ray)
	{
		if (IsParticle() == false)
			return false;

		if (m_WireObject == null)
			return false;

		List<Vector4>	listPos = m_WireObject.GetLastParticlePostions();
		foreach (Vector4 pos in listPos)
		{
			Bounds	bounds = new Bounds(new Vector3(pos.x, pos.y, pos.z), new Vector3(pos.w, pos.w, pos.w));
			if (bounds.IntersectRay(ray))
				return true;
		}

		return false;
	}
开发者ID:ziyihu,项目名称:LordOfSinU3D,代码行数:19,代码来源:FxmInfoIndexing.cs

示例6: RaycastSide

		private PivotType RaycastSide(SuperCube aCube, Ray aRay) {
			aRay.origin    = aCube.transform.InverseTransformPoint(aRay.origin);
			aRay.direction = aCube.transform.InverseTransformDirection(aRay.direction);
			aRay.direction.Normalize();

			Vector3   size    = aCube.Extents / 2;
			PivotType side    = PivotType.None;
			float     closest = float.MaxValue;
			float     dist    = 0;

			Bounds bounds = new Bounds();
			bounds.center = Vector3.zero;
			bounds.extents = size;
			if (bounds.IntersectRay(aRay, out dist)) {
				side = PivotType.All;
				closest = dist + 0.1f;
			}

			if (CheckSide(aRay, new Vector3( 0, 0,-1), size.z, Mathf.Min(size.x, size.y), closest, out dist)) {
				closest = dist;
				side    = PivotType.Back;
			}
			if (CheckSide(aRay, new Vector3( 0, 0, 1), size.z, Mathf.Min(size.x, size.y), closest, out dist)) {
				closest = dist;
				side    = PivotType.Front;
			}
			if (CheckSide(aRay, new Vector3(-1, 0, 0), size.x, Mathf.Min(size.y, size.z), closest, out dist)) {
				closest = dist;
				side    = PivotType.Right;
			}
			if (CheckSide(aRay, new Vector3( 1, 0, 0), size.x, Mathf.Min(size.y, size.z), closest, out dist)) {
				closest = dist;
				side    = PivotType.Left;
			}
			if (CheckSide(aRay, new Vector3( 0,-1, 0), size.y, Mathf.Min(size.x, size.z), closest, out dist)) {
				closest = dist;
				side    = PivotType.Top;
			}
			if (CheckSide(aRay, new Vector3( 0, 1, 0), size.y, Mathf.Min(size.x, size.z), closest, out dist)) {
				closest = dist;
				side    = PivotType.Bottom;
			}

			return side;
		}
开发者ID:rhysb89,项目名称:AdelaidePrototype,代码行数:45,代码来源:SuperCubeEditor.cs

示例7: ObjectRaycast

		/**
		 * Return the nearest hit object in scene.  Does not require a collider.
		 */
		public static GameObject ObjectRaycast(Ray ray, IEnumerable<GameObject> objects)
		{
			Renderer renderer;
			float distance = Mathf.Infinity;
			float best = Mathf.Infinity;
			GameObject obj = null;
			Bounds bounds = new Bounds(Vector3.zero, Vector3.one);

			pb_RaycastHit hit;

			foreach(GameObject go in objects)
			{
				Ray localRay = TransformRay(ray, go.transform);

				renderer = go.GetComponent<Renderer>();

				if( renderer != null )
				{
					if( renderer.bounds.IntersectRay(ray, out distance) )
					{
						MeshFilter mf = go.GetComponent<MeshFilter>();

						if( mf != null && mf.sharedMesh != null && MeshRaycast(mf.sharedMesh, localRay, out hit))
						{
							if(hit.distance < best)
							{
								best = hit.distance;
								obj = go;
							}
						}
					}
				}
				else
				{
					bounds.center = go.transform.position;

					if(bounds.IntersectRay(ray, out distance))
					{
						if( distance < best )
						{
							best = distance;
							obj = go;
						}
					}
				}
			}

			return obj;
		}
开发者ID:procore3d,项目名称:giles,代码行数:52,代码来源:pb_HandleUtility.cs


注:本文中的UnityEngine.Bounds.IntersectRay方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。