0
私の2Dゲームでは、私は画像コンポーネント(スプライト付き)とGridLayoutコンポーネントを持つパネルを持っています。私も(子供と)パネル用のボタンを作成するスクリプトを入れているパネルで ユニティ:イメージ上のボタンの位置に基づいてイメージのピクセルを取得する
public void InitializeGrid(int rows, int columns, List<RbzFilteredWord> words)
{
RectTransform myRect = GetComponent<RectTransform>();
buttonHeight = myRect.rect.height/(float)rows;
buttonWidth = myRect.rect.width/(float)columns;
GridLayoutGroup grid = this.GetComponent<GridLayoutGroup>();
grid.cellSize = new Vector2(buttonWidth, buttonHeight);
...
for (int i = 0; i < rows; i++)
{
for (int j = 0; j < columns; j++)
{
button = (Button)Instantiate(prefab);
button.transform.SetParent(transform, false);
...
}
問題:
各ボタンのテキストは、画素の色を示す必要があります(下にある画像から)ボタンのピボット位置で
私はこのメソッドが利用できることを知っています:GetPixel(x、y)、しかし、私はこのメソッドのパラメータとしてどの座標を使う必要があるのか分かりません。統一時のnoob
私はそれを知っています。しかし、気をつけて、私は回避策を見つけた – PrisonMike