Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

569
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda