public void SetMiniMapIcon(Sprite icon, Vector2?cord) { if (miniMapIcon != null) { Destroy(miniMapIcon); } if (cord.HasValue) { Vector3 c = cord.Value; c.z = 10; miniMapIcon = Instantiate(new GameObject(), c, Quaternion.identity); } else { miniMapIcon = Instantiate(new GameObject(), place.GetCenter(), Quaternion.identity); } miniMapIcon.transform.parent = transform; miniMapIcon.name = "MiniMapIcon"; miniMapIcon.layer = LayerMask.NameToLayer("MiniMap"); SpriteRenderer s = miniMapIcon.AddComponent <SpriteRenderer>(); s.sprite = icon; }