/// <summary> /// Moves the the specified layer down the layer hierarchy. /// </summary> /// <param name="map">The reference to a <see cref="GridMap"/> type.</param> /// <param name="index"> /// The index of the layer that will be deleted. /// </param> /// <param name="visible">The prefabs for the layer will have there active states set.</param> /// <param name="callback">A callback with one parameter containing the items whose visibility will be set.</param> public static void SetLayerVisibility(this GridMap map, int index, bool visible, Action <GameObject[]> callback) { var items = map.GetLayerPrefabs(index); if (callback != null) { callback(items.ToArray()); } foreach (var item in items) { item.SetActive(visible); } map.Layers[index].Visible = visible; }
/// <summary> /// Deletes the the specified layer from a <see cref="GridMap"/> type. /// </summary> /// <param name="map">The reference to a <see cref="GridMap"/> type.</param> /// <param name="index"> /// The index of the layer that will be deleted. /// </param> /// <remarks>This method does not record an undo operation.</remarks> public static void DeleteLayer(this GridMap map, int index) { // find list of objects to delete var items = map.GetLayerPrefabs(index); while (items.Count > 0) { #if UNITY_EDITOR Object.DestroyImmediate(items[0]); #else Object.Destroy(items[0]); #endif items.RemoveAt(0); } var list = new List <GridMapLayerModel>(map.Layers); list.RemoveAt(index); map.Layers = list.ToArray(); }