简体   繁体   中英

Increment a Y and X axis Unity C#

How can i possibly increment a Y axis in c#

For Example i have this data(prefab)

P = Player B = Boss T = Travern

This is shown like this :

在此处输入图片说明

What currently i can do in my code:

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);
            }

is this

在此处输入图片说明

They are all in one spot. Could someone please

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

应该只将y轴增加i;

Sorry for the late answer . Here's what i did.

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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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