I’m trying to set up some basic classes, but I can’t figure it out how I can make the Block class callable like this: “Blocks.getBlockById(id).texture.top”
I’m just getting this error:
BCE0019: 'texture' is not a member of 'object'.
Here’s my code:
import UnityEngine public class BlockTexture(): // function parameters are the position in the texture def textureIndexToPosition(i as int): return Vector2( Mathf.Floor(i/Blocks.textureSize), i % Blocks.textureSize ) def constructor(_top as int, _north as int, _east as int, _south as int, _west as int, _bottom as int): top as Vector2 = textureIndexToPosition(_top) north as Vector2 = textureIndexToPosition(_north) east as Vector2 = textureIndexToPosition(_east) south as Vector2 = textureIndexToPosition(_south) west as Vector2 = textureIndexToPosition(_west) bottom as Vector2 = textureIndexToPosition(_bottom) public class Block(): def constructor(_id as int, _name as string, _texture as BlockTexture ): id as int = _id name as string = _name texture as BlockTexture = _texture public static class Blocks (MonoBehaviour): public textureSize as int = 10; public blockList as List = [ Block(0, "Stone", BlockTexture(0, 0, 0, 0, 0, 0) ), Block(1, "Dirt", BlockTexture(1, 1, 1, 1, 1, 1) ), Block(2, "Grass", BlockTexture(3, 2, 2, 2, 2, 1) ) ] public def getBlockById(id): return blockList[id]
Thanks in advance!