About 6,060,000 results
Open links in new tab
  1. Unity width and height of the gameobject - Stack Overflow

    Feb 14, 2019 · If your object has a renderer, you can use renderer.bounds.size, which will return a vector with the height and width (and depth, if it is in 3D). You can also get the width and …

  2. Reliable way to get width/height of UI element? - Unity Discussions

    May 22, 2015 · I’ve been using the following to calculate the width and height of the element: var rectTransform = GetComponent<RectTransform>(); float width = rectTransform.rect.width; …

  3. Unity: How can I get the width of a gameobject?

    Aug 14, 2016 · Either set the sprite's Pixel Per Unit value to a 1:1 ratio, or manually calculate the ratio multiplier: PixelUnits = Sprite.rect.width / Sprite.bounds.size.x; In the above code you …

  4. How do you find the height,width,depth of a GameObject ... - Reddit

    Feb 19, 2021 · I found a website that says to get the height, width, depth of a mesh, use this code: public static Vector3 sizeUpGameObject(GameObject g) { Vector3 objectSize=new …

  5. Unity 3D: Get the Height and Width of a Game Object in Unity

    Jul 27, 2015 · To get the pixel height and width of a game object in Unity, you need to get the RectTransform and then Rect object. The following code will return the Rect object and then …

  6. How to find width and height of game object, Unity2D

    May 4, 2015 · Your code to get the width should be in the inverse order: GameObject mynewball = (GameObject)Instantiate(ball); RectTransform rt = (RectTransform)mynewball.transform; …

  7. unity game engine - Getting the width of a sprite - Stack Overflow

    If you are using Unity 5 you should use this code: float tileWidth = tileSet[0].GetComponent<SpriteRenderer>().bounds.size.x; Pay attention to your pixels per unit.

  8. How to find the width and height of an object - Unity Discussions

    Jan 16, 2014 · Bounds myBounds = renderer.bounds; Vector3 width = myBounds.width; Vector3 height = myBounds.height; Can also use min / max positions with myBounds.min.x/y and …

  9. How to get the size (width and height) of a 2D GameObject?

    Mar 1, 2022 · You can use a foreach loop to do this pretty easily and this: https://docs.unity3d.com/ScriptReference/Bounds.html. Why do you need to get the …

  10. Getting width of 2d object in unity 3d - Stack Overflow

    Feb 27, 2014 · I'm using the new 2d tools in Unity3d, and I have a game object with a 2d polygonal collider attached to it. I just want to understand how to get the width of this object! …

Refresh