private void RegisterBlock(Block b, BlockDataAttribute attributes) { b.Id = BlockRegistrationId; BlockRegistrationId++; b.Data = attributes; Texture2D[] loadedTextures = new Texture2D[6]; for (int i = 0; i < 6; i++) { Texture2D blockTexture = (Texture2D)Resources.Load(b.Data.TextureNames[i]); if (blockTexture == null) { Debug.LogWarning("Block: " + b.Data.DisplayName + " references a texture that doesn't exist. Falling back"); blockTexture = (Texture2D)Resources.Load("notexture"); } loadedTextures[i] = blockTexture; } string name = attributes.DisplayName; if (RegisteredBlocks.ContainsKey(name)) { throw new InvalidOperationException("Cannot have two blocks with the same name!"); } RegisteredBlocks[name] = new RegisteredBlock() { Block = b, }; }
private void RegisterBlock(Block b, BlockDataAttribute attributes) { b.Id = BlockRegistrationId; BlockRegistrationId++; b.Data = attributes; Texture2D[] loadedTextures = new Texture2D[6]; for(int i = 0; i < 6; i++) { Texture2D blockTexture = (Texture2D)Resources.Load(b.Data.TextureNames[i]); if (blockTexture == null) { Debug.LogWarning("Block: " + b.Data.DisplayName + " references a texture that doesn't exist. Falling back"); blockTexture = (Texture2D)Resources.Load("notexture"); } loadedTextures[i] = blockTexture; } string name = attributes.DisplayName; if (RegisteredBlocks.ContainsKey(name)) { throw new InvalidOperationException("Cannot have two blocks with the same name!"); } RegisteredBlocks[name] = new RegisteredBlock() { Block = b, }; }