Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

563
Vistas
Unity - Gizmos not being drawn properly from Inherited class

Currently I am having an Issue regarding Gizmos being drawn this issue is specific to 2 classes

Interactable() and Door() : Interactable()

inside Interactable() I have:

void OnDrawGizmos () {
    Gizmos.color = Color.grey;
    if (transform.parent != null) {
        Gizmos.DrawWireSphere ( transform.parent.position, interactionDist );
    } else {
        Gizmos.DrawWireSphere ( transform.position, interactionDist );
    }
} 

is being used for interaction area ( regarding door they are child of Frame of the door )

and inside Door() : Interactible()

void OnDrawGizmos () {
    Gizmos.matrix = transform.parent.localToWorldMatrix;
    Gizmos.color = Color.yellow;
    Gizmos.DrawWireCube ( openDistance, Vector3.one);
} 

Issue is that Gizmo created inside Door() is being properly shown while Wire Sphere from Interactable() is completely missing.

Door Gizmo

But for other scripts which inherit from Interactable() shows Gizmos properly

Objects with different script

Only difference i can think off is that others scripts which inherit from this behavior don't have OnDrawGizmos() class.

Could somebody point me out in direction in which i would be able to draw both of them at the same time ?

Thank you.

Edit: After little change and answer from rustyBucketBay worked for me. Sorry for huge amount of Edits.

Updated code:

new void OnDrawGizmos () {
    base.OnDrawGizmos ();
    Gizmos.color = Color.yellow;
    Gizmos.DrawWireCube (transform.parent.position + openDistance, Vector3.one );
}
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

I needed to comment Gizmos.matrix = transform.parent.localToWorldMatrix; to see the yellow cube.

To see both, you need to call the base class's OnDrawGizmos( OnDrawGizmos() in the child class's OnDrawGizmos() like so:

 void OnDrawGizmos() { base.OnDrawGizmos(); //Gizmos.matrix = transform.parent.localToWorldMatrix; Gizmos.color = Color.yellow; Gizmos.DrawWireCube(transform.position, Vector3.one); }
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda