Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

352
Views
Escuche la entrada clave del script del editor

Estoy usando un script de editor colocado en la carpeta del editor, que escucha una tecla presionada. Cuando se presiona la tecla, se supone que desencadena una función del script MonoBehavior . El problema es que la función no se activa en absoluto. Incluso estoy agregando EventSystem en mi inspector. ¿Cuál es el problema aquí? :

 [CustomEditor (typeof (Switcher))] public class SiwtcherEditor : Editor { void OnSceneGUI () { Switcher script = (Switcher) target; Event e = Event.current; switch (e.type) { case EventType.KeyDown: { if (Event.current.keyCode == (KeyCode.A)) { Debug.Log ("A pressed"); script.SwitchHere(); e.Use (); } break; } } } }
 public class Switcher : MonoBehaviour { public void SwitchHere () { Debug.Log ("GotINPUT"); } }
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Si alguien se encuentra con este problema, el problema era que no se llamaba a OnSceneGUI(). Entonces, el problema se resuelve con la función OnEnable() como se indica a continuación:

 [CustomEditor (typeof (Switcher))] public class SiwtcherEditor : Editor { void OnSceneGUI (SceneView sceneView) { SceneView.RepaintAll (); Switcher script = (Switcher) target; Event e = Event.current; switch (e.type) { case EventType.KeyDown: { if (Event.current.keyCode == (KeyCode.A)) { script.SwitchHere(); e.Use (); } break; } } } void OnEnable () { SceneView.duringSceneGui += OnSceneGUI; } void OnDisable () { SceneView.duringSceneGui -= OnSceneGUI; } }
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!