private void OnEnable() { if (Application.isEditor) { SceneView.onSceneGUIDelegate += OnScene; } } private void OnScene(SceneView sceneview) { if (isBursh) { Ray ray = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition);// 从鼠标位置发射射线 RaycastHit hit; // 用于存储射线碰撞的信息 if (Physics.Raycast(ray, out hit)) { Vector3 worldPoint = hit.point; // 获取碰撞点的世界坐标 //Debug.Log("鼠标点击的世界坐标: " + worldPoint); brush.position = worldPoint; } } if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Escape) { isBursh = !isBursh; } }
OnScene的方法自己实现标签:isBursh,hit,实现,Update,current,编辑器,worldPoint,OnScene,Event From: https://www.cnblogs.com/sanyejun/p/17817289.html