繁体   English   中英

将Y和X轴递增Unity C#

[英]Increment a Y and X axis Unity C#

我如何在C#中增加Y轴

例如我有这个数据(预制)

P = Player B = Boss T = Travern

如下所示:

在此处输入图片说明

目前我可以在我的代码中做什么:

GameObject o = Instantiate(prefab_big_road[0]) as GameObject;
            o.transform.SetParent(pos_big_road[0]);
            o.transform.localScale = Vector3.one;
            o.transform.localPosition = new Vector3(2.0f,-5.0f,0f);
            //o.transform.localPosition = new Vector3(x * xl, y * yl, 0f);

            if (allchars.Contains(playerwinnopairboth))
            {
                o.GetComponent<UISprite>().spriteName = "layout_player_bigline-01";
                NGUITools.SetActive(o, true);
            }
            if (allchars.Contains(bankerwinnopairboth))
            {
                o.GetComponent<UISprite>().spriteName = "layout_banker_bigline-01";
                NGUITools.SetActive(o, true);
            }

这是

在此处输入图片说明

他们都集中在一个地方。 有人可以吗

 o.transform.localPosition=new Vector3 (o.transform.localPosition.x,o.transform.localPosition.y+i,o.transform.localPosition.z);

应该只将y轴增加i;

抱歉回复晚了 。 这就是我所做的。

string[,] table = new string[104, 6];

string newPreviousValue = "placeholder";
int xIndex = -1;
int yIndex = 0;

if (table.GetLength(0) < xIndex)
            {
                break;
            }

            if (previousValue.Equals(newPreviousValue) && yIndex < table.GetLength(1) - 1)
            {
                yIndex += 1;
                table[xIndex, yIndex] = previousValue;
            }
            else
            {
                xIndex += 1;
                yIndex = 0;
                table[xIndex, yIndex] = previousValue;
            }
            newPreviousValue = previousValue;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM