Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


PlaceObject(Vector2, out Vector3, out Vector3)

Casts a ray against the loaded scenes and returns the nearest intersected point on a collider.
Read time 1 minuteLast updated 4 days ago

Definition

  • Type: Method
  • Namespace: UnityEditor
  • Assembly: UnityEditor

PlaceObject(Vector2, Vector3, Vector3)

public static bool PlaceObject(Vector2 guiPosition, out Vector3 position, out Vector3 normal)

Parameters

guiPosition

The GUI position in the SceneView. You can pass mousePosition to this parameter in most cases.

position

Returns the nearest intersected point to a ray cast from the mouse position into the scene.

normal

Returns the normal of the nearest intersected point to a ray cast from the mouse position into the scene.

Returns

Type

Description

boolReturns true if the raycast intersected something in the scene; otherwise, false.

Remarks

Use this method to match the behavior of drag and drop in the SceneView.
HandleUtility.PlaceObject also queries any delegates registered to HandleUtility.placeObjectCustomPasses when determining the nearest point.