diff --git a/DungeonShooting_Godot/prefab/ui/TileSetEditorSegment.tscn b/DungeonShooting_Godot/prefab/ui/TileSetEditorSegment.tscn
index 1928861..1ae0339 100644
--- a/DungeonShooting_Godot/prefab/ui/TileSetEditorSegment.tscn
+++ b/DungeonShooting_Godot/prefab/ui/TileSetEditorSegment.tscn
@@ -5,8 +5,8 @@
[ext_resource type="Shader" path="res://resource/material/Grid.gdshader" id="2_t1p2n"]
[ext_resource type="Texture2D" uid="uid://uhhfgdhpk7i4" path="res://icon.png" id="2_wr143"]
[ext_resource type="Script" path="res://src/game/ui/tileSetEditorSegment/MaskBrush.cs" id="4_ytys0"]
-[ext_resource type="Script" path="res://src/game/ui/tileSetEditorSegment/TileSelectedCell.cs" id="6_ebs5u"]
[ext_resource type="Texture2D" uid="uid://bn47bmilcw4x0" path="res://resource/sprite/ui/commonIcon/Select2.png" id="6_g5ey6"]
+[ext_resource type="Script" path="res://src/game/ui/tileSetEditorSegment/TileSelected.cs" id="6_gql80"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_u3xqn"]
shader = ExtResource("2_t1p2n")
@@ -128,11 +128,11 @@
[node name="RightBg" type="VBoxContainer" parent="HSplitContainer/Right/MarginContainer"]
layout_mode = 2
-script = ExtResource("6_ebs5u")
+script = ExtResource("6_gql80")
[node name="Label" type="Label" parent="HSplitContainer/Right/MarginContainer/RightBg"]
layout_mode = 2
-text = "已经导入的图块(右键移除):"
+text = "已经导入的图块(双击移除):"
[node name="ScrollContainer" type="ScrollContainer" parent="HSplitContainer/Right/MarginContainer/RightBg"]
layout_mode = 2
diff --git a/DungeonShooting_Godot/src/framework/common/NodeExtend.cs b/DungeonShooting_Godot/src/framework/common/NodeExtend.cs
index e9988f0..fcd6c36 100644
--- a/DungeonShooting_Godot/src/framework/common/NodeExtend.cs
+++ b/DungeonShooting_Godot/src/framework/common/NodeExtend.cs
@@ -83,6 +83,21 @@
{
return (control.SizeFlagsHorizontal & Control.SizeFlags.Expand) != 0;
}
+
+ ///
+ /// 返回鼠标是否在Ui矩形内
+ ///
+ public static bool IsMouseInRect(this Control control)
+ {
+ var pos = control.GetLocalMousePosition();
+ if (pos.X < 0 || pos.Y < 0)
+ {
+ return false;
+ }
+
+ var size = control.Size;
+ return pos.X <= size.X && pos.Y <= size.Y;
+ }
///
/// 设置是否启用节点
diff --git a/DungeonShooting_Godot/src/framework/ui/UiBase.cs b/DungeonShooting_Godot/src/framework/ui/UiBase.cs
index 6c932ef..230991e 100644
--- a/DungeonShooting_Godot/src/framework/ui/UiBase.cs
+++ b/DungeonShooting_Godot/src/framework/ui/UiBase.cs
@@ -1,3 +1,4 @@
+using System;
using System.Collections;
using System.Collections.Generic;
using Godot;
@@ -55,6 +56,8 @@
private bool _nestedOpen;
//当前Ui包含的 IUiNodeScript 接口, 关闭Ui是需要调用 IUiNodeScript.OnDestroy()
private HashSet _nodeScripts;
+ //存放事件集合的对象
+ private EventFactory _eventFactory;
public UiBase(string uiName)
{
@@ -212,10 +215,36 @@
{
ParentUi.RecordNestedUi(this, null, UiManager.RecordType.Close);
}
-
+
+ RemoveAllEventListener();
QueueFree();
}
+ ///
+ /// 添加监听事件, 所有事件会在当前 ui 销毁时自动销毁
+ ///
+ /// 事件类型
+ /// 回调函数
+ public void AddEventListener(EventEnum eventType, Action
OnSetMarkVisible,
+
+ ///
+ /// 设置TileSet纹理, 参数
+ ///
+ OnSetTileTexture,
+ ///
+ /// 设置TileSet编辑器的背景颜色, 参数为
+ ///
+ OnSetTileSetBgColor,
+ ///
+ /// 导入选中的Cell图块, 参数为
+ ///
+ OnImportTileCell,
+ ///
+ /// 移除选中的Cell图块, 参数为
+ ///
+ OnRemoveTileCell,
}
diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditor/TileSetEditorPanel.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditor/TileSetEditorPanel.cs
index 7c25b8e..6429b16 100644
--- a/DungeonShooting_Godot/src/game/ui/tileSetEditor/TileSetEditorPanel.cs
+++ b/DungeonShooting_Godot/src/game/ui/tileSetEditor/TileSetEditorPanel.cs
@@ -97,6 +97,9 @@
TextureImage = texture.GetImage();
CellHorizontal = texture.GetWidth() / GameConfig.TileCellSize;
CellVertical = texture.GetHeight() / GameConfig.TileCellSize;
+
+ //派发事件
+ EventManager.EmitEvent(EventEnum.OnSetTileTexture, texture);
}
///
@@ -105,6 +108,9 @@
public void SetBgColor(Color color)
{
BgColor = color;
+
+ //派发事件
+ EventManager.EmitEvent(EventEnum.OnSetTileTexture, color);
}
///
diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditorImport/TileSetEditorImportPanel.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditorImport/TileSetEditorImportPanel.cs
index 71def9a..a99ad59 100644
--- a/DungeonShooting_Godot/src/game/ui/tileSetEditorImport/TileSetEditorImportPanel.cs
+++ b/DungeonShooting_Godot/src/game/ui/tileSetEditorImport/TileSetEditorImportPanel.cs
@@ -10,7 +10,6 @@
private bool _isOpenColorPicker;
private TileSetEditor.TileSetEditorPanel _tileSetEditor;
- private bool _initTexture = false;
public override void OnCreateUi()
{
@@ -26,6 +25,11 @@
S_ImportPreviewBg.Instance.Visible = false;
S_ReimportButton.Instance.Visible = false;
+
+ //监听TileSet纹理改变
+ AddEventListener(EventEnum.OnSetTileTexture, OnSetTileTexture);
+ //监听TileSet背景颜色改变
+ AddEventListener(EventEnum.OnSetTileSetBgColor, OnSetTileSetBgColor);
}
public override void OnDestroyUi()
@@ -34,11 +38,33 @@
_dragBinder.UnBind();
}
- public override void OnShowUi()
+ //TileSet纹理改变
+ private void OnSetTileTexture(object arg)
{
- if (!_initTexture && _tileSetEditor.Texture != null)
+ //判断是否已经初始化好纹理了
+ if (arg is Texture2D texture)
{
- SetTexture(_tileSetEditor.Texture);
+ var sprite2D = S_ImportPreview.Instance;
+ if (sprite2D.Texture != texture)
+ {
+ sprite2D.Texture = texture;
+ S_ImportPreviewBg.Instance.Visible = true;
+ S_ReimportButton.Instance.Visible = true;
+
+ //隐藏导入文本和icon
+ S_ImportLabel.Instance.Visible = false;
+ S_ImportIcon.Instance.Visible = false;
+ S_ImportButton.Instance.Visible = false;
+ }
+ }
+ }
+
+ //背景颜色改变
+ private void OnSetTileSetBgColor(object arg)
+ {
+ if (arg is Color color)
+ {
+ S_ImportPreviewBg.Instance.Color = color;
}
}
@@ -108,7 +134,6 @@
//设置颜色
color =>
{
- S_ImportPreviewBg.Instance.Color = color;
_tileSetEditor.SetBgColor(color);
},
//关闭窗口
@@ -157,28 +182,5 @@
Debug.Log("导入文件: " + file);
var imageTexture = ImageTexture.CreateFromImage(Image.LoadFromFile(file));
_tileSetEditor.SetTexture(imageTexture);
- SetTexture(imageTexture);
- }
-
- ///
- /// 设置纹理
- ///
- public void SetTexture(Texture2D imageTexture)
- {
- _initTexture = true;
- var textureRect = S_Control.L_ImportPreview.Instance;
- if (textureRect.Texture != null)
- {
- textureRect.Texture.Dispose();
- }
-
- textureRect.Texture = imageTexture;
- S_ImportPreviewBg.Instance.Visible = true;
- S_ReimportButton.Instance.Visible = true;
-
- //隐藏导入文本和icon
- S_ImportLabel.Instance.Visible = false;
- S_ImportIcon.Instance.Visible = false;
- S_ImportButton.Instance.Visible = false;
}
}
diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditorProject/TileButtonCell.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditorProject/TileButtonCell.cs
index a7feb45..56aba1d 100644
--- a/DungeonShooting_Godot/src/game/ui/tileSetEditorProject/TileButtonCell.cs
+++ b/DungeonShooting_Godot/src/game/ui/tileSetEditorProject/TileButtonCell.cs
@@ -12,6 +12,7 @@
public override void OnDoubleClick()
{
+ //打开TileSet编辑器面板
var tileSetEditorPanel = CellNode.UiPanel.OpenNextUi(UiManager.UiNames.TileSetEditor);
tileSetEditorPanel.InitData(Data);
}
diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditorSegment/MaskBrush.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditorSegment/MaskBrush.cs
index ac5750a..636992d 100644
--- a/DungeonShooting_Godot/src/game/ui/tileSetEditorSegment/MaskBrush.cs
+++ b/DungeonShooting_Godot/src/game/ui/tileSetEditorSegment/MaskBrush.cs
@@ -32,7 +32,7 @@
}
//绘制鼠标悬停区域
- if (TileEditArea.IsMouseInTexture())
+ if (TileTexture.IsMouseInRect())
{
var pos = TileEditArea.GetMouseCellPosition() * GameConfig.TileCellSize;
DrawRect(
diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditorSegment/TileCell.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditorSegment/TileCell.cs
index 0ae00ce..0004169 100644
--- a/DungeonShooting_Godot/src/game/ui/tileSetEditorSegment/TileCell.cs
+++ b/DungeonShooting_Godot/src/game/ui/tileSetEditorSegment/TileCell.cs
@@ -24,6 +24,12 @@
CellNode.L_CellId.Instance.Text = data.ToString();
}
+ public override void OnDoubleClick()
+ {
+ //双击移除Cell数据
+ EventManager.EmitEvent(EventEnum.OnRemoveTileCell, Data);
+ }
+
public override void OnDestroy()
{
_previewTexture.Dispose();
diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditorSegment/TileEditArea.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditorSegment/TileEditArea.cs
index aedabac..7dd398a 100644
--- a/DungeonShooting_Godot/src/game/ui/tileSetEditorSegment/TileEditArea.cs
+++ b/DungeonShooting_Godot/src/game/ui/tileSetEditorSegment/TileEditArea.cs
@@ -1,4 +1,5 @@
-using Godot;
+using System.Collections.Generic;
+using Godot;
namespace UI.TileSetEditorSegment;
@@ -7,6 +8,7 @@
private TileSetEditorSegment.LeftBg _leftBg;
private DragBinder _dragBinder;
private UiGrid _maskGrid;
+ private readonly HashSet _useMask = new HashSet();
public void SetUiNode(IUiNode uiNode)
{
@@ -20,6 +22,9 @@
_maskGrid = new UiGrid(_leftBg.L_TileTexture.L_MaskRoot.L_MaskRect, typeof(MaskRectCell));
_maskGrid.SetCellOffset(Vector2I.Zero);
+
+ _leftBg.UiPanel.AddEventListener(EventEnum.OnImportTileCell, OnImportCell);
+ _leftBg.UiPanel.AddEventListener(EventEnum.OnRemoveTileCell, OnRemoveCell);
}
public void OnDestroy()
@@ -39,6 +44,11 @@
public override void _Input(InputEvent @event)
{
+ //Ui未打开
+ if (!_leftBg.UiPanel.IsOpen)
+ {
+ return;
+ }
if (@event is InputEventMouseButton mouseButton)
{
if (_leftBg.UiPanel.IsOpen)
@@ -65,18 +75,32 @@
public override void _Process(double delta)
{
+ //Ui未打开
+ if (!_leftBg.UiPanel.IsOpen)
+ {
+ return;
+ }
+
if (Input.IsMouseButtonPressed(MouseButton.Left)) //左键导入
{
- if (IsMouseInTexture())
+ if (_leftBg.L_TileTexture.Instance.IsMouseInRect() && this.IsMouseInRect())
{
- ImportCell(GetMouseCellPosition());
+ var cellPosition = GetMouseCellPosition();
+ if (!_useMask.Contains(cellPosition))
+ {
+ EventManager.EmitEvent(EventEnum.OnImportTileCell, cellPosition);
+ }
}
}
else if (Input.IsMouseButtonPressed(MouseButton.Right)) //右键移除
{
- if (IsMouseInTexture())
+ if (_leftBg.L_TileTexture.Instance.IsMouseInRect() && this.IsMouseInRect())
{
- RemoveCell(GetMouseCellPosition());
+ var cellPosition = GetMouseCellPosition();
+ if (_useMask.Contains(cellPosition))
+ {
+ EventManager.EmitEvent(EventEnum.OnRemoveTileCell, cellPosition);
+ }
}
}
}
@@ -84,33 +108,37 @@
///
/// 导入选中的Cell图块
///
- /// cell位置, 从图块左上角开始
- public void ImportCell(Vector2I cell)
+ private void OnImportCell(object arg)
{
- var cellIndex = _leftBg.UiPanel.EditorPanel.CellPositionToIndex(cell);
- var uiCell = _maskGrid.GetCell(cellIndex);
- if (!uiCell.Data)
+ if (arg is Vector2I cell)
{
- uiCell.SetData(true);
- _leftBg.UiPanel.S_RightBg.Instance.ImportCell(cell);
+ var cellIndex = _leftBg.UiPanel.EditorPanel.CellPositionToIndex(cell);
+ var uiCell = _maskGrid.GetCell(cellIndex);
+ if (uiCell != null && !uiCell.Data)
+ {
+ _useMask.Add(cell);
+ uiCell.SetData(true);
+ }
}
}
///
/// 移除选中的Cell图块
///
- /// cell位置, 从图块左上角开始
- public void RemoveCell(Vector2I cell)
+ private void OnRemoveCell(object arg)
{
- var cellIndex = _leftBg.UiPanel.EditorPanel.CellPositionToIndex(cell);
- var uiCell = _maskGrid.GetCell(cellIndex);
- if (uiCell.Data)
+ if (arg is Vector2I cell)
{
- uiCell.SetData(false);
- _leftBg.UiPanel.S_RightBg.Instance.RemoveCell(cell);
+ var cellIndex = _leftBg.UiPanel.EditorPanel.CellPositionToIndex(cell);
+ var uiCell = _maskGrid.GetCell(cellIndex);
+ if (uiCell != null && uiCell.Data)
+ {
+ _useMask.Remove(cell);
+ uiCell.SetData(false);
+ }
}
}
-
+
//缩小
private void Shrink()
{
@@ -147,8 +175,6 @@
///
public void OnShow()
{
- //背景颜色
- Color = _leftBg.UiPanel.EditorPanel.BgColor;
OnLeftBgResize();
}
@@ -156,33 +182,31 @@
private void OnLeftBgResize()
{
var sprite = _leftBg.L_TileTexture.Instance;
- if (sprite.Texture != _leftBg.UiPanel.EditorPanel.Texture)
- {
- sprite.Texture = _leftBg.UiPanel.EditorPanel.Texture;
- OnChangeTileSetTexture(_leftBg.UiPanel.EditorPanel.Texture);
- }
-
var colorRect = _leftBg.L_Grid.Instance;
colorRect.Material.SetShaderMaterialParameter(ShaderParamNames.Size, Size);
SetGridTransform(sprite.Position, sprite.Scale.X);
}
-
- //改变TileSet纹理
- private void OnChangeTileSetTexture(Texture2D texture)
+
+ ///
+ /// 改变TileSet纹理
+ ///
+ public void OnChangeTileSetTexture(Texture2D texture)
{
+ _leftBg.L_TileTexture.Instance.Texture = texture;
var width = _leftBg.UiPanel.EditorPanel.CellHorizontal;
var height = _leftBg.UiPanel.EditorPanel.CellVertical;
_maskGrid.RemoveAll();
+ _useMask.Clear();
_maskGrid.SetColumns(width);
- for (int i = 0; i < width; i++)
+ for (var i = 0; i < width; i++)
{
- for (int j = 0; j < height; j++)
+ for (var j = 0; j < height; j++)
{
_maskGrid.Add(false);
}
}
}
-
+
//设置网格位置和缩放
private void SetGridTransform(Vector2 pos, float scale)
{
@@ -192,22 +216,6 @@
}
///
- /// 返回鼠标是否在texture区域内
- ///
- public bool IsMouseInTexture()
- {
- var textureRect = _leftBg.L_TileTexture.Instance;
- var pos = textureRect.GetLocalMousePosition();
- if (pos.X < 0 || pos.Y < 0)
- {
- return false;
- }
-
- var size = textureRect.Size;
- return pos.X <= size.X && pos.Y <= size.Y;
- }
-
- ///
/// 返回鼠标所在的单元格位置, 相对于纹理左上角
///
public Vector2I GetMouseCellPosition()
diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditorSegment/TileSelected.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditorSegment/TileSelected.cs
new file mode 100644
index 0000000..a601bc6
--- /dev/null
+++ b/DungeonShooting_Godot/src/game/ui/tileSetEditorSegment/TileSelected.cs
@@ -0,0 +1,63 @@
+using Godot;
+
+namespace UI.TileSetEditorSegment;
+
+public partial class TileSelected : VBoxContainer, IUiNodeScript
+{
+ private TileSetEditorSegment.RightBg _rightBg;
+ private UiGrid _grid;
+
+ public void SetUiNode(IUiNode uiNode)
+ {
+ _rightBg = (TileSetEditorSegment.RightBg)uiNode;
+
+ _grid = new UiGrid(_rightBg.L_ScrollContainer.L_CellButton, typeof(TileCell));
+ _grid.SetCellOffset(new Vector2I(5, 5));
+ _grid.SetAutoColumns(true);
+ _grid.SetHorizontalExpand(true);
+
+ _rightBg.UiPanel.AddEventListener(EventEnum.OnImportTileCell, OnImportCell);
+ _rightBg.UiPanel.AddEventListener(EventEnum.OnRemoveTileCell, OnRemoveCell);
+ }
+
+ ///
+ /// 导入选中的Cell图块
+ ///
+ private void OnImportCell(object obj)
+ {
+ if (obj is Vector2I cell)
+ {
+ _grid.Add(cell);
+ _grid.Sort();
+ }
+ }
+
+ ///
+ /// 移除选中的Cell图块
+ ///
+ private void OnRemoveCell(object obj)
+ {
+ if (obj is Vector2I cell)
+ {
+ var uiCell = _grid.Find(c => c.Data == cell);
+ if (uiCell != null)
+ {
+ _grid.RemoveByIndex(uiCell.Index);
+ }
+ }
+ }
+
+ public void OnDestroy()
+ {
+ _grid.Destroy();
+ }
+
+
+ ///
+ /// 改变TileSet纹理
+ ///
+ public void OnChangeTileSetTexture(Texture2D texture)
+ {
+ _grid.RemoveAll();
+ }
+}
\ No newline at end of file
diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditorSegment/TileSelectedCell.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditorSegment/TileSelectedCell.cs
deleted file mode 100644
index 9bd9914..0000000
--- a/DungeonShooting_Godot/src/game/ui/tileSetEditorSegment/TileSelectedCell.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-using Godot;
-
-namespace UI.TileSetEditorSegment;
-
-public partial class TileSelectedCell : VBoxContainer, IUiNodeScript
-{
- private TileSetEditorSegment.RightBg _rightBg;
- private UiGrid _grid;
-
- public void SetUiNode(IUiNode uiNode)
- {
- _rightBg = (TileSetEditorSegment.RightBg)uiNode;
-
- _grid = new UiGrid(_rightBg.L_ScrollContainer.L_CellButton, typeof(TileCell));
- _grid.SetCellOffset(new Vector2I(5, 5));
- _grid.SetAutoColumns(true);
- _grid.SetHorizontalExpand(true);
- }
-
- public void OnDestroy()
- {
- _grid.Destroy();
- }
-
- public void ImportCell(Vector2I cell)
- {
- _grid.Add(cell);
- _grid.Sort();
- }
-
- public void RemoveCell(Vector2I cell)
- {
- var uiCell = _grid.Find(c => c.Data == cell);
- if (uiCell != null)
- {
- _grid.RemoveByIndex(uiCell.Index);
- }
- }
-}
\ No newline at end of file
diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditorSegment/TileSetEditorSegment.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditorSegment/TileSetEditorSegment.cs
index 561db83..a71a4e9 100644
--- a/DungeonShooting_Godot/src/game/ui/tileSetEditorSegment/TileSetEditorSegment.cs
+++ b/DungeonShooting_Godot/src/game/ui/tileSetEditorSegment/TileSetEditorSegment.cs
@@ -26,7 +26,6 @@
public sealed override void OnInitNestedUi()
{
_ = L_HSplitContainer.L_Left.L_MarginContainer.L_LeftBg;
- _ = L_HSplitContainer.L_Right.L_MarginContainer.L_RightBg;
}
@@ -300,9 +299,9 @@
}
///
- /// 类型: , 路径: TileSetEditorSegment.HSplitContainer.Right.MarginContainer.RightBg
+ /// 类型: , 路径: TileSetEditorSegment.HSplitContainer.Right.MarginContainer.RightBg
///
- public class RightBg : UiNode
+ public class RightBg : UiNode
{
///
/// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorSegment.HSplitContainer.Right.MarginContainer.Label
@@ -330,8 +329,8 @@
}
private ScrollContainer _L_ScrollContainer;
- public RightBg(TileSetEditorSegmentPanel uiPanel, UI.TileSetEditorSegment.TileSelectedCell node) : base(uiPanel, node) { }
- public override RightBg Clone() => new (UiPanel, (UI.TileSetEditorSegment.TileSelectedCell)Instance.Duplicate());
+ public RightBg(TileSetEditorSegmentPanel uiPanel, UI.TileSetEditorSegment.TileSelected node) : base(uiPanel, node) { }
+ public override RightBg Clone() => new (UiPanel, (UI.TileSetEditorSegment.TileSelected)Instance.Duplicate());
}
///
@@ -340,13 +339,13 @@
public class MarginContainer_1 : UiNode
{
///
- /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorSegment.HSplitContainer.Right.RightBg
+ /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorSegment.HSplitContainer.Right.RightBg
///
public RightBg L_RightBg
{
get
{
- if (_L_RightBg == null) _L_RightBg = new RightBg(UiPanel, Instance.GetNode("RightBg"));
+ if (_L_RightBg == null) _L_RightBg = new RightBg(UiPanel, Instance.GetNode("RightBg"));
return _L_RightBg;
}
}
@@ -480,7 +479,7 @@
public ScrollContainer S_ScrollContainer => L_HSplitContainer.L_Right.L_MarginContainer.L_RightBg.L_ScrollContainer;
///
- /// 场景中唯一名称的节点, 节点类型: , 节点路径: TileSetEditorSegment.HSplitContainer.Right.MarginContainer.RightBg
+ /// 场景中唯一名称的节点, 节点类型: , 节点路径: TileSetEditorSegment.HSplitContainer.Right.MarginContainer.RightBg
///
public RightBg S_RightBg => L_HSplitContainer.L_Right.L_MarginContainer.L_RightBg;
diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditorSegment/TileSetEditorSegmentPanel.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditorSegment/TileSetEditorSegmentPanel.cs
index 03a6ff4..2059814 100644
--- a/DungeonShooting_Godot/src/game/ui/tileSetEditorSegment/TileSetEditorSegmentPanel.cs
+++ b/DungeonShooting_Godot/src/game/ui/tileSetEditorSegment/TileSetEditorSegmentPanel.cs
@@ -13,6 +13,11 @@
public override void OnCreateUi()
{
EditorPanel = (TileSetEditorPanel)ParentUi;
+
+ //改变纹理事件
+ AddEventListener(EventEnum.OnSetTileTexture, OnSetTileTexture);
+ //改变背景颜色事件
+ AddEventListener(EventEnum.OnSetTileSetBgColor, OnSetTileSetBgColor);
}
public override void OnShowUi()
@@ -32,4 +37,24 @@
{
}
+
+ //改变TileSet纹理
+ private void OnSetTileTexture(object arg)
+ {
+ if (arg is Texture2D texture)
+ {
+ S_LeftBg.Instance.OnChangeTileSetTexture(texture);
+ S_RightBg.Instance.OnChangeTileSetTexture(texture);
+ }
+ }
+
+ //改变TileSet背景颜色
+ private void OnSetTileSetBgColor(object arg)
+ {
+ //背景颜色
+ if (arg is Color color)
+ {
+ S_LeftBg.Instance.Color = color;
+ }
+ }
}