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

565
Views
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 answers
Answer question

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 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!