I want to instantiate a prefab at the mouse position in the editor. All the answers I found till now are for instatiate a prefab at runtime but i want to instantiate in the editor. Currently I am trying to use input.GetMouseButtonDown but that doesn't seem to work ? Also is it fine to use raycasting in the editor itself?
EDIT: Alright I found that we need to use eventtype.MouseDown but now the script is not executing? there are no errors in the console window
using UnityEngine;
using UnityEditor;
[ExecuteInEditMode]
public class mapMaker : Editor
{
public GameObject rock;
private void OnSceneGUI()
{
if (Event.current.type == EventType.MouseDown)
{
Ray ray = Camera.current.ScreenPointToRay(Event.current.mousePosition);
RaycastHit hit;
if (Physics.Raycast(ray, out hit, 1000.0f))
{
Debug.Log(Event.current.mousePosition);
Vector3 newTilePosition = hit.point;
Instantiate(rock, newTilePosition, Quaternion.identity);
}
}
}
}
```