/// Get a plane mesh of the size "size" public static Mesh GetPlaneMesh(Vector2 size) { float id = (size.x + size.y * 666f); if (MeshPool.planes.ContainsKey(id)) { return(MeshPool.planes[id].mesh); } MeshPool.planes.Add(id, MeshPool.GenPlaneMesh(size)); return(MeshPool.planes[id].mesh); }
/// Get a plane mesh of the size "size" public static Mesh GetHumanPlaneMesh(Vector2 size, Direction direction) { float id = (size.x + size.y * 666f) + (int)direction * 333f; if (MeshPool.humanPlanes.ContainsKey(id)) { return(MeshPool.humanPlanes[id].mesh); } MeshPool.humanPlanes.Add(id, MeshPool.GenHumanMesh(size, direction)); return(MeshPool.humanPlanes[id].mesh); }
/// Get the mesh for corners for a connected tilable public static Mesh GetCornersPlane(bool[] corners) { int id = HashUtils.HashBoolArray(corners); if (MeshPool.cornerPlanes.ContainsKey(id)) { return(MeshPool.cornerPlanes[id].mesh); } MeshPool.cornerPlanes.Add(id, MeshPool.GenCornersPlane(corners)); return(MeshPool.cornerPlanes[id].mesh); }
/// Get a new graphic instance (or an existing one) public static GraphicInstance GetNew( GraphicDef def, Color color = default(Color), Texture2D texture = null, float drawPriority = -42f, Mesh mesh = null ) { Mesh _mesh = (mesh == null) ? MeshPool.GetPlaneMesh(def.size) : mesh; Color _color = (color == default(Color)) ? def.color : color; Texture2D _texture = (texture == null) ? Res.textures[def.textureName] : texture; float _priority = (drawPriority == -42f) ? def.drawPriority : drawPriority; int id = GraphicInstance.GetUID(def, _color, _texture, _priority, _mesh); if (GraphicInstance.instances.ContainsKey(id)) { return(GraphicInstance.instances[id]); } GraphicInstance.instances.Add(id, new GraphicInstance(id, def, _mesh, _color, _texture, _priority)); return(GraphicInstance.instances[id]); }