- Home /
Question by
travelsound84 · Dec 18, 2021 at 09:47 AM ·
colliderboundswrong
Collider bounds size is 0
Hi everybody,
I have an issue with getting the correct bounds of the collider of my video player bar.
For some reason, I always get 0. I even check if the game object and it's parent object are active and I print it out:
public void InitializeTimeLineBounds()
{
float xTimeLineStart;
float xTimeLineWidth;
print("initBounds of " + transform.parent.parent.name);
print(gameObject.activeInHierarchy.ToString());
print(gameObject.activeSelf.ToString());
if (gameObject.activeInHierarchy == false)
{
transform.parent.parent.gameObject.SetActive(true);
xTimeLineStart = transform.GetComponent<Collider>().bounds.min.x;
xTimeLineWidth = transform.GetComponent<Collider>().bounds.size.x;
transform.parent.parent.gameObject.SetActive(false);
}
else
{
print("hier1");
//transform.parent.parent.gameObject.SetActive(true);
xTimeLineStart = transform.GetComponent<Collider>().bounds.min.x;
xTimeLineWidth = transform.GetComponent<Collider>().bounds.size.x;
}
print(xTimeLineStart);
print(xTimeLineWidth);
}
Here is what I get printed: ![alt text][1]
And this is what the GameObject in the inspector looks like in play mode: ![alt text][2]
Does anybody have an idea what's causing the variable xTimeLineWidth to be 0? I have commented the "transform.parent.parent.gameObject.SetActive(true);" line, because from the printout I can see that it is actually active. Even uncommented I get the same issue. [1]: /storage/temp/190108-screenshot-2021-12-18-at-103451.png [2]: /storage/temp/190109-screenshot-2021-12-18-at-103715.png
screenshot-2021-12-18-at-103451.png
(105.6 kB)
screenshot-2021-12-18-at-103715.png
(277.9 kB)
Comment