Generating room layouts from XML - ERROR

So I am rather new to Unity (like, I only started learning it in uni last month), and one of the assignment tasks that is required of me is to parse room data from an XML file, and use that to build a level.

However, when the room layout is actually generated, the top row is shifted quite a bit to the left of the rest of the level.

2971821--220759--level.PNG

Would anyone have any idea what is going on?

Attached are what I believe to be the offending scripts.

Thanks.

2971821–220761–LayoutControl.cs (7.82 KB)
2971821–220762–LayoutMapCodes.cs (107 Bytes)

I couldn´t find out whats wrong with your code but its pretty mutch of it for a simple task. Maby you multiply/divide some where a position with 0.

Also i am not sure why you use xml for roomLayouts images are better suited for this or a costum file format.

Here is some example.

    void Start ()
    {
        Texture2D mapLayout = Resources.Load("image.jp") as Texture2D;//use uncompressed image

        for(int posX = 0; posX < mapLayout.width; posX ++)
            for(int posZ = 0; posZ < mapLayout.width; posZ ++)
            {
                //at a certain amount it could make sense to make a own class to return the room type getType(Color color) returns string/enum type
                if(mapLayout.GetPixel(posX,posZ).Equals(Color.black))
                    addRoomPart(posX,posZ,"wall");
                if(mapLayout.GetPixel(posX,posZ).Equals(Color.white))
                    addRoomPart(posX,posZ,"floor");
            }
    }

    void addRoomPart(int _posX,int _posZ,string _type)
    {
        GameObject roomPart = Resources.Load("path/" + _type);
        //roomPart.transform. ...

    }

Does it work if you use underscores instead of spaces for the empty space at the start of the top row? (the highlighted one in the image above). It’s possible that the XML parser is stripping out the whitespace around the content.

Huh. That’s actually fixed the layout!

I have another problem, though. The portal (the object that transports the player to the next level; represented by the number 1 in the topmost screenshot) isn’t working, even as the player is walking into it. I’ve added a Box Collider to it, with “Is Trigger” checked, so I don’t think that’s the problem. It will either be in LayoutControl (which I’ve already posted) or Portal (as posted below).

2972840–220847–Portal.cs (696 Bytes)