public BlockType(ushort id, string name, bool solid, string textureName) { this.id = id; this.name = name; this.solid = solid; this.textureName = textureName; if (solid) { textureSet = Object.FindObjectOfType <TextureSetLoader>().GetByName(textureName); } }
/// <summary> /// Loads all textures from the resource location /// </summary> public void LoadTextures() { var resourceTextures = Resources.LoadAll <Texture2D>(pathToTextureResources); Texture2D packedTextures = new Texture2D(64, 64) { filterMode = FilterMode.Point }; Rect[] rects = packedTextures.PackTextures(resourceTextures, 0, 8192, false); for (int i = 0; i < resourceTextures.Length; i++) { TextureSet tex = new TextureSet(resourceTextures[i].name); tex.AddTexture(rects[i]); AddTexture(tex); } tileSheet = packedTextures; material.mainTexture = packedTextures; }
/// <summary> /// Adds the given textureset to the dictionary /// </summary> /// <param name="textureSet">The textureset to add</param> public void AddTexture(TextureSet textureSet) { textureSets.Add(textureSet.name, textureSet); }