拖动物品到快速使用
This commit is contained in:
@@ -14,6 +14,12 @@ namespace NBF
|
||||
|
||||
private void OnInited()
|
||||
{
|
||||
draggable = true;
|
||||
onDragStart.Add(context =>
|
||||
{
|
||||
context.PreventDefault();
|
||||
DragDropManager.inst.StartDrag(this, this.icon, this.icon, (int)context.data);
|
||||
});
|
||||
}
|
||||
|
||||
public virtual void SetData(ItemInfo itemInfo)
|
||||
|
||||
@@ -37,6 +37,8 @@ namespace NBF
|
||||
|
||||
ItemList.SetPanel(this);
|
||||
ItemList.SetData(tabItemList, true, true);
|
||||
|
||||
BagSlotPanel.Show();
|
||||
}
|
||||
|
||||
private void OnUICanceled(string action)
|
||||
|
||||
31
Assets/Scripts/UI/Bag/BagSlotItem.Designer.cs
generated
Normal file
31
Assets/Scripts/UI/Bag/BagSlotItem.Designer.cs
generated
Normal file
@@ -0,0 +1,31 @@
|
||||
/**本脚本为自动生成,每次生成会覆盖!请勿手动修改,生成插件文档及项目地址:https://git.whoot.com/whoot-games/whoot.fguieditorplugin**/
|
||||
|
||||
|
||||
using FairyGUI;
|
||||
using FairyGUI.Utils;
|
||||
using NBC;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public partial class BagSlotItem
|
||||
{
|
||||
public const string URL = "ui://hxr7rc7puiwj1t";
|
||||
|
||||
public GImage back;
|
||||
public GTextField TextIndex;
|
||||
public GTextField TextCount;
|
||||
public GImage Quality;
|
||||
|
||||
public override void ConstructFromXML(XML xml)
|
||||
{
|
||||
base.ConstructFromXML(xml);
|
||||
|
||||
back = (GImage)GetChild("back");
|
||||
TextIndex = (GTextField)GetChild("TextIndex");
|
||||
TextCount = (GTextField)GetChild("TextCount");
|
||||
Quality = (GImage)GetChild("Quality");
|
||||
OnInited();
|
||||
UILanguage.TrySetComponentLanguage(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/UI/Bag/BagSlotItem.Designer.cs.meta
Normal file
2
Assets/Scripts/UI/Bag/BagSlotItem.Designer.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6e8df720091e10e47a8068485beb5b1f
|
||||
16
Assets/Scripts/UI/Bag/BagSlotItem.cs
Normal file
16
Assets/Scripts/UI/Bag/BagSlotItem.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
// 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖
|
||||
|
||||
using UnityEngine;
|
||||
using FairyGUI;
|
||||
using NBC;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public partial class BagSlotItem : GButton
|
||||
{
|
||||
private void OnInited()
|
||||
{
|
||||
onDrop.Add(context => { this.icon = (string)context.data; });
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/UI/Bag/BagSlotItem.cs.meta
Normal file
2
Assets/Scripts/UI/Bag/BagSlotItem.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fbdf8a7405939fd4180c9480ff529c25
|
||||
36
Assets/Scripts/UI/Bag/BagSlotPanel.Designer.cs
generated
Normal file
36
Assets/Scripts/UI/Bag/BagSlotPanel.Designer.cs
generated
Normal file
@@ -0,0 +1,36 @@
|
||||
/**本脚本为自动生成,每次生成会覆盖!请勿手动修改,生成插件文档及项目地址:https://git.whoot.com/whoot-games/whoot.fguieditorplugin**/
|
||||
|
||||
using FairyGUI;
|
||||
using FairyGUI.Utils;
|
||||
using NBC;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
/// <summary> </summary>
|
||||
public partial class BagSlotPanel
|
||||
{
|
||||
public GObject this[string aKey] => ContentPane.GetChild(aKey);
|
||||
public override string UIPackName => "Main";
|
||||
public override string UIResName => "BagSlotPanel";
|
||||
|
||||
[AutoFind(Name = "back")]
|
||||
public GLabel back;
|
||||
[AutoFind(Name = "SlotTitle")]
|
||||
public GComponent SlotTitle;
|
||||
[AutoFind(Name = "List")]
|
||||
public GList List;
|
||||
[AutoFind(Name = "SlotList")]
|
||||
public GList SlotList;
|
||||
[AutoFind(Name = "SlotSeparator")]
|
||||
public GImage SlotSeparator;
|
||||
public override string[] GetDependPackages(){ return new string[] {"Common"}; }
|
||||
|
||||
public static void Show(object param = null){ App.UI.OpenUI<BagSlotPanel>(param); }
|
||||
|
||||
public static void Hide(){ App.UI.HideUI<BagSlotPanel>(); }
|
||||
|
||||
public static void Del(){ App.UI.DestroyUI<BagSlotPanel>(); }
|
||||
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/UI/Bag/BagSlotPanel.Designer.cs.meta
Normal file
2
Assets/Scripts/UI/Bag/BagSlotPanel.Designer.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b20e20ff411c89e42a2bf35a499a5aed
|
||||
67
Assets/Scripts/UI/Bag/BagSlotPanel.cs
Normal file
67
Assets/Scripts/UI/Bag/BagSlotPanel.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
// 本脚本只在不存在时会生成一次。已存在不会再次生成覆盖
|
||||
|
||||
using System.Collections.Generic;
|
||||
using FairyGUI;
|
||||
using Fantasy;
|
||||
using UnityEngine;
|
||||
using NBC;
|
||||
using NBF.Fishing2;
|
||||
using UIPanel = NBC.UIPanel;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public partial class BagSlotPanel : UIPanel
|
||||
{
|
||||
private List<ItemInfo> _items = new List<ItemInfo>();
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
// List.SetVirtual();
|
||||
}
|
||||
|
||||
protected override void OnShow()
|
||||
{
|
||||
SetList();
|
||||
}
|
||||
|
||||
private void SetList()
|
||||
{
|
||||
|
||||
|
||||
var role = App.Main.GetComponent<Role>();
|
||||
var roleBag = role.GetComponent<RoleBag>();
|
||||
_items.Clear();
|
||||
foreach (var roleBagItem in roleBag.Items)
|
||||
{
|
||||
if (CanShow(roleBagItem))
|
||||
{
|
||||
_items.Add(roleBagItem);
|
||||
}
|
||||
}
|
||||
|
||||
List.RemoveChildrenToPool();
|
||||
List.itemRenderer = OnRenderItem;
|
||||
|
||||
List.numItems = _items.Count;
|
||||
}
|
||||
|
||||
void OnRenderItem(int index, GObject obj)
|
||||
{
|
||||
var itemData = _items[index];
|
||||
if (obj is BagItem bagItem)
|
||||
{
|
||||
bagItem.SetData(itemData);
|
||||
}
|
||||
}
|
||||
|
||||
private bool CanShow(ItemInfo itemInfo)
|
||||
{
|
||||
if (itemInfo.ItemType == ItemType.Rod)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/UI/Bag/BagSlotPanel.cs.meta
Normal file
2
Assets/Scripts/UI/Bag/BagSlotPanel.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1d010d83455eca34ab24068d41400c1d
|
||||
@@ -24,6 +24,7 @@ namespace NBF
|
||||
UIObjectFactory.SetPackageItemExtension(ItemBasicInfoTag.URL, typeof(ItemBasicInfoTag));
|
||||
UIObjectFactory.SetPackageItemExtension(ItemGearInfoTag.URL, typeof(ItemGearInfoTag));
|
||||
UIObjectFactory.SetPackageItemExtension(ShopGearItem.URL, typeof(ShopGearItem));
|
||||
UIObjectFactory.SetPackageItemExtension(BagSlotItem.URL, typeof(BagSlotItem));
|
||||
UIObjectFactory.SetPackageItemExtension(BagItem.URL, typeof(BagItem));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user