コード例 #1
0
            protected override void RowGUI(RowGUIArgs args)
            {
                TileMapTreeViewItem item = args.item as TileMapTreeViewItem;
                Layer l      = item.layer;
                Rect  r      = args.rowRect;
                float indent = GetContentIndent(args.item);

                r.x     += indent;
                r.width -= EditorGUIUtility.singleLineHeight * 2 + indent;
                GUIContent c = new GUIContent(l.name);

                if (l is TileLayer)
                {
                    c.image = tileLayerIcon;
                }
                else if (l is ObjectGroup)
                {
                    c.image = objectGroupIcon;
                }
                else if (l is ImageLayer)
                {
                    c.image = imageLayerIcon;
                }
                else if (l is GroupLayer)
                {
                    c.image = groupLayerIcon;
                }
                GUI.Label(r, c);

                GUIStyle visStyle = new GUIStyle(GUI.skin.toggle);

                visStyle.normal.background   = invisibleIcon;
                visStyle.onNormal.background = visibleIcon;
                r.x    += r.width;
                r.width = EditorGUIUtility.singleLineHeight;
                bool visible = GUI.Toggle(r, l.visible, "", visStyle);

                if (l.visible != visible)
                {
                    l.visible = visible;
                    tileMap.UpdateVisible();
                }

                Color color = GUI.color;

                GUI.color = Color.black;
                GUIStyle lockStyle = new GUIStyle(GUI.skin.toggle);

                lockStyle.normal.background   = unlockedIcon;
                lockStyle.onNormal.background = lockedIcon;
                r.x      += r.width;
                l.locked  = GUI.Toggle(r, l.locked, "", lockStyle);
                GUI.color = color;
            }
コード例 #2
0
 protected override TreeViewItem BuildRoot()
 {
     root = new TileMapTreeViewItem {
         id = -1, depth = -1, displayName = "TileMap"
     };
     for (int i = tileMap.tmxFile.layers.Count - 1; i >= 0; i--)
     {
         AddLayerItem(root, tileMap.tmxFile.layers[i] as Layer);
     }
     SetupDepthsFromParentsAndChildren(root);
     return(root);
 }
コード例 #3
0
            void AddLayerItem(TileMapTreeViewItem parent, Layer layer)
            {
                TileMapTreeViewItem item = new TileMapTreeViewItem {
                    id = layer.id, displayName = layer.name, layer = layer
                };

                parent.AddChild(item);
                if (layer is GroupLayer)
                {
                    GroupLayer group = layer as GroupLayer;
                    for (int i = group.layers.Count - 1; i >= 0; i--)
                    {
                        AddLayerItem(item, group.layers[i] as Layer);
                    }
                }
            }
コード例 #4
0
            protected override void SelectionChanged(IList <int> selectedIds)
            {
                if (selectedIds.Count == 0)
                {
                    return;
                }
                int id = selectedIds[0];
                TileMapTreeViewItem item = FindItem(id, root) as TileMapTreeViewItem;

                if (item != null && item.layer != null)
                {
                    // Debug.Log(item.layer.name);
                    selectedLayer   = item.layer;
                    selectedLayerID = item.id;
                }
                else if (item == null)
                {
                    List <int> ids = new List <int>();
                    ids.Add(selectedLayerID);
                    SetSelection(ids);
                }
            }