Created
July 19, 2019 14:25
-
-
Save pr00thmatic/2c15637847d30f20cf498de8712c4996 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEditor; | |
using UnityEditor.SceneManagement; | |
[CustomEditor(typeof(Prueba))] | |
public class PruebaEditor : Editor { | |
Prueba Target { get => (Prueba) target; } | |
void OnSceneGUI () { | |
Ray rayo = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition); | |
Debug.DrawLine(rayo.origin, rayo.origin + rayo.direction * 100); | |
RaycastHit hit; | |
Target.didHit = Physics.Raycast(rayo, out hit); | |
bool isClicking = | |
Event.current.type == EventType.MouseDown && | |
Event.current.button == 0 || | |
Event.current.type == EventType.MouseDrag; | |
if (Target.didHit && isClicking) { | |
GUIUtility.hotControl = GUIUtility.GetControlID(FocusType.Passive); | |
Event.current.Use(); | |
Target.hitName = hit.collider.name; | |
Target.hitPoint.transform.position = hit.point; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment