首次提交
This commit is contained in:
42
Assets/Scripts/UI/Tools/PreviewDetailsPanel.Designer.cs
generated
Normal file
42
Assets/Scripts/UI/Tools/PreviewDetailsPanel.Designer.cs
generated
Normal file
@@ -0,0 +1,42 @@
|
||||
/**本脚本为自动生成,每次生成会覆盖!请勿手动修改,生成插件文档及项目地址: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 PreviewDetailsPanel
|
||||
{
|
||||
public GObject this[string aKey] => ContentPane.GetChild(aKey);
|
||||
public override string UIPackName => "Tools";
|
||||
public override string UIResName => "PreviewDetailsPanel";
|
||||
|
||||
[AutoFind(Name = "title")]
|
||||
public GComponent title;
|
||||
[AutoFind(Name = "modelBack")]
|
||||
public GImage modelBack;
|
||||
[AutoFind(Name = "Model")]
|
||||
public ModelViewer Model;
|
||||
[AutoFind(Name = "Quality")]
|
||||
public GImage Quality;
|
||||
[AutoFind(Name = "Basic")]
|
||||
public ItemBasicInfoTag Basic;
|
||||
[AutoFind(Name = "BtnSaveIcon")]
|
||||
public GButton BtnSaveIcon;
|
||||
[AutoFind(Name = "BtnReSet")]
|
||||
public GButton BtnReSet;
|
||||
[AutoFind(Name = "BtnSaveSetting")]
|
||||
public GButton BtnSaveSetting;
|
||||
public override string[] GetDependPackages(){ return new string[] {"Common","Main"}; }
|
||||
|
||||
public static void Show(object param = null){ UI.Inst.OpenUI<PreviewDetailsPanel>(param); }
|
||||
|
||||
public static void Hide(){ UI.Inst.HideUI<PreviewDetailsPanel>(); }
|
||||
|
||||
public static void Del(){ UI.Inst.DestroyUI<PreviewDetailsPanel>(); }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 156ad87133aee5c4a8436e94407c37c5
|
||||
89
Assets/Scripts/UI/Tools/PreviewDetailsPanel.cs
Normal file
89
Assets/Scripts/UI/Tools/PreviewDetailsPanel.cs
Normal file
@@ -0,0 +1,89 @@
|
||||
// 本脚本只在不存在时会生成一次。已存在不会再次生成覆盖
|
||||
|
||||
using System.IO;
|
||||
using FairyGUI;
|
||||
using Fantasy;
|
||||
using UnityEngine;
|
||||
using NBC;
|
||||
using Newtonsoft.Json;
|
||||
using UIPanel = NBC.UIPanel;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public partial class PreviewDetailsPanel : UIPanel
|
||||
{
|
||||
public ItemInfo ItemInfo;
|
||||
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
this.AutoAddClick(OnBtnClick);
|
||||
}
|
||||
|
||||
protected override void OnShow()
|
||||
{
|
||||
ItemInfo = GetData() as ItemInfo;
|
||||
|
||||
Quality.SetQuality(ItemInfo.Config.Quality);
|
||||
|
||||
Basic.SetInfo(ItemInfo);
|
||||
|
||||
// var model = PrefabsHelper.CreatePrefab(ItemInfo.Config.Model);
|
||||
Model.SetData(new ItemInfo()
|
||||
{
|
||||
Id = ItemInfo.Config.Id,
|
||||
ConfigId = ItemInfo.Config.Id,
|
||||
Count = 1,
|
||||
});
|
||||
// Model.SetBackground(Back);
|
||||
|
||||
InputManager.OnUICanceled += OnUICanceled;
|
||||
}
|
||||
|
||||
|
||||
private void OnUICanceled(string action)
|
||||
{
|
||||
if (!IsTop) return;
|
||||
if (action == InputDef.UI.SubPrev)
|
||||
{
|
||||
}
|
||||
else if (action == InputDef.UI.SubNext)
|
||||
{
|
||||
}
|
||||
else if (action == InputDef.UI.Up)
|
||||
{
|
||||
}
|
||||
else if (action == InputDef.UI.Down)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private void OnBtnClick(GComponent btn)
|
||||
{
|
||||
if (btn == BtnSaveIcon)
|
||||
{
|
||||
Model.SaveRenderTextureToPNG(ItemInfo.Config.Id);
|
||||
#if UNITY_EDITOR
|
||||
UnityEditor.AssetDatabase.Refresh();
|
||||
#endif
|
||||
}
|
||||
else if (btn == BtnSaveSetting)
|
||||
{
|
||||
var setting = Model.ViewerSettings;
|
||||
var json = JsonUtility.ToJson(setting); //JsonConvert.SerializeObject(setting);
|
||||
//Assets/Resources/config/Viewer
|
||||
var savePath = Path.Combine(Application.dataPath, $"Resources/config/Viewer/{ItemInfo.ConfigId}.json");
|
||||
File.WriteAllText(savePath, json);
|
||||
#if UNITY_EDITOR
|
||||
UnityEditor.AssetDatabase.Refresh();
|
||||
#endif
|
||||
}
|
||||
else if (btn == BtnReSet)
|
||||
{
|
||||
// Model.ReSetSetting(ItemInfo.Config);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/UI/Tools/PreviewDetailsPanel.cs.meta
Normal file
2
Assets/Scripts/UI/Tools/PreviewDetailsPanel.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8eefc162282655e4aac6215d90c38c95
|
||||
34
Assets/Scripts/UI/Tools/PreviewPanel.Designer.cs
generated
Normal file
34
Assets/Scripts/UI/Tools/PreviewPanel.Designer.cs
generated
Normal file
@@ -0,0 +1,34 @@
|
||||
/**本脚本为自动生成,每次生成会覆盖!请勿手动修改,生成插件文档及项目地址: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 PreviewPanel
|
||||
{
|
||||
public GObject this[string aKey] => ContentPane.GetChild(aKey);
|
||||
public override string UIPackName => "Tools";
|
||||
public override string UIResName => "PreviewPanel";
|
||||
|
||||
[AutoFind(Name = "ItemList")]
|
||||
public CommonItemList ItemList;
|
||||
[AutoFind(Name = "ItemModal")]
|
||||
public BagItem ItemModal;
|
||||
[AutoFind(Name = "BtnGenAllIcon")]
|
||||
public GButton BtnGenAllIcon;
|
||||
[AutoFind(Name = "GenModel")]
|
||||
public ModelViewer GenModel;
|
||||
public override string[] GetDependPackages(){ return new string[] {"Common","Main"}; }
|
||||
|
||||
public static void Show(object param = null){ UI.Inst.OpenUI<PreviewPanel>(param); }
|
||||
|
||||
public static void Hide(){ UI.Inst.HideUI<PreviewPanel>(); }
|
||||
|
||||
public static void Del(){ UI.Inst.DestroyUI<PreviewPanel>(); }
|
||||
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/UI/Tools/PreviewPanel.Designer.cs.meta
Normal file
2
Assets/Scripts/UI/Tools/PreviewPanel.Designer.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c5cbbfd0335a46e45aabd3e1479c8abf
|
||||
172
Assets/Scripts/UI/Tools/PreviewPanel.cs
Normal file
172
Assets/Scripts/UI/Tools/PreviewPanel.cs
Normal file
@@ -0,0 +1,172 @@
|
||||
// 本脚本只在不存在时会生成一次。已存在不会再次生成覆盖
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FairyGUI;
|
||||
using Fantasy;
|
||||
using UnityEngine;
|
||||
using NBC;
|
||||
using NBF.Fishing2;
|
||||
using NBF.Utils;
|
||||
using Log = NBC.Log;
|
||||
using UIPanel = NBC.UIPanel;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public partial class PreviewPanel : UIPanel
|
||||
{
|
||||
private List<ItemInfo> _itemInfos = new List<ItemInfo>();
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
this.AutoAddClick(OnBtnClick);
|
||||
}
|
||||
|
||||
|
||||
protected override void OnShow()
|
||||
{
|
||||
ItemList.List.OnClickItem += OnClickItem;
|
||||
InputManager.OnUICanceled += OnUICanceled;
|
||||
|
||||
List<TabItemData> tabItemList = new List<TabItemData>();
|
||||
|
||||
var dic = GetItemsByType();
|
||||
foreach (var (type, list) in dic)
|
||||
{
|
||||
TabItemData tabItem = new TabItemData
|
||||
{
|
||||
Key = type.ToString()
|
||||
};
|
||||
tabItem.Items.AddRange(list);
|
||||
tabItemList.Add(tabItem);
|
||||
}
|
||||
|
||||
// ItemList.SetPanel(this);
|
||||
ItemList.SetData(tabItemList, true, true);
|
||||
}
|
||||
|
||||
private void OnBtnClick(GComponent btn)
|
||||
{
|
||||
if (btn == BtnGenAllIcon)
|
||||
{
|
||||
AutoGenIcon();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void OnUICanceled(string action)
|
||||
{
|
||||
if (!IsTop) return;
|
||||
if (action == InputDef.UI.SubPrev)
|
||||
{
|
||||
}
|
||||
else if (action == InputDef.UI.SubNext)
|
||||
{
|
||||
}
|
||||
else if (action == InputDef.UI.Up)
|
||||
{
|
||||
}
|
||||
else if (action == InputDef.UI.Down)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private void OnClickItem(object item)
|
||||
{
|
||||
if (item is not BagItem bagItem) return;
|
||||
PreviewDetailsPanel.Show(bagItem.ItemInfo);
|
||||
}
|
||||
|
||||
|
||||
#region 数据处理
|
||||
|
||||
public Dictionary<ItemType, List<ItemInfo>> GetItemsByType()
|
||||
{
|
||||
// List<ItemInfo> Items = new List<ItemInfo>();
|
||||
_itemInfos.Clear();
|
||||
|
||||
var configs = Game.Tables.TbItem.DataList.ToList();
|
||||
foreach (var itemConfig in configs)
|
||||
{
|
||||
ItemInfo itemInfo = new ItemInfo
|
||||
{
|
||||
ConfigId = itemConfig.Id,
|
||||
Count = 1
|
||||
};
|
||||
_itemInfos.Add(itemInfo);
|
||||
}
|
||||
|
||||
var dic = new Dictionary<ItemType, List<ItemInfo>>();
|
||||
foreach (var item in _itemInfos)
|
||||
{
|
||||
var type = item.ConfigId.GetItemType();
|
||||
if (!dic.ContainsKey(type))
|
||||
{
|
||||
dic.Add(type, new List<ItemInfo>());
|
||||
}
|
||||
|
||||
dic[type].Add(item);
|
||||
}
|
||||
|
||||
foreach (var (key, list) in dic)
|
||||
{
|
||||
list.Sort((x, y) => (int)(y.Config.Quality - x.Config.Quality));
|
||||
}
|
||||
|
||||
return dic;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 自动生成所有icon
|
||||
|
||||
private int _index = -1;
|
||||
|
||||
private void AutoGenIcon()
|
||||
{
|
||||
// Timer.ClearAll(this);
|
||||
// Timer.Loop(2f, this, NextIcon);
|
||||
Game.Instance.StartCoroutine(NextIcon());
|
||||
}
|
||||
|
||||
private IEnumerator NextIcon()
|
||||
{
|
||||
foreach (var item in _itemInfos)
|
||||
{
|
||||
GenModel.visible = true;
|
||||
// GenModel.SetData(item.Config);
|
||||
GenModel.SetData(new ItemInfo()
|
||||
{
|
||||
Id = item.Config.Id,
|
||||
ConfigId = item.Config.Id,
|
||||
Count = 1,
|
||||
});
|
||||
yield return new WaitForSeconds(1f);
|
||||
GenModel.SaveRenderTextureToPNG(item.Config.Id);
|
||||
yield return new WaitForSeconds(1f);
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
GenModel.visible = false;
|
||||
UnityEditor.AssetDatabase.Refresh();
|
||||
Timer.ClearAll(this);
|
||||
Log.Info("全部完成===");
|
||||
Notices.Success("全部图标生成完成");
|
||||
#endif
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
protected override void OnHide()
|
||||
{
|
||||
InputManager.OnUICanceled -= OnUICanceled;
|
||||
ItemList.List.OnClickItem -= OnClickItem;
|
||||
}
|
||||
|
||||
protected override void OnDestroy()
|
||||
{
|
||||
base.OnDestroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/UI/Tools/PreviewPanel.cs.meta
Normal file
2
Assets/Scripts/UI/Tools/PreviewPanel.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 536be5135584e52489e3c5b71dc719e1
|
||||
14
Assets/Scripts/UI/Tools/ToolsBinder.cs
Normal file
14
Assets/Scripts/UI/Tools/ToolsBinder.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
/**注册组件绑定关系。本脚本为自动生成,每次生成会覆盖!请勿手动修改,生成插件文档及项目地址:https://git.whoot.com/whoot-games/whoot.fguieditorplugin**/
|
||||
|
||||
using FairyGUI;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public static class ToolsBinder
|
||||
{
|
||||
[UIExtensionAutoBind]
|
||||
public static void BindAll()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/UI/Tools/ToolsBinder.cs.meta
Normal file
2
Assets/Scripts/UI/Tools/ToolsBinder.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2d6aa632a0961684b9f1c720d2ff496d
|
||||
Reference in New Issue
Block a user