- Home /
Too subjective and argumentative
Unit sized gaps between my blocks?
I used the script below and this tutorial to follow along: https://www.youtube.com/watch?v=nrSUYMnySR4
using UnityEngine; using System.Collections;
public class Levels : MonoBehaviour {
private int levelWidth;
private int levelHeight;
public Transform NcolWoodOneTile;
public Transform NcolGrassOneTile;
private Color[] tileColors;
public Color NcolWoodOneColor;
public Color NcolGrassOneColor;
public Texture2D levelTexture;![alt text][1]
// Use this for initialization
void Start () {
levelWidth = levelTexture.width;
levelHeight = levelTexture.height;
loadLevel ();
}
// Update is called once per frame
void Update () {
}
void loadLevel () {
tileColors = new Color[levelWidth * levelHeight];
tileColors = levelTexture.GetPixels ();
for(int y = 0; y < levelHeight; y++)
{
for(int x = 0; x < levelWidth; x++)
{
if(tileColors[x+y*levelWidth] == NcolWoodOneColor)
{
Instantiate(NcolWoodOneTile, new Vector3(x, y), Quaternion.identity);
}
if(tileColors[x+y*levelWidth] == NcolGrassOneColor)
{
Instantiate(NcolGrassOneTile, new Vector3(x, y), Quaternion.identity);
}
}
}
}
}
[1]: /storage/temp/34992-screenshot+(70).png
You do not seem to have completed the tutorial. Your code does not match that at 15:34
richyrich the thing he added there was optional. Did you see when he tested it before adding that and it worked?
richyrich the thing he added there was optional. Did you see when he tested it before adding that and it worked?
@awplays49 Fair play mate, I only wrote "not 'seem' to have completed tutorial". Admittedly that could have been expressed more clearly. I have updated the comment. $$anonymous$$y apologies
Follow this Question
Related Questions
Unity large level size in build 0 Answers
End level when all enemies eliminated 2 Answers
How to save achievments in game 2 Answers
Is there any way to destroy script at certain level ? 1 Answer
leaving level 1 Answer