public static void Push(MapTileRenderer r) { if (r.gameObject.transform.parent != null) { r.gameObject.transform.parent = null; } r.Enabled = false; r.ResetToEmpty(); pool.Push(r); }
internal static bool SetTile(MapTileRenderer renderer, string atlasName, string picName) { if (atlasDic.ContainsKey(atlasName)) { MapTileAtlas atlas = atlasDic[atlasName]; foreach (var pi in atlas.info.Pictures) { if (pi.name == picName) { // 找到了,开始整理renderer renderer.mr.material = atlas.material; renderer.SetRect(pi.rect); return(true); } } return(false); } else { Texture2D tex = Resources.Load <Texture2D>("Atlas/" + atlasName); string json = Resources.Load <TextAsset>("Atlas/" + atlasName + "_config").text; MapTileAtlasInfo info = JsonUtility.FromJson <MapTileAtlasInfo>(json); MapTileAtlas atlas = new MapTileAtlas() { texture = tex, info = info, material = new Material(defaultMaterial) }; atlas.material.SetTexture("_MainTex", tex); atlasDic.Add(atlasName, atlas); foreach (var pi in atlas.info.Pictures) { if (pi.name == picName) { // 找到了,开始整理renderer renderer.mr.material = atlas.material; renderer.SetRect(pi.rect); return(true); } } return(false); } }