public NinePatch GetPatch(string name) { NinePatch patch = Optional <NinePatch>(name); if (patch != null) { return(patch); } try { TextureRegion region = GetRegion(name); if (region is TextureAtlas.AtlasRegion) { int[] splits = (region as TextureAtlas.AtlasRegion).Splits; if (splits != null) { patch = new NinePatch(region, splits[0], splits[1], splits[2], splits[3]); int[] pads = (region as TextureAtlas.AtlasRegion).Pads; if (pads != null) { patch.SetPadding(pads[0], pads[1], pads[2], pads[3]); } } } if (patch == null) { patch = new NinePatch(region); } Add <NinePatch>(name, patch); return(patch); } catch { throw new Exception("No NinePatch, TextureRegion, or Texture registered with name: " + name); } }