Reputation: 98
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.
But for other scripts which inherit from Interactable() shows Gizmos properly
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 );
}
Upvotes: 1
Views: 1110
Reputation: 4551
I needed to comment out the Gizmos.matrix = transform.parent.localToWorldMatrix;
to see the yellow cube.
To see both you need to call the OnDrawGizmos()
of the base class in the OnDrawGizmos()
of the child class like this:
void OnDrawGizmos()
{
base.OnDrawGizmos();
//Gizmos.matrix = transform.parent.localToWorldMatrix;
Gizmos.color = Color.yellow;
Gizmos.DrawWireCube(transform.position, Vector3.one);
}
Upvotes: 2