【发布时间】:2016-09-03 00:25:57
【问题描述】:
对于我的 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),但我不知道我需要使用哪个坐标作为这个方法的参数,因为我是一个统一的菜鸟
【问题讨论】:
标签: image unity3d grid getpixel