1
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace MuHuaEditor {
|
||||
/// <summary>
|
||||
/// 属性容器 - 自定义编辑器
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(AttributeContainerConst))]
|
||||
public class AttributeContainerConstEditor : ModuleUIEditor<AttributeContainerConst> {
|
||||
|
||||
public VisualTreeAsset AttributeTemplate = default;
|
||||
|
||||
private UIAttributeList attributeList;
|
||||
|
||||
public VisualElement AttributeList => Q<VisualElement>("AttributeList");
|
||||
|
||||
public override void Initial() {
|
||||
attributeList = new UIAttributeList(AttributeList, AttributeTemplate);
|
||||
attributeList.Initial(value.instances);
|
||||
AddControl(attributeList);
|
||||
}
|
||||
|
||||
|
||||
// public override void OnInspectorGUI() {
|
||||
// base.OnInspectorGUI();
|
||||
// if (GUILayout.Button("创建属性")) { GenerateAttribute(); }
|
||||
// if (GUILayout.Button("删除属性")) { DeleteInstance(); }
|
||||
// }
|
||||
|
||||
/// <summary> 创建属性实例 </summary>
|
||||
// private void GenerateAttribute() {
|
||||
// AttributeInstanceConst instance = CreateInstance<AttributeInstanceConst>();
|
||||
// instance.container = container;
|
||||
// // 加入容器
|
||||
// container.instances.Add(instance);
|
||||
// AssetDatabase.AddObjectToAsset(instance, container);
|
||||
// EditorUtility.SetDirty(instance);
|
||||
// EditorUtility.SetDirty(container);
|
||||
// AssetDatabase.SaveAssets();
|
||||
// }
|
||||
/// <summary> 删除全部实例 </summary>
|
||||
// private void DeleteInstance() {
|
||||
// for (int i = container.instances.Count; i-- > 0;) {
|
||||
// AttributeInstanceConst instance = container.instances[i];
|
||||
// container.instances.Remove(instance);
|
||||
// Undo.DestroyObjectImmediate(instance);
|
||||
// }
|
||||
// EditorUtility.SetDirty(container);
|
||||
// AssetDatabase.SaveAssets();
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d8ae6bbae674e19448216fd6b41cd012
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences:
|
||||
- VisualTreeAsset: {fileID: 9197481963319205126, guid: 95527f76fc8930d4ab47213114a5952b, type: 3}
|
||||
- AttributeTemplate: {fileID: 9197481963319205126, guid: 1749a10e5ffdea045b442dfa323e4028, type: 3}
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,46 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace MuHuaEditor {
|
||||
/// <summary>
|
||||
/// 属性实例 - 自定义编辑器
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(AttributeInstanceConst))]
|
||||
public class AttributeInstanceConstEditor : Editor {
|
||||
|
||||
private AttributeInstanceConst instance;
|
||||
|
||||
private void Awake() => instance = target as AttributeInstanceConst;
|
||||
|
||||
public override void OnInspectorGUI() {
|
||||
base.OnInspectorGUI();
|
||||
if (instance.container == null) { return; }
|
||||
EditorGUILayout.Space(20);
|
||||
|
||||
// 输入字段修改 name
|
||||
EditorGUI.BeginChangeCheck();
|
||||
string newName = EditorGUILayout.TextField("属性名称", instance.name);
|
||||
if (EditorGUI.EndChangeCheck()) { ModifyName(newName); }
|
||||
// 按钮功能
|
||||
if (GUILayout.Button("删除属性")) { DeleteInstance(); }
|
||||
}
|
||||
|
||||
/// <summary> 修改名字 </summary>
|
||||
private void ModifyName(string newName) {
|
||||
instance.name = newName;
|
||||
Undo.RecordObject(instance, "修改属性名称");
|
||||
EditorUtility.SetDirty(instance);
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
/// <summary> 删除实例 </summary>
|
||||
private void DeleteInstance() {
|
||||
AttributeContainerConst container = instance.container;
|
||||
container.instances.Remove(instance);
|
||||
EditorUtility.SetDirty(container);
|
||||
Undo.DestroyObjectImmediate(instance);
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ce2626e82921eb14992661fc763dc7b5
|
||||
guid: dbe28b450df84584cb523a09c813e59b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
@@ -0,0 +1,126 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using MuHua;
|
||||
|
||||
namespace MuHuaEditor {
|
||||
/// <summary>
|
||||
/// 属性 - UI列表
|
||||
/// </summary>
|
||||
public class UIAttributeList : ModuleUIPanel, UIControl {
|
||||
/// <summary> 拖拽预览 </summary>
|
||||
public VisualElement preview;
|
||||
/// <summary> 鼠标位置 </summary>
|
||||
public Vector2 mousePosition;
|
||||
/// <summary> 偏移位置 </summary>
|
||||
public Vector2 offsetPosition;
|
||||
/// <summary> 项目列表 </summary>
|
||||
public ModuleUIItems<UIItem, AttributeInstanceConst> items;
|
||||
|
||||
public UIAttributeList(VisualElement element, VisualTreeAsset templateAsset) : base(element) {
|
||||
items = new ModuleUIItems<UIItem, AttributeInstanceConst>(element, templateAsset,
|
||||
(data, element) => new UIItem(data, element, this));
|
||||
|
||||
element.RegisterCallback<MouseMoveEvent>(FloatingFunc);
|
||||
}
|
||||
private void FloatingFunc(MouseMoveEvent evt) {
|
||||
mousePosition = evt.mousePosition;
|
||||
}
|
||||
|
||||
public void Update() {
|
||||
if (preview == null) { return; }
|
||||
preview.transform.position = mousePosition - offsetPosition;
|
||||
}
|
||||
|
||||
public void Dispose() => items.Release();
|
||||
|
||||
/// <summary> 初始化 </summary>
|
||||
public void Initial(List<AttributeInstanceConst> list) {
|
||||
items.Create(list);
|
||||
}
|
||||
/// <summary> 设置值 </summary>
|
||||
// public void Settings(T value) => callback?.Invoke(value);
|
||||
|
||||
public void MouseDownEvent(VisualElement element) {
|
||||
preview = element;
|
||||
offsetPosition = mousePosition;
|
||||
// Debug.Log($"{preview.worldBound.position} - {mousePosition}");
|
||||
// offsetPosition = preview.worldBound.position - mousePosition;
|
||||
// Debug.Log($"{preview.worldBound.position} = {mousePosition} + {offsetPosition}");
|
||||
}
|
||||
public void MouseUpEvent() {
|
||||
if (preview == null) { return; }
|
||||
preview.transform.position = Vector2.zero;
|
||||
|
||||
int insertIndex = GetInsertIndex(element, preview);
|
||||
int oldIndex = element.IndexOf(preview);
|
||||
|
||||
// 修正插入索引
|
||||
// if (insertIndex > oldIndex) insertIndex--;
|
||||
Debug.Log($"插入位置 {insertIndex} - 旧位置 {oldIndex}");
|
||||
// 重新排序UI和数据
|
||||
if (oldIndex != insertIndex) { MovePreviewElement(oldIndex, insertIndex); }
|
||||
preview = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取插入索引
|
||||
/// </summary>
|
||||
private int GetInsertIndex(VisualElement parent, VisualElement preview) {
|
||||
Vector2 previewCenter = preview.worldBound.center;
|
||||
int insertIndex = 0;
|
||||
for (int i = 0; i < parent.childCount; i++) {
|
||||
var child = parent[i];
|
||||
if (child == preview) continue;
|
||||
if (previewCenter.y < child.worldBound.center.y) {
|
||||
insertIndex = i;
|
||||
break;
|
||||
}
|
||||
insertIndex = i + 1;
|
||||
}
|
||||
return insertIndex;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 移动预览元素到新位置
|
||||
/// </summary>
|
||||
private void MovePreviewElement(int oldIndex, int newIndex) {
|
||||
VisualElement temp = element[oldIndex];
|
||||
// element.RemoveAt(oldIndex);
|
||||
element.Insert(newIndex, temp);
|
||||
}
|
||||
|
||||
/// <summary> UI项 </summary>
|
||||
public class UIItem : ModuleUIItem<AttributeInstanceConst> {
|
||||
public readonly UIAttributeList parent;
|
||||
|
||||
public Label Range => Q<Label>("Range");
|
||||
public TextField Name => Q<TextField>("Name");
|
||||
public EnumField Type => Q<EnumField>("Type");
|
||||
public FloatField Value => Q<FloatField>("Value");
|
||||
|
||||
public UIItem(AttributeInstanceConst value, VisualElement element, UIAttributeList parent) : base(value, element) {
|
||||
this.parent = parent;
|
||||
Name.SetValueWithoutNotify(value.name);
|
||||
Type.Init(value.type);
|
||||
Type.SetValueWithoutNotify(value.type);
|
||||
Value.SetValueWithoutNotify(value.defaultValue);
|
||||
Range.text = $"{value.minValue} ~ {value.maxValue}";
|
||||
element.RegisterCallback<MouseDownEvent>(MouseDownEvent);
|
||||
element.RegisterCallback<MouseUpEvent>(MouseUpEvent);
|
||||
}
|
||||
public override void DefaultState() {
|
||||
// Button.EnableInClassList("button-s", false);
|
||||
}
|
||||
public override void SelectState() {
|
||||
// parent.Settings(value);
|
||||
// Button.EnableInClassList("button-s", true);
|
||||
}
|
||||
|
||||
private void MouseDownEvent(MouseDownEvent evt) => parent.MouseDownEvent(element);
|
||||
|
||||
private void MouseUpEvent(MouseUpEvent evt) => parent.MouseUpEvent();
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cc8dab09130da0a43bcd57ddecde2332
|
||||
guid: 82adca68fa56cb14382ebd547a8bf044
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -1,43 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
/// <summary>
|
||||
/// 属性容器 - 自定义编辑器
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(ConstAttributeContainer))]
|
||||
public class ConstAttributeContainerEditor : Editor {
|
||||
|
||||
private ConstAttributeContainer container;
|
||||
|
||||
private void Awake() => container = target as ConstAttributeContainer;
|
||||
|
||||
public override void OnInspectorGUI() {
|
||||
base.OnInspectorGUI();
|
||||
if (GUILayout.Button("创建属性")) { GenerateAttribute(); }
|
||||
if (GUILayout.Button("删除属性")) { DeleteInstance(); }
|
||||
}
|
||||
|
||||
/// <summary> 创建属性实例 </summary>
|
||||
private void GenerateAttribute() {
|
||||
ConstAttributeInstance instance = CreateInstance<ConstAttributeInstance>();
|
||||
instance.container = container;
|
||||
// 加入容器
|
||||
container.instances.Add(instance);
|
||||
AssetDatabase.AddObjectToAsset(instance, container);
|
||||
EditorUtility.SetDirty(instance);
|
||||
EditorUtility.SetDirty(container);
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
/// <summary> 删除全部实例 </summary>
|
||||
private void DeleteInstance() {
|
||||
for (int i = container.instances.Count; i-- > 0;) {
|
||||
ConstAttributeInstance instance = container.instances[i];
|
||||
container.instances.Remove(instance);
|
||||
Undo.DestroyObjectImmediate(instance);
|
||||
}
|
||||
EditorUtility.SetDirty(container);
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
/// <summary>
|
||||
/// 属性实例 - 自定义编辑器
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(ConstAttributeInstance))]
|
||||
public class ConstAttributeInstanceEditor : Editor {
|
||||
|
||||
private ConstAttributeInstance instance;
|
||||
|
||||
private void Awake() => instance = target as ConstAttributeInstance;
|
||||
|
||||
public override void OnInspectorGUI() {
|
||||
base.OnInspectorGUI();
|
||||
if (instance.container == null) { return; }
|
||||
EditorGUILayout.Space(20);
|
||||
|
||||
// 输入字段修改 name
|
||||
EditorGUI.BeginChangeCheck();
|
||||
string newName = EditorGUILayout.TextField("属性名称", instance.name);
|
||||
if (EditorGUI.EndChangeCheck()) { ModifyName(newName); }
|
||||
// 按钮功能
|
||||
if (GUILayout.Button("删除属性")) { DeleteInstance(); }
|
||||
}
|
||||
|
||||
/// <summary> 修改名字 </summary>
|
||||
private void ModifyName(string newName) {
|
||||
instance.name = newName;
|
||||
Undo.RecordObject(instance, "修改属性名称");
|
||||
EditorUtility.SetDirty(instance);
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
/// <summary> 删除实例 </summary>
|
||||
private void DeleteInstance() {
|
||||
ConstAttributeContainer container = instance.container;
|
||||
container.instances.Remove(instance);
|
||||
EditorUtility.SetDirty(container);
|
||||
Undo.DestroyObjectImmediate(instance);
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 01e61c86999f6aa40aa7742bb891014e
|
||||
guid: 51b8c6d3c0b5b3d459dca741e39b455e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
+2
-2
@@ -6,10 +6,10 @@ using UnityEngine;
|
||||
/// 属性容器 - 常量
|
||||
/// </summary>
|
||||
[CreateAssetMenu(menuName = "MuHua/属性模块/属性容器")]
|
||||
public class ConstAttributeContainer : ScriptableObject {
|
||||
public class AttributeContainerConst : ScriptableObject {
|
||||
/// <summary> 属性列表 </summary>
|
||||
[HideInInspector]
|
||||
public List<ConstAttributeInstance> instances;
|
||||
public List<AttributeInstanceConst> instances;
|
||||
|
||||
/// <summary> 转换数据 </summary>
|
||||
public AttributeContainer To() {
|
||||
+3
-3
@@ -6,7 +6,7 @@ using UnityEngine;
|
||||
/// 属性实例 - 常量
|
||||
/// </summary>
|
||||
[CreateAssetMenu(menuName = "MuHua/属性模块/属性实例")]
|
||||
public class ConstAttributeInstance : ScriptableObject {
|
||||
public class AttributeInstanceConst : ScriptableObject {
|
||||
/// <summary> 属性类型 </summary>
|
||||
public AttributeType type;
|
||||
/// <summary> 默认值 </summary>
|
||||
@@ -14,11 +14,11 @@ public class ConstAttributeInstance : ScriptableObject {
|
||||
/// <summary> 最小值 </summary>
|
||||
public float minValue;
|
||||
/// <summary> 最大值 </summary>
|
||||
public float maxValue = float.MaxValue;
|
||||
public float maxValue = 9999;
|
||||
|
||||
/// <summary> 属性容器 </summary>
|
||||
[HideInInspector]
|
||||
public ConstAttributeContainer container;
|
||||
public AttributeContainerConst container;
|
||||
|
||||
/// <summary> 转换数据 </summary>
|
||||
public AttributeInstance To() {
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 48193b9c6d7c6af4088a00876ccaa1c3
|
||||
guid: 535afb79004b58e43a958d46e4f3eb20
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9871787cca5a9e54fab450c7d3674d69
|
||||
guid: 34e0f6e731b56d54db838c594430c73b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6f6de86e3bf3ec348a2cfde1e36e77bd
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 12385, guid: 0000000000000000e000000000000000, type: 0}
|
||||
disableValidation: 0
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
|
||||
<ui:Template name="AttributeTemplate" src="project://database/Assets/ModuleCore/ModuleAttribute/UI%20Toolkit/AttributeContainerConstEditor/AttributeTemplate.uxml?fileID=9197481963319205126&guid=1749a10e5ffdea045b442dfa323e4028&type=3#AttributeTemplate" />
|
||||
<Style src="project://database/Assets/ModuleCore/ModuleAttribute/UI%20Toolkit/AttributeContainerConstEditor/AttributeContainerConstEditor.uss?fileID=7433441132597879392&guid=6f6de86e3bf3ec348a2cfde1e36e77bd&type=3#AttributeContainerConstEditor" />
|
||||
<ui:VisualElement name="AttributeList" style="flex-grow: 1;">
|
||||
<ui:Instance template="AttributeTemplate" name="AttributeTemplate" />
|
||||
<ui:Instance template="AttributeTemplate" name="AttributeTemplate" />
|
||||
<ui:Instance template="AttributeTemplate" name="AttributeTemplate" />
|
||||
<ui:Instance template="AttributeTemplate" name="AttributeTemplate" />
|
||||
</ui:VisualElement>
|
||||
<ui:VisualElement name="ButtonGroup" style="flex-direction: row;">
|
||||
<ui:Button text="创建属性" parse-escape-sequences="true" display-tooltip-when-elided="true" name="Button1" style="margin-top: 2px; margin-right: 2px; margin-bottom: 2px; margin-left: 2px; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px;" />
|
||||
<ui:Button text="删除全部属性" parse-escape-sequences="true" display-tooltip-when-elided="true" name="Button2" style="margin-top: 2px; margin-right: 2px; margin-bottom: 2px; margin-left: 2px; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px;" />
|
||||
<ui:VisualElement style="flex-grow: 1;" />
|
||||
<ui:Button text="删除属性" parse-escape-sequences="true" display-tooltip-when-elided="true" name="Button3" style="margin-top: 2px; margin-right: 2px; margin-bottom: 2px; margin-left: 2px; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px;" />
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 95527f76fc8930d4ab47213114a5952b
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
|
||||
<Style src="project://database/Assets/ModuleCore/ModuleAttribute/UI%20Toolkit/AttributeContainerConstEditor/AttributeContainerConstEditor.uss?fileID=7433441132597879392&guid=6f6de86e3bf3ec348a2cfde1e36e77bd&type=3#AttributeContainerConstEditor" />
|
||||
<ui:VisualElement style="flex-direction: row; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0; background-color: rgb(51, 51, 51); margin-top: 1px; margin-right: 1px; margin-bottom: 1px; margin-left: 1px; border-top-left-radius: 5px; border-top-right-radius: 5px; border-bottom-right-radius: 5px; border-bottom-left-radius: 5px;">
|
||||
<ui:TextField picking-mode="Ignore" value="filler text" keyboard-type="Default" name="Name" style="margin-top: 2px; margin-right: 2px; margin-bottom: 2px; margin-left: 2px; width: 100px;" />
|
||||
<ui:EnumField type="UnityEngine.TextAlignment, UnityEngine.TextRenderingModule" value="Center" name="Type" style="margin-top: 2px; margin-right: 2px; margin-bottom: 2px; margin-left: 2px; width: 100px;" />
|
||||
<ui:FloatField value="42.2" name="Value" style="flex-grow: 1; margin-top: 2px; margin-right: 2px; margin-bottom: 2px; margin-left: 2px;" />
|
||||
<ui:Label tabindex="-1" text="0-9999" parse-escape-sequences="true" display-tooltip-when-elided="true" name="Range" style="width: 100px; -unity-text-align: middle-center; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0;" />
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1749a10e5ffdea045b442dfa323e4028
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
|
||||
@@ -0,0 +1,102 @@
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using MuHua;
|
||||
|
||||
namespace MuHuaEditor {
|
||||
/// <summary>
|
||||
/// 装备 - 编辑窗口
|
||||
/// </summary>
|
||||
public class EquipmentWindow : ModuleUIEditorWindow {
|
||||
|
||||
public VisualTreeAsset ButtonTemplate = default;
|
||||
|
||||
private EquipmentType currentEquipmentType;
|
||||
private UIEquipmentEnum<EquipmentType> equipmentType;
|
||||
private UIEquipmentEnum<WeaponType> weaponType;
|
||||
private UIEquipmentEnum<ArmorType> armorType;
|
||||
private UIEquipmentEnum<AccessoryType> accessoryType;
|
||||
private UIEquipmentList equipmentList;
|
||||
|
||||
public VisualElement VEEquipmentType => Q<VisualElement>("EquipmentType");
|
||||
public VisualElement VEEquipmentExtendType => Q<VisualElement>("EquipmentExtendType");
|
||||
public VisualElement EquipmentList => Q<VisualElement>("EquipmentList");
|
||||
|
||||
[MenuItem("Window/UI Toolkit/EquipmentWindow")]
|
||||
public static void ShowWindow() {
|
||||
EquipmentWindow wnd = GetWindow<EquipmentWindow>();
|
||||
wnd.titleContent = new GUIContent("EquipmentWindow");
|
||||
}
|
||||
|
||||
public override void Initial() {
|
||||
equipmentType = new UIEquipmentEnum<EquipmentType>(VEEquipmentType, ButtonTemplate, SettingsEquipmentType);
|
||||
weaponType = new UIEquipmentEnum<WeaponType>(VEEquipmentExtendType, ButtonTemplate, (value) => SettingsEquipmentType(value.ToString()));
|
||||
armorType = new UIEquipmentEnum<ArmorType>(VEEquipmentExtendType, ButtonTemplate, (value) => SettingsEquipmentType(value.ToString()));
|
||||
accessoryType = new UIEquipmentEnum<AccessoryType>(VEEquipmentExtendType, ButtonTemplate, (value) => SettingsEquipmentType(value.ToString()));
|
||||
equipmentList = new UIEquipmentList(EquipmentList, rootVisualElement, ButtonTemplate, (value) => Debug.Log(value));
|
||||
AddControl(equipmentList);
|
||||
|
||||
equipmentType.Initial();
|
||||
}
|
||||
public override void OnDestroy() {
|
||||
base.OnDestroy();
|
||||
equipmentType.Release();
|
||||
weaponType.Release();
|
||||
armorType.Release();
|
||||
accessoryType.Release();
|
||||
}
|
||||
|
||||
/// <summary> 设置装备类型 </summary>
|
||||
private void SettingsEquipmentType(EquipmentType type) {
|
||||
currentEquipmentType = type;
|
||||
if (type == EquipmentType.武器) { weaponType.Initial(); }
|
||||
if (type == EquipmentType.护甲) { armorType.Initial(); }
|
||||
if (type == EquipmentType.饰品) { accessoryType.Initial(); }
|
||||
}
|
||||
/// <summary> 设置装备类型 </summary>
|
||||
private void SettingsEquipmentType(string type) {
|
||||
string path = $"Assets/AssetsEquipment/ScriptableObject/{currentEquipmentType}/{type}";
|
||||
EnsureDirectoryExists(path);
|
||||
List<EquipmentConst> equipments = FindConstAssets<EquipmentConst>(path);
|
||||
equipmentList.Initial(equipments);
|
||||
}
|
||||
|
||||
#region 编辑器工具
|
||||
/// <summary> 查找指定文件夹下的所有 T 类型的 ScriptableObject 资源 </summary>
|
||||
public static List<T> FindConstAssets<T>(string folderPath) where T : ScriptableObject {
|
||||
List<T> result = new List<T>();
|
||||
string filter = $"t:{typeof(T).Name}";
|
||||
string[] guids = AssetDatabase.FindAssets(filter, new[] { folderPath });
|
||||
foreach (string guid in guids) {
|
||||
string assetPath = AssetDatabase.GUIDToAssetPath(guid);
|
||||
T asset = AssetDatabase.LoadAssetAtPath<T>(assetPath);
|
||||
if (asset != null) { result.Add(asset); }
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/// <summary> 确保目录存在 </summary>
|
||||
public static void EnsureDirectoryExists(string path) {
|
||||
if (!Directory.Exists(path)) { Directory.CreateDirectory(path); }
|
||||
}
|
||||
#endregion
|
||||
|
||||
private void CreateConstWeapon() {
|
||||
// 创建一个新的 ConstWeapon 资源
|
||||
var asset = ScriptableObject.CreateInstance<WeaponConst>();
|
||||
string path = EditorUtility.SaveFilePanelInProject(
|
||||
"保存 ConstWeapon",
|
||||
"NewConstWeapon.asset",
|
||||
"asset",
|
||||
"请选择保存 ConstWeapon 的路径"
|
||||
);
|
||||
if (!string.IsNullOrEmpty(path)) {
|
||||
AssetDatabase.CreateAsset(asset, path);
|
||||
AssetDatabase.SaveAssets();
|
||||
EditorUtility.FocusProjectWindow();
|
||||
Selection.activeObject = asset;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ec99af1e55d08254f8089eba7fa65bcd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences:
|
||||
- m_ViewDataDictionary: {instanceID: 0}
|
||||
- VisualTreeAsset: {fileID: 9197481963319205126, guid: 866ca35095f42154d97c957787b91a83, type: 3}
|
||||
- ButtonTemplate: {fileID: 9197481963319205126, guid: 72d39f3bc55f0a94196e83e8bfea1857, type: 3}
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fe6d086cc2b6beb4e8d9dfe9339270f5
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using MuHua;
|
||||
|
||||
namespace MuHuaEditor {
|
||||
/// <summary>
|
||||
/// 装备枚举
|
||||
/// </summary>
|
||||
public class UIEquipmentEnum<T> : ModuleUIPanel where T : Enum {
|
||||
|
||||
public Action<T> callback;
|
||||
public ModuleUIItems<UIItem, T> items;
|
||||
|
||||
public UIEquipmentEnum(VisualElement element, VisualTreeAsset templateAsset, Action<T> callback) : base(element) {
|
||||
this.callback = callback;
|
||||
items = new ModuleUIItems<UIItem, T>(element, templateAsset,
|
||||
(data, element) => new UIItem(data, element, this));
|
||||
}
|
||||
/// <summary> 释放资源 </summary>
|
||||
public void Release() => items.Release();
|
||||
|
||||
/// <summary> 初始化 </summary>
|
||||
public void Initial() {
|
||||
items.Create(EnumToList());
|
||||
items.SelectFirst();
|
||||
}
|
||||
/// <summary> 设置值 </summary>
|
||||
public void Settings(T value) => callback?.Invoke(value);
|
||||
|
||||
private List<T> EnumToList() {
|
||||
var list = new List<T>();
|
||||
foreach (var name in Enum.GetValues(typeof(T))) { list.Add((T)name); }
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary> UI项 </summary>
|
||||
public class UIItem : ModuleUIItem<T> {
|
||||
public readonly UIEquipmentEnum<T> parent;
|
||||
|
||||
public Button Button => Q<Button>("Button");
|
||||
|
||||
public UIItem(T value, VisualElement element, UIEquipmentEnum<T> parent) : base(value, element) {
|
||||
this.parent = parent;
|
||||
Button.text = value.ToString();
|
||||
Button.clicked += Select;
|
||||
}
|
||||
public override void DefaultState() {
|
||||
Button.EnableInClassList("button-s", false);
|
||||
}
|
||||
public override void SelectState() {
|
||||
parent.Settings(value);
|
||||
Button.EnableInClassList("button-s", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d8ae6bbae674e19448216fd6b41cd012
|
||||
guid: 1a27a9357cd2dfb46b03783e745821ff
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -0,0 +1,58 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using MuHua;
|
||||
|
||||
namespace MuHuaEditor {
|
||||
/// <summary>
|
||||
/// 装备 - UI列表
|
||||
/// </summary>
|
||||
public class UIEquipmentList : ModuleUIPanel, UIControl {
|
||||
|
||||
public Action<EquipmentConst> callback;
|
||||
public UIScrollViewListV<UIItem, EquipmentConst> items;
|
||||
|
||||
public VisualElement ScrollView => Q<VisualElement>("ScrollView");
|
||||
|
||||
public UIEquipmentList(VisualElement element, VisualElement canvas, VisualTreeAsset templateAsset, Action<EquipmentConst> callback) : base(element) {
|
||||
this.callback = callback;
|
||||
items = new UIScrollViewListV<UIItem, EquipmentConst>(ScrollView, canvas, templateAsset,
|
||||
(data, element) => new UIItem(data, element, this));
|
||||
}
|
||||
|
||||
public void Update() => items.Update();
|
||||
|
||||
public void Dispose() => items.Dispose();
|
||||
|
||||
/// <summary> 初始化 </summary>
|
||||
public void Initial(List<EquipmentConst> equipments) {
|
||||
items.Create(equipments);
|
||||
items.SelectFirst();
|
||||
}
|
||||
|
||||
/// <summary> 设置值 </summary>
|
||||
public void Settings(EquipmentConst value) => callback?.Invoke(value);
|
||||
|
||||
/// <summary> UI项 </summary>
|
||||
public class UIItem : ModuleUIItem<EquipmentConst> {
|
||||
public readonly UIEquipmentList parent;
|
||||
|
||||
public Button Button => Q<Button>("Button");
|
||||
|
||||
public UIItem(EquipmentConst value, VisualElement element, UIEquipmentList parent) : base(value, element) {
|
||||
this.parent = parent;
|
||||
Button.text = value.name;
|
||||
Button.clicked += Select;
|
||||
}
|
||||
public override void DefaultState() {
|
||||
Button.EnableInClassList("button-s", false);
|
||||
}
|
||||
public override void SelectState() {
|
||||
parent.Settings(value);
|
||||
Button.EnableInClassList("button-s", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ea8d2198def9909448f54d619cfc65aa
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,15 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using UnityEditor;
|
||||
|
||||
namespace MuHuaEditor {
|
||||
/// <summary>
|
||||
/// 武器 - 自定义编辑器
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(WeaponConst))]
|
||||
public class WeaponConstEditor : Editor {
|
||||
public VisualTreeAsset ButtonTemplate;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 191c3d543ef38514a8845f693eb75de3
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1eaf517ccfb649341aa59df1d7d437c2
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,12 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 饰品类型
|
||||
/// </summary>
|
||||
public enum AccessoryType {
|
||||
项链 = 0,
|
||||
戒指 = 1,
|
||||
手镯 = 2
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5bc9afb170700e64a902cc2b868b8b04
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,14 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 护甲类型
|
||||
/// </summary>
|
||||
public enum ArmorType {
|
||||
上衣 = 0,
|
||||
头盔 = 1,
|
||||
手套 = 2,
|
||||
腰带 = 3,
|
||||
鞋子 = 4
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3851fbd666690f247b52ab57af296c62
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,23 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 插槽类型
|
||||
/// </summary>
|
||||
public enum EquipmentSlotType {
|
||||
主手 = 0,
|
||||
副手 = 1,
|
||||
|
||||
上衣 = 10,
|
||||
头盔 = 11,
|
||||
手套 = 12,
|
||||
腰带 = 13,
|
||||
鞋子 = 14,
|
||||
|
||||
项链 = 20,
|
||||
戒指1 = 21,
|
||||
戒指2 = 22,
|
||||
手镯1 = 23,
|
||||
手镯2 = 24
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d79bc5d78a1f1124093253ca1cd314f2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,12 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 装备类型
|
||||
/// </summary>
|
||||
public enum EquipmentType {
|
||||
武器 = 0,
|
||||
护甲 = 1,
|
||||
饰品 = 2
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 505a2c6d7fed9924591dfcdccbe928c9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,12 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 武器类型
|
||||
/// </summary>
|
||||
public enum WeaponType {
|
||||
单手 = 0,
|
||||
副手 = 1,
|
||||
双手 = 2
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5d1d95d68b876be4c9d6fb7d25113dee
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fa01c7c9647ebd6468b17280d5065639
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+1
-1
@@ -2,7 +2,7 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ConstWeaponEditor : MonoBehaviour
|
||||
public class Accessory : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7cfcaecd119af2f48adf5a4649d88360
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Armor : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: de8ae08be418e3c48a7f938b6b842caa
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Weapon : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4fdef6696992dc94f977f5ca3a2cc528
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+1
-7
@@ -2,17 +2,11 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 饰品类型
|
||||
/// </summary>
|
||||
public enum AccessoryType {
|
||||
戒指, 手镯, 项链
|
||||
}
|
||||
/// <summary>
|
||||
/// 饰品 - 物品常量
|
||||
/// </summary>
|
||||
[CreateAssetMenu(menuName = "MuHua/物品系统/饰品")]
|
||||
public class ConstAccessory : ConstEquipment {
|
||||
public class AccessoryConst : EquipmentConst {
|
||||
/// <summary> 饰品类型 </summary>
|
||||
public AccessoryType type;
|
||||
|
||||
+2
-7
@@ -2,17 +2,12 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 护甲类型
|
||||
/// </summary>
|
||||
public enum ArmorType {
|
||||
上衣, 头盔, 手套, 腰带, 鞋子
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 护甲 - 物品常量
|
||||
/// </summary>
|
||||
[CreateAssetMenu(menuName = "MuHua/物品系统/护甲")]
|
||||
public class ConstArmor : ConstEquipment {
|
||||
public class ArmorConst : EquipmentConst {
|
||||
/// <summary> 护甲类型 </summary>
|
||||
public ArmorType type;
|
||||
|
||||
+1
-1
@@ -5,6 +5,6 @@ using UnityEngine;
|
||||
/// <summary>
|
||||
/// 装备 - 物品常量
|
||||
/// </summary>
|
||||
public class ConstEquipment : ConstInventoryItem {
|
||||
public class EquipmentConst : InventoryItemConst {
|
||||
|
||||
}
|
||||
+2
-14
@@ -2,27 +2,15 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 武器类型
|
||||
/// </summary>
|
||||
public enum WeaponType {
|
||||
单手, 副手, 双手
|
||||
}
|
||||
/// <summary>
|
||||
/// 武器类别
|
||||
/// </summary>
|
||||
public enum WeaponCategory {
|
||||
剑, 刀, 枪, 弓, 法杖, 斧头, 锤子
|
||||
}
|
||||
/// <summary>
|
||||
/// 武器 - 物品常量
|
||||
/// </summary>
|
||||
[CreateAssetMenu(menuName = "MuHua/物品系统/武器")]
|
||||
public class ConstWeapon : ConstEquipment {
|
||||
public class WeaponConst : EquipmentConst {
|
||||
/// <summary> 武器类型 </summary>
|
||||
public WeaponType type;
|
||||
/// <summary> 武器类别 </summary>
|
||||
public WeaponCategory category;
|
||||
public string category;
|
||||
|
||||
public override InventoryItem To() {
|
||||
Equipment item = new Equipment();
|
||||
-8
@@ -3,14 +3,6 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 插槽类型
|
||||
/// </summary>
|
||||
public enum EquipmentSlotType {
|
||||
主手, 副手, 上衣, 项链,
|
||||
头盔, 手套, 腰带, 鞋子,
|
||||
戒指1, 戒指2, 手镯1, 手镯2
|
||||
}
|
||||
/// <summary>
|
||||
/// 装备插槽
|
||||
/// </summary>
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 36ee47234b03ee74bad8e42c24ee2c6c
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bdc3f13083804594fbdda1c64d9ae51a
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,4 @@
|
||||
.button-s {
|
||||
background-color: rgb(0, 164, 192);
|
||||
color: rgb(255, 255, 255);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2543472de45605a4e8903f740d5db3af
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 12385, guid: 0000000000000000e000000000000000, type: 0}
|
||||
disableValidation: 0
|
||||
@@ -0,0 +1,4 @@
|
||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
|
||||
<Style src="project://database/Assets/UI%20Toolkit/Component/Button/Button.uss?fileID=7433441132597879392&guid=2543472de45605a4e8903f740d5db3af&type=3#Button" />
|
||||
<ui:Button text="Button" parse-escape-sequences="true" display-tooltip-when-elided="true" name="Button" style="margin-top: 2px; margin-right: 2px; margin-bottom: 2px; margin-left: 2px; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px;" />
|
||||
</ui:UXML>
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 72d39f3bc55f0a94196e83e8bfea1857
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a03ad2fda0780f0499f39870c8107b90
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,21 @@
|
||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
|
||||
<ui:Template name="Button1" src="project://database/Assets/UI%20Toolkit/Component/Button/Button1.uxml?fileID=9197481963319205126&guid=72d39f3bc55f0a94196e83e8bfea1857&type=3#Button1" />
|
||||
<Style src="project://database/Assets/UI%20Toolkit/EditorWindow/EquipmentWindow/EquipmentWindow.uss?fileID=7433441132597879392&guid=8bceec5d72cb41343aace6e8d7439e3b&type=3#EquipmentWindow" />
|
||||
<ui:VisualElement name="ScrollView" class="scrollview">
|
||||
<ui:VisualElement name="Viewport" class="scrollview-viewport" style="margin-right: 0; margin-bottom: 0; margin-top: 0; margin-left: 0;">
|
||||
<ui:VisualElement name="Container" class="scrollview-container" style="padding-top: 2px; padding-right: 2px; padding-bottom: 2px; padding-left: 2px;">
|
||||
<ui:Instance template="Button1" name="Button1" />
|
||||
<ui:Instance template="Button1" name="Button1" />
|
||||
<ui:Instance template="Button1" name="Button1" />
|
||||
<ui:Instance template="Button1" name="Button1" />
|
||||
<ui:Instance template="Button1" name="Button1" />
|
||||
</ui:VisualElement>
|
||||
</ui:VisualElement>
|
||||
<ui:VisualElement name="ScrollerHorizontal" class="scroller-horizontal scrollview-horizontal-scroller" style="display: none;">
|
||||
<ui:VisualElement name="Dragger" class="scroller-horizontal-dragger scrollview-horizontal-scroller-dragger" />
|
||||
</ui:VisualElement>
|
||||
<ui:VisualElement name="ScrollerVertical" class="scroller-vertical scrollview-vertical-scroller" style="display: none;">
|
||||
<ui:VisualElement name="Dragger" class="scroller-vertical-dragger scrollview-vertical-scroller-dragger" />
|
||||
</ui:VisualElement>
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 723d660a1c7f9a148829ed36eacad3df
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
|
||||
@@ -0,0 +1,3 @@
|
||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
|
||||
<ui:Button text="Button" parse-escape-sequences="true" display-tooltip-when-elided="true" style="padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; margin-top: 2px; margin-right: 2px; margin-bottom: 2px; margin-left: 2px;" />
|
||||
</ui:UXML>
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 40971501a755d8b4eab02d9deaf63499
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8bceec5d72cb41343aace6e8d7439e3b
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 12385, guid: 0000000000000000e000000000000000, type: 0}
|
||||
disableValidation: 0
|
||||
@@ -0,0 +1,32 @@
|
||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
|
||||
<ui:Template name="Button1" src="project://database/Assets/ModuleCore/ModuleEquipment/UI%20Toolkit/Button/ButtonTemplate.uxml?fileID=9197481963319205126&guid=72d39f3bc55f0a94196e83e8bfea1857&type=3#ButtonTemplate" />
|
||||
<ui:Template name="EquipmentList" src="project://database/Assets/ModuleCore/ModuleEquipment/UI%20Toolkit/EquipmentWindow/EquipmentList.uxml?fileID=9197481963319205126&guid=723d660a1c7f9a148829ed36eacad3df&type=3#EquipmentList" />
|
||||
<Style src="project://database/Assets/ModuleCore/ModuleEquipment/UI%20Toolkit/EquipmentWindow/EquipmentWindow.uss?fileID=7433441132597879392&guid=8bceec5d72cb41343aace6e8d7439e3b&type=3#EquipmentWindow" />
|
||||
<ui:VisualElement name="EquipmentType" style="flex-direction: row; padding-top: 2px; padding-right: 2px; padding-bottom: 2px; padding-left: 2px;">
|
||||
<ui:Instance template="Button1" name="Button1" />
|
||||
<ui:Instance template="Button1" name="Button1" />
|
||||
<ui:Instance template="Button1" name="Button1" />
|
||||
<ui:Instance template="Button1" name="Button1" />
|
||||
<ui:Instance template="Button1" name="Button1" />
|
||||
<ui:Instance template="Button1" name="Button1" />
|
||||
<ui:Instance template="Button1" name="Button1" />
|
||||
<ui:Instance template="Button1" name="Button1" />
|
||||
</ui:VisualElement>
|
||||
<ui:VisualElement style="height: 2px; background-color: rgb(38, 38, 38);" />
|
||||
<ui:VisualElement name="EquipmentExtendType" style="flex-direction: row; padding-top: 2px; padding-right: 2px; padding-bottom: 2px; padding-left: 2px;">
|
||||
<ui:Instance template="Button1" name="Button1" />
|
||||
<ui:Instance template="Button1" name="Button1" />
|
||||
<ui:Instance template="Button1" name="Button1" />
|
||||
<ui:Instance template="Button1" name="Button1" />
|
||||
</ui:VisualElement>
|
||||
<ui:VisualElement style="height: 2px; background-color: rgb(38, 38, 38);" />
|
||||
<ui:VisualElement name="FunctionPanel" style="flex-grow: 1; flex-direction: row;">
|
||||
<ui:Instance template="EquipmentList" name="EquipmentList" style="width: 100px;" />
|
||||
<ui:VisualElement style="background-color: rgb(38, 38, 38); width: 2px;" />
|
||||
</ui:VisualElement>
|
||||
<ui:VisualElement style="height: 2px; background-color: rgb(38, 38, 38);" />
|
||||
<ui:VisualElement name="ButtonGroup" style="flex-direction: row;">
|
||||
<ui:Button text="创建" parse-escape-sequences="true" display-tooltip-when-elided="true" name="Button1" style="margin-top: 2px; margin-right: 2px; margin-bottom: 2px; margin-left: 2px; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; width: 96px;" />
|
||||
<ui:Button text="创建(随机)" parse-escape-sequences="true" display-tooltip-when-elided="true" name="Button2" style="margin-top: 2px; margin-right: 2px; margin-bottom: 2px; margin-left: 2px; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; width: 96px;" />
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 866ca35095f42154d97c957787b91a83
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
|
||||
+1
-1
@@ -6,7 +6,7 @@ using UnityEngine;
|
||||
/// 材料 - 物品常量
|
||||
/// </summary>
|
||||
[CreateAssetMenu(menuName = "MuHua/物品系统/材料")]
|
||||
public class ConstMaterial : ConstInventoryItem {
|
||||
public class ConstMaterial : InventoryItemConst {
|
||||
/// <summary> 最大堆叠数 </summary>
|
||||
public int maxStack = 99;
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
/// <summary>
|
||||
/// 项目拖拽
|
||||
/// </summary>
|
||||
public interface InventoryDrag {
|
||||
/// <summary> 数量 </summary>
|
||||
public int Count { get; }
|
||||
/// <summary> 物品 </summary>
|
||||
public InventoryItem Item { get; }
|
||||
/// <summary> 锚点 </summary>
|
||||
public VisualElement Anchor { get; }
|
||||
|
||||
/// <summary> 取消拖拽 </summary>
|
||||
public void Cancel();
|
||||
/// <summary> 设置物品 </summary>
|
||||
public void Settings(InventoryItem item, int count);
|
||||
}
|
||||
+1
-1
@@ -6,7 +6,7 @@ using UnityEngine;
|
||||
/// 物品 - 常量
|
||||
/// </summary>
|
||||
[CreateAssetMenu(menuName = "MuHua/物品系统/物品")]
|
||||
public class ConstInventoryItem : ScriptableObject {
|
||||
public class InventoryItemConst : ScriptableObject {
|
||||
/// <summary> 图片 </summary>
|
||||
public Sprite sprite;
|
||||
|
||||
@@ -8,7 +8,7 @@ using MuHua;
|
||||
/// </summary>
|
||||
public class AssetsManager : ModuleSingle<AssetsManager> {
|
||||
|
||||
public List<ConstInventoryItem> items;
|
||||
public List<InventoryItemConst> items;
|
||||
|
||||
protected override void Awake() => NoReplace(false);
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user