localPositionをXを640としたら、右端の座標として扱いたいです。
「Screen Match Mode > Match width or height」をwidth 1にすると
おそらくやりたいことが実現できているのですが、
可能であればExpandの設定で行いたいです。
■ 現在の設定
canvas scaler >
UIScale Mode > scale with screen size
Reference Resolution > 640 × 1136
Screen Match Mode > Expand
C#
1const int BUTTON_SPACE = 10; 2 3int width = 5; 4int height = 5; 5float imageSize = BUTTON_SIZE * 1.0f; // ボタンの横幅 6float allWidthSize = (imageSize*width) + (BUTTON_SPACE*(width-1)); // ボタン部分の横幅 7float allHeightSize = (imageSize*height) + (BUTTON_SPACE*(height-1)); // ボタン部分の縦幅 8 9for(int x=0; x<width; x++){ 10 11 GameObject obj = (GameObject)Instantiate(prefabButton); 12 13 Vector3 pos = new Vector3 (x*imageSize+BUTTON_SPACE*x, -y*imageSize - BUTTON_SPACE*y, 0); 14 //pos = new Vector3(100,100,0); 15 16 obj.GetComponent<RectTransform>().localPosition = pos + diffPos; 17 obj.GetComponent<RectTransform>().localScale = Vector3.zero; 18 obj.transform.SetParent (parentButton.transform, false); 19}
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/03/13 12:40