Skip to content

Instantly share code, notes, and snippets.

@haramakoto
Created February 10, 2023 02:18
Show Gist options
  • Save haramakoto/50853885491e29f3f181d59eded0d750 to your computer and use it in GitHub Desktop.
Save haramakoto/50853885491e29f3f181d59eded0d750 to your computer and use it in GitHub Desktop.
RendererのBoundsを設定する
namespace hoge.hoge
{
using UnityEngine;
public class BoundsSetter : MonoBehaviour
{
[SerializeField]
private Vector3 targetBoundsSize;
private void Start()
{
this.SetBounds();
}
[ContextMenu("SetBounds")]
private void SetBounds()
{
Bounds currentBounds = this.GetComponent<Renderer>().localBounds;
currentBounds.extents = this.targetBoundsSize;
this.GetComponent<Renderer>().localBounds = currentBounds;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment