Exemple #1
0
 /// <summary>
 /// Updates <see cref="ItemData.EditorLayerName"/>, while managing Undo.
 /// </summary>
 /// <param name="item">Tree layer element to update</param>
 /// <param name="layerName">New layer name</param>
 private static void ApplyLayerNameToItem(ILayerableItemAuthoring item, string layerName)
 {
     if (item.EditorLayerName != layerName)
     {
         if (item is MonoBehaviour behaviour)
         {
             Undo.RecordObject(behaviour, $"Item {behaviour.name}: Change layer name from {item.EditorLayerName} to {layerName}");
         }
         item.EditorLayerName = layerName;
     }
 }
 private void AddToLayer(ILayerableItemAuthoring item)
 {
     if (item == null)
     {
         return;
     }
     if (item.EditorLayerName == string.Empty)
     {
         item.EditorLayerName = $"Layer_{item.EditorLayer + 1}";
     }
     if (!_layers.ContainsKey(item.EditorLayerName))
     {
         _layers.Add(item.EditorLayerName, new List <MonoBehaviour>());
     }
     _layers[item.EditorLayerName].Add((MonoBehaviour)item);
 }
 /// <summary>
 /// Construct as <see cref="LayerTreeViewElementType.Item"/>.
 /// </summary>
 /// <param name="item">Game item behavior</param>
 public LayerTreeElement(ILayerableItemAuthoring item)
 {
     Item      = item;
     IsVisible = Item.EditorLayerVisibility;
 }