简体   繁体   中英

How do I clone an object from detecting characters in a string in unity?

I've created a new project to test scripts based on the topics I write. to apply to real projects. But I don't know how to do it...

I have an object called Pad, it is Prefab, and I want it to be cloned according to the string below.

string levelI = "0000000" +
    "0000000" +
    "0111110" +
    "0111110" +
    "0111110" +
    "0111110" +
    "0011100" +
    "0010100" +
    "0010100" +
    "0011100" +
    "0011100";

//Oh, another requirement is how to extract strings from other files

to be in this format after game start

图片在这里

Ah yes, a game page like this looks like a certain game. But this is just an example of what I would like to do from an actual project...

Thank You

You want an array of 11 rows and 7 columns so you input should be

      string[] levelI = {
            "0000000",
            "0000000",
            "0111110",
            "0111110",
            "0111110",
            "0111110",
            "0011100",
            "0010100",
            "0010100",
            "0011100",
            "0011100"
        };
        foreach(string row in levelI)
        {
            //add row new row of buttons
            for(int col = 0; col < 7; col++)
            {
                char digit = row[col];

            }
        }

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