[unity中级案例五子棋大战] 课程中ui做到了自适应,但是棋盘没有做到自适应,改变横纵比或者固定分辨率后,棋盘可能就溢出场景了,棋盘的格子也是大致的与unity的单位格相对应的,请问有什么方法可以让棋盘也做到自适应
float width = GetComponent<SpriteRenderer>().bounds.size.x;
float targetWidth = Camera.main.orthographicSize * 2 / Screen.height * Screen.width;
Vector3 scale = transform.localScale;
scale.x = targetWidth / width;
scale.y = targetWidth / width;
transform.localScale = scale;