Compare commits
10 Commits
7230db792c
...
415da3b111
| Author | SHA1 | Date | |
|---|---|---|---|
| 415da3b111 | |||
| ebf312c6cc | |||
| 304c41775a | |||
| 4597149228 | |||
| 21b7cbcef5 | |||
| dd690d871c | |||
| 62e3374187 | |||
| 65e218850f | |||
| bd27595b0d | |||
| 1b017de1ba |
@@ -0,0 +1,19 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 45818eb64c9b04441b20b29f0230edb7, type: 3}
|
||||
m_Name: "\u707E\u7978\u4E4B\u77ED\u5251"
|
||||
m_EditorClassIdentifier:
|
||||
sprite: {fileID: 0}
|
||||
level: 0
|
||||
rarity: 0
|
||||
type: 0
|
||||
category: 0
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d07fad53a94189c42bcebe454bc4dde0
|
||||
guid: d9f2593221f759045a7a8c191b7c7842
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
@@ -1,69 +0,0 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 23403840a9d12654f8f15c6188728498, type: 3}
|
||||
m_Name: "\u7269\u54C1\u5C5E\u6027"
|
||||
m_EditorClassIdentifier:
|
||||
instances:
|
||||
- {fileID: 6610366098165316818}
|
||||
- {fileID: 2362838488679916709}
|
||||
- {fileID: 4633682211995004289}
|
||||
--- !u!114 &2362838488679916709
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: e891e45f4230ee04d8d329520fd39cbc, type: 3}
|
||||
m_Name: "\u9632\u5FA1"
|
||||
m_EditorClassIdentifier:
|
||||
type: 0
|
||||
defaultValue: 0
|
||||
minValue: 0
|
||||
maxValue: 9999
|
||||
container: {fileID: 11400000}
|
||||
--- !u!114 &4633682211995004289
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: e891e45f4230ee04d8d329520fd39cbc, type: 3}
|
||||
m_Name: "\u9B54\u6CD5\u503C"
|
||||
m_EditorClassIdentifier:
|
||||
type: 3
|
||||
defaultValue: 0
|
||||
minValue: 0
|
||||
maxValue: 100
|
||||
container: {fileID: 11400000}
|
||||
--- !u!114 &6610366098165316818
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: e891e45f4230ee04d8d329520fd39cbc, type: 3}
|
||||
m_Name: "\u653B\u51FB"
|
||||
m_EditorClassIdentifier:
|
||||
type: 0
|
||||
defaultValue: 0
|
||||
minValue: 0
|
||||
maxValue: 9999
|
||||
container: {fileID: 11400000}
|
||||
@@ -1,13 +0,0 @@
|
||||
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:
|
||||
@@ -1,54 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using UnityEditor;
|
||||
using MuHua;
|
||||
|
||||
namespace MuHuaEditor {
|
||||
/// <summary>
|
||||
/// 属性实例 - 自定义编辑器
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(AttributeInstanceConst))]
|
||||
public class AttributeInstanceConstEditor : ModuleUIEditor<AttributeInstanceConst> {
|
||||
|
||||
public UIAttributePanel attributePanel;
|
||||
|
||||
public VisualElement AttributePanel => Q<VisualElement>("AttributePanel");
|
||||
public FloatField Min => Q<FloatField>("Min");
|
||||
public FloatField Max => Q<FloatField>("Max");
|
||||
public Button button => Q<Button>("Button");
|
||||
|
||||
public override void Initial() {
|
||||
attributePanel = new UIAttributePanel(value, AttributePanel);
|
||||
|
||||
Min.SetValueWithoutNotify(value.minValue);
|
||||
Max.SetValueWithoutNotify(value.maxValue);
|
||||
|
||||
Min.RegisterCallback<FocusOutEvent>(evt => ModifyMin());
|
||||
Max.RegisterCallback<FocusOutEvent>(evt => ModifyMax());
|
||||
|
||||
button.clicked += DeleteInstance;
|
||||
}
|
||||
|
||||
/// <summary> 修改最小值 </summary>
|
||||
private void ModifyMin() { value.minValue = Min.value; Dirty(); }
|
||||
/// <summary> 修改最大值 </summary>
|
||||
private void ModifyMax() { value.maxValue = Max.value; Dirty(); }
|
||||
|
||||
/// <summary> 保存资源 </summary>
|
||||
private void Dirty() {
|
||||
EditorUtility.SetDirty(value);
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
|
||||
/// <summary> 删除实例 </summary>
|
||||
private void DeleteInstance() {
|
||||
AttributeContainerConst container = value.container;
|
||||
container.instances.Remove(value);
|
||||
EditorUtility.SetDirty(container);
|
||||
Undo.DestroyObjectImmediate(value);
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,133 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using UnityEditor;
|
||||
using MuHua;
|
||||
|
||||
namespace MuHuaEditor {
|
||||
/// <summary>
|
||||
/// 属性 - UI列表
|
||||
/// </summary>
|
||||
public class UIAttributeList : ModuleUIPanel, UIControl {
|
||||
/// <summary> 模板资源 </summary>
|
||||
public VisualTreeAsset templateAsset;
|
||||
/// <summary> 移动目标 </summary>
|
||||
public VisualElement moving;
|
||||
/// <summary> 拖拽预览 </summary>
|
||||
public VisualElement preview;
|
||||
/// <summary> 项目预览 </summary>
|
||||
public UIItem previewItem;
|
||||
/// <summary> 鼠标偏移 </summary>
|
||||
public Vector2 mousePosition;
|
||||
/// <summary> 位置偏移 </summary>
|
||||
public Vector2 positionOffset;
|
||||
/// <summary> 偏移位置 </summary>
|
||||
public Vector2 mouseOffset;
|
||||
/// <summary> 属性列表 </summary>
|
||||
public AttributeContainerConst container;
|
||||
/// <summary> 项目列表 </summary>
|
||||
public ModuleUIItems<UIItem, AttributeInstanceConst> items;
|
||||
|
||||
public UIAttributeList(VisualElement element, VisualTreeAsset templateAsset) : base(element) {
|
||||
this.templateAsset = templateAsset;
|
||||
items = new ModuleUIItems<UIItem, AttributeInstanceConst>(element, templateAsset,
|
||||
(data, element) => new UIItem(data, element, this));
|
||||
|
||||
element.RegisterCallback<MouseUpEvent>(MouseUpEvent);
|
||||
element.RegisterCallback<MouseMoveEvent>(FloatingFunc);
|
||||
}
|
||||
private void MouseUpEvent(MouseUpEvent evt) {
|
||||
if (preview == null) { return; }
|
||||
preview.parent.Remove(preview);
|
||||
preview = null;
|
||||
moving.EnableInClassList("acce-hide", false);
|
||||
if (previewItem == null) { return; }
|
||||
previewItem.Dispose();
|
||||
|
||||
EditorUtility.SetDirty(container);
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
private void FloatingFunc(MouseMoveEvent evt) {
|
||||
mousePosition = evt.mousePosition;
|
||||
}
|
||||
public void Update() {
|
||||
if (preview == null) { return; }
|
||||
preview.transform.position = positionOffset + mousePosition - mouseOffset;
|
||||
int insertIndex = GetInsertIndex(element, preview);
|
||||
int oldIndex = element.IndexOf(moving);
|
||||
// 修正插入索引
|
||||
// Debug.Log($"{insertIndex} , {oldIndex}");
|
||||
if (insertIndex > oldIndex) insertIndex--;
|
||||
if (oldIndex != insertIndex) { MovePreviewElement(oldIndex, insertIndex); }
|
||||
}
|
||||
public void Dispose() => items.Release();
|
||||
|
||||
/// <summary> 初始化 </summary>
|
||||
public void Initial(AttributeContainerConst container) {
|
||||
this.container = container;
|
||||
items.Create(container.instances);
|
||||
}
|
||||
/// <summary> 设置值 </summary>
|
||||
public void Settings(VisualElement moving, AttributeInstanceConst value) {
|
||||
this.moving = moving;
|
||||
moving.EnableInClassList("acce-hide", true);
|
||||
|
||||
preview = templateAsset.Instantiate();
|
||||
previewItem = new UIItem(value, preview);
|
||||
items.element.Add(preview);
|
||||
|
||||
preview.EnableInClassList("acce-preview", true);
|
||||
// Debug.Log($"{preview.transform.position} , {preview.worldBound.position} , {moving.worldBound.position}");
|
||||
mouseOffset = mousePosition;
|
||||
// preview.transform.position的默认值
|
||||
positionOffset = moving.worldBound.position - preview.worldBound.position;
|
||||
}
|
||||
|
||||
/// <summary> 获取插入索引 </summary>
|
||||
private int GetInsertIndex(VisualElement parent, VisualElement preview) {
|
||||
Vector2 previewCenter = preview.worldBound.center;
|
||||
int insertIndex = 0;
|
||||
for (int i = 0; i < parent.childCount - 1; i++) {
|
||||
VisualElement child = parent[i];
|
||||
if (child == preview) continue;
|
||||
if (previewCenter.y - 10 < 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.Insert(newIndex, temp);
|
||||
|
||||
AttributeInstanceConst instanceConst = container.instances[oldIndex];
|
||||
container.instances.RemoveAt(oldIndex);
|
||||
container.instances.Insert(newIndex, instanceConst);
|
||||
}
|
||||
|
||||
/// <summary> UI项 </summary>
|
||||
public class UIItem : ModuleUIItem<AttributeInstanceConst> {
|
||||
public readonly UIAttributeList parent;
|
||||
public UIAttributePanel attributePanel;
|
||||
|
||||
public UIItem(AttributeInstanceConst value, VisualElement element) : base(value, element) {
|
||||
attributePanel = new UIAttributePanel(value, element);
|
||||
}
|
||||
public UIItem(AttributeInstanceConst value, VisualElement element, UIAttributeList parent) : base(value, element) {
|
||||
this.parent = parent;
|
||||
attributePanel = new UIAttributePanel(value, element);
|
||||
element.RegisterCallback<MouseDownEvent>(MouseDownEvent);
|
||||
}
|
||||
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.Settings(element, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using UnityEditor;
|
||||
using MuHua;
|
||||
|
||||
/// <summary>
|
||||
/// 属性面板
|
||||
/// </summary>
|
||||
public class UIAttributePanel : ModuleUIPanel {
|
||||
|
||||
private AttributeInstanceConst value;
|
||||
|
||||
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 Toggle Boolean => Q<Toggle>("Boolean");
|
||||
|
||||
public UIAttributePanel(AttributeInstanceConst value, VisualElement element) : base(element) {
|
||||
this.value = value;
|
||||
Initial();
|
||||
Name.RegisterCallback<FocusOutEvent>(evt => ModifyName());
|
||||
Type.RegisterValueChangedCallback(evt => ModifyType((AttributeType)evt.newValue));
|
||||
Value.RegisterCallback<FocusOutEvent>(evt => ModifyValue());
|
||||
Boolean.RegisterValueChangedCallback(evt => ModifyBoolean());
|
||||
}
|
||||
|
||||
public void Initial() {
|
||||
Name.SetValueWithoutNotify(value.name);
|
||||
Type.Init(value.type);
|
||||
Value.SetValueWithoutNotify(value.defaultValue);
|
||||
Boolean.value = value.defaultValue > 0;
|
||||
|
||||
if (value.type == AttributeType.Boolean) {
|
||||
Value.style.display = DisplayStyle.None;
|
||||
}
|
||||
else { Boolean.style.display = DisplayStyle.None; }
|
||||
|
||||
if (value.type == AttributeType.Percentage) {
|
||||
Range.text = $"{value.minValue}% ~ {value.maxValue}%";
|
||||
}
|
||||
else { Range.text = $"{value.minValue} ~ {value.maxValue}"; }
|
||||
}
|
||||
|
||||
/// <summary> 修改名字 </summary>
|
||||
private void ModifyName() { value.name = Name.value; Dirty(); }
|
||||
/// <summary> 修改类型 </summary>
|
||||
private void ModifyType(AttributeType type) {
|
||||
if (type == AttributeType.Float) { value.InitialFloat(); }
|
||||
if (type == AttributeType.Integer) { value.InitialInteger(); }
|
||||
if (type == AttributeType.Boolean) { value.InitialBoolean(); }
|
||||
if (type == AttributeType.Percentage) { value.InitialPercentage(); }
|
||||
if (value.type == AttributeType.Boolean) {
|
||||
Value.style.display = DisplayStyle.None;
|
||||
}
|
||||
else { Boolean.style.display = DisplayStyle.None; }
|
||||
Dirty();
|
||||
}
|
||||
/// <summary> 修改默认值 </summary>
|
||||
private void ModifyValue() { value.defaultValue = Value.value; Dirty(); }
|
||||
/// <summary> 修改布尔值 </summary>
|
||||
private void ModifyBoolean() { value.defaultValue = Boolean.value ? 1 : 0; Dirty(); }
|
||||
|
||||
/// <summary> 保存资源 </summary>
|
||||
private void Dirty() {
|
||||
EditorUtility.SetDirty(value);
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 属性容器
|
||||
/// </summary>
|
||||
public class AttributeContainer {
|
||||
/// <summary> 属性字典 </summary>
|
||||
public Dictionary<string, AttributeInstance> dictionary = new Dictionary<string, AttributeInstance>();
|
||||
|
||||
/// <summary> 添加属性 </summary>
|
||||
public void AddInstance(string attributeID, AttributeInstance instance) {
|
||||
if (dictionary.ContainsKey(attributeID)) { return; }
|
||||
dictionary.Add(attributeID, instance);
|
||||
}
|
||||
/// <summary> 添加修改器 </summary>
|
||||
public void AddModifier(string attributeID, AttributeModifier mod, bool isUpdate) {
|
||||
if (!dictionary.ContainsKey(attributeID)) { return; }
|
||||
dictionary[attributeID].AddModifier(mod, isUpdate);
|
||||
}
|
||||
/// <summary> 重新计算值 </summary>
|
||||
public void RecalculateValue() {
|
||||
foreach (var item in dictionary) { item.Value.RecalculateValue(); }
|
||||
}
|
||||
/// <summary> 循环属性集合 </summary>
|
||||
public void ForEach(Action<string, AttributeInstance> action) {
|
||||
foreach (var item in dictionary) { action?.Invoke(item.Key, item.Value); }
|
||||
}
|
||||
/// <summary> 查询值 </summary>
|
||||
public float FindValue(string attributeID) {
|
||||
if (!dictionary.ContainsKey(attributeID)) { return 0; }
|
||||
return dictionary[attributeID].currentValue;
|
||||
}
|
||||
/// <summary> 查询修改器 </summary>
|
||||
public List<AttributeModifier> FindModifier(string attributeID) {
|
||||
if (!dictionary.ContainsKey(attributeID)) { return new(); }
|
||||
return dictionary[attributeID].modifiers;
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 属性容器 - 常量
|
||||
/// </summary>
|
||||
[CreateAssetMenu(menuName = "MuHua/属性模块/属性容器")]
|
||||
public class AttributeContainerConst : ScriptableObject {
|
||||
/// <summary> 属性列表 </summary>
|
||||
[HideInInspector]
|
||||
public List<AttributeInstanceConst> instances = new List<AttributeInstanceConst>();
|
||||
|
||||
/// <summary> 转换数据 </summary>
|
||||
public AttributeContainer To() {
|
||||
AttributeContainer container = new AttributeContainer();
|
||||
instances.ForEach(obj => container.AddInstance(obj.name, obj.To()));
|
||||
return container;
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 属性实例
|
||||
/// </summary>
|
||||
public class AttributeInstance {
|
||||
/// <summary> 属性名称 </summary>
|
||||
public string name;
|
||||
/// <summary> 基础值 </summary>
|
||||
public float baseValue;
|
||||
/// <summary> 当前值 </summary>
|
||||
public float currentValue;
|
||||
/// <summary> 附加值% </summary>
|
||||
public float additionValue;
|
||||
/// <summary> 最小值 </summary>
|
||||
public float minValue;
|
||||
/// <summary> 最大值 </summary>
|
||||
public float maxValue = float.MaxValue;
|
||||
/// <summary> 属性类型 </summary>
|
||||
public AttributeType type;
|
||||
/// <summary> 修改器列表 </summary>
|
||||
public List<AttributeModifier> modifiers = new List<AttributeModifier>();
|
||||
|
||||
/// <summary> 添加修改器 </summary>
|
||||
public void AddModifier(AttributeModifier mod, bool isUpdate) {
|
||||
modifiers.Add(mod);
|
||||
if (isUpdate) { RecalculateValue(); }
|
||||
}
|
||||
/// <summary> 添加修改器 </summary>
|
||||
public void AddModifier(List<AttributeModifier> mods, bool isUpdate) {
|
||||
modifiers.AddRange(mods);
|
||||
if (isUpdate) { RecalculateValue(); }
|
||||
}
|
||||
/// <summary> 重新计算值 </summary>
|
||||
public void RecalculateValue() {
|
||||
currentValue = baseValue;
|
||||
modifiers.ForEach(mod => currentValue = mod.Fixed(currentValue));
|
||||
additionValue = 1;
|
||||
modifiers.ForEach(mod => additionValue = mod.Addition(additionValue));
|
||||
currentValue = currentValue * additionValue;
|
||||
currentValue = Mathf.Clamp(currentValue, minValue, maxValue);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3552e7ce95869d341adbe3a4b2a98851
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,59 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 属性实例 - 常量
|
||||
/// </summary>
|
||||
[CreateAssetMenu(menuName = "MuHua/属性模块/属性实例")]
|
||||
public class AttributeInstanceConst : ScriptableObject {
|
||||
/// <summary> 属性类型 </summary>
|
||||
public AttributeType type;
|
||||
/// <summary> 默认值 </summary>
|
||||
public float defaultValue;
|
||||
/// <summary> 最小值 </summary>
|
||||
public float minValue;
|
||||
/// <summary> 最大值 </summary>
|
||||
public float maxValue = 9999;
|
||||
|
||||
/// <summary> 属性容器 </summary>
|
||||
[HideInInspector]
|
||||
public AttributeContainerConst container;
|
||||
|
||||
public void InitialFloat() {
|
||||
type = AttributeType.Float;
|
||||
defaultValue = 0;
|
||||
minValue = 0;
|
||||
maxValue = 9999;
|
||||
}
|
||||
public void InitialInteger() {
|
||||
type = AttributeType.Integer;
|
||||
defaultValue = 0;
|
||||
minValue = 0;
|
||||
maxValue = 9999;
|
||||
}
|
||||
public void InitialBoolean() {
|
||||
type = AttributeType.Boolean;
|
||||
defaultValue = 0;
|
||||
minValue = 0;
|
||||
maxValue = 1;
|
||||
}
|
||||
public void InitialPercentage() {
|
||||
type = AttributeType.Percentage;
|
||||
defaultValue = 0;
|
||||
minValue = 0;
|
||||
maxValue = 100;
|
||||
}
|
||||
|
||||
/// <summary> 转换数据 </summary>
|
||||
public AttributeInstance To() {
|
||||
AttributeInstance instance = new AttributeInstance();
|
||||
instance.type = type;
|
||||
instance.name = name;
|
||||
instance.baseValue = defaultValue;
|
||||
instance.currentValue = defaultValue;
|
||||
instance.minValue = minValue;
|
||||
instance.maxValue = maxValue;
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e891e45f4230ee04d8d329520fd39cbc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,13 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 属性调整
|
||||
/// </summary>
|
||||
public abstract class AttributeModifier {
|
||||
/// <summary> 固定值 </summary>
|
||||
public abstract float Fixed(float input);
|
||||
/// <summary> 附加值% </summary>
|
||||
public abstract float Addition(float input);
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2a544851e744f1540b431f2506157f18
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,46 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using MuHua;
|
||||
|
||||
/// <summary>
|
||||
/// 属性附加
|
||||
/// </summary>
|
||||
public class AttributeSystem : Module<AttributeSystem> {
|
||||
/// <summary> 修改事件 </summary>
|
||||
public static event Action<AttributeSystem> OnChange;
|
||||
/// <summary> 附加字典 </summary>
|
||||
public Dictionary<string, AttributeContainer> dictionary = new Dictionary<string, AttributeContainer>();
|
||||
|
||||
/// <summary> 应用修改 </summary>
|
||||
public void Apply() => OnChange?.Invoke(this);
|
||||
/// <summary> 添加容器 </summary>
|
||||
public void AddInstance(string containerID, AttributeContainer container) {
|
||||
if (dictionary.ContainsKey(containerID)) { return; }
|
||||
dictionary.Add(containerID, container);
|
||||
OnChange?.Invoke(this);
|
||||
}
|
||||
/// <summary> 添加修改器 </summary>
|
||||
public void AddModifier(string containerID, string attributeID, AttributeModifier mod, bool isUpdate) {
|
||||
if (!dictionary.ContainsKey(containerID)) { return; }
|
||||
dictionary[containerID].AddModifier(attributeID, mod, isUpdate);
|
||||
OnChange?.Invoke(this);
|
||||
}
|
||||
/// <summary> 重新计算值 </summary>
|
||||
public void RecalculateValue() {
|
||||
foreach (var item in dictionary) { item.Value.RecalculateValue(); }
|
||||
}
|
||||
/// <summary> 查询容器 </summary>
|
||||
public AttributeContainer FindContainer(string containerID) {
|
||||
if (!dictionary.ContainsKey(containerID)) { return new(); }
|
||||
return dictionary[containerID];
|
||||
}
|
||||
/// <summary> 查询容器 </summary>
|
||||
public bool TryContainer(string containerID, out AttributeContainer container) {
|
||||
container = null;
|
||||
if (!dictionary.ContainsKey(containerID)) { return false; }
|
||||
container = dictionary[containerID];
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 828a59f9caabfb340aa07273f42ccfa4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bdb0856dce49d2a4cae5b351eed7ef48
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 34e0f6e731b56d54db838c594430c73b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
-14
@@ -1,14 +0,0 @@
|
||||
<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" class="acce-preview" />
|
||||
<ui:Instance template="AttributeTemplate" name="AttributeTemplate" />
|
||||
<ui:Instance template="AttributeTemplate" name="AttributeTemplate" class="acce-hide" />
|
||||
<ui:Instance template="AttributeTemplate" name="AttributeTemplate" />
|
||||
</ui:VisualElement>
|
||||
<ui:VisualElement name="ButtonGroup" style="flex-direction: row; justify-content: space-between;">
|
||||
<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>
|
||||
</ui:UXML>
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b88d603d14ca15f4e9bbd6ebc99e332f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 51817b5555c3c584f846b2c05b877f72
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 12385, guid: 0000000000000000e000000000000000, type: 0}
|
||||
disableValidation: 0
|
||||
-16
@@ -1,16 +0,0 @@
|
||||
<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/AttributeInstanceConstEditor/AttributeInstanceConstEditor.uss?fileID=7433441132597879392&guid=51817b5555c3c584f846b2c05b877f72&type=3#AttributeInstanceConstEditor" />
|
||||
<ui:VisualElement name="AttributePanel" 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:Toggle name="Boolean" style="flex-grow: 1;" />
|
||||
<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: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:FloatField value="42.2" name="Min" style="flex-grow: 1; margin-top: 2px; margin-right: 2px; margin-bottom: 2px; margin-left: 2px;" />
|
||||
<ui:Label tabindex="-1" text="min ~ max" parse-escape-sequences="true" display-tooltip-when-elided="true" 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:FloatField value="42.2" name="Max" style="flex-grow: 1; margin-top: 2px; margin-right: 2px; margin-bottom: 2px; margin-left: 2px;" />
|
||||
</ui:VisualElement>
|
||||
<ui:Button text="删除" 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>
|
||||
@@ -1,18 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Accessory : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7cfcaecd119af2f48adf5a4649d88360
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,18 +0,0 @@
|
||||
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()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: de8ae08be418e3c48a7f938b6b842caa
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,13 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 装备
|
||||
/// </summary>
|
||||
public class Equipment : InventoryItem {
|
||||
/// <summary> 装备类型 (类型1/类型2) </summary>
|
||||
public string type;
|
||||
/// <summary> 词缀列表 </summary>
|
||||
public List<EquipmentAffix> affixes = new List<EquipmentAffix>();
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
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()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4fdef6696992dc94f977f5ca3a2cc528
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -15,5 +15,5 @@ public class EquipmentAffix {
|
||||
/// <summary> 最小值 </summary>
|
||||
public float maxValue = float.MaxValue;
|
||||
/// <summary> 属性类型 </summary>
|
||||
public AttributeType attributeType;
|
||||
public ValueType attributeType;
|
||||
}
|
||||
|
||||
@@ -14,60 +14,60 @@ public class EquipmentColumn {
|
||||
public EquipmentSlot this[string key] => dictionary[key];
|
||||
|
||||
public EquipmentColumn() {
|
||||
AddSlot(WeaponSlot());
|
||||
AddSlot(DeputySlot());
|
||||
// AddSlot(WeaponSlot());
|
||||
// AddSlot(DeputySlot());
|
||||
|
||||
AddSlot(ArmorSlot(EquipmentSlotType.上衣, ArmorType.上衣));
|
||||
AddSlot(ArmorSlot(EquipmentSlotType.头盔, ArmorType.头盔));
|
||||
AddSlot(ArmorSlot(EquipmentSlotType.手套, ArmorType.手套));
|
||||
AddSlot(ArmorSlot(EquipmentSlotType.腰带, ArmorType.腰带));
|
||||
AddSlot(ArmorSlot(EquipmentSlotType.鞋子, ArmorType.鞋子));
|
||||
// AddSlot(ArmorSlot(EquipmentSlotType.上衣, ArmorType.上衣));
|
||||
// AddSlot(ArmorSlot(EquipmentSlotType.头盔, ArmorType.头盔));
|
||||
// AddSlot(ArmorSlot(EquipmentSlotType.手套, ArmorType.手套));
|
||||
// AddSlot(ArmorSlot(EquipmentSlotType.腰带, ArmorType.腰带));
|
||||
// AddSlot(ArmorSlot(EquipmentSlotType.鞋子, ArmorType.鞋子));
|
||||
|
||||
AddSlot(AccessorySlot(EquipmentSlotType.项链, AccessoryType.项链));
|
||||
AddSlot(AccessorySlot(EquipmentSlotType.戒指1, AccessoryType.戒指));
|
||||
AddSlot(AccessorySlot(EquipmentSlotType.戒指2, AccessoryType.戒指));
|
||||
AddSlot(AccessorySlot(EquipmentSlotType.手镯1, AccessoryType.手镯));
|
||||
AddSlot(AccessorySlot(EquipmentSlotType.手镯2, AccessoryType.手镯));
|
||||
// AddSlot(AccessorySlot(EquipmentSlotType.项链, AccessoryType.项链));
|
||||
// AddSlot(AccessorySlot(EquipmentSlotType.戒指1, AccessoryType.戒指));
|
||||
// AddSlot(AccessorySlot(EquipmentSlotType.戒指2, AccessoryType.戒指));
|
||||
// AddSlot(AccessorySlot(EquipmentSlotType.手镯1, AccessoryType.手镯));
|
||||
// AddSlot(AccessorySlot(EquipmentSlotType.手镯2, AccessoryType.手镯));
|
||||
}
|
||||
|
||||
public bool ContainsKey(string key) => dictionary.ContainsKey(key);
|
||||
/// <summary> 添加插槽 </summary>
|
||||
public void AddSlot(EquipmentSlot slot) => dictionary.Add(slot.name, slot);
|
||||
|
||||
/// <summary> 武器插槽 </summary>
|
||||
public EquipmentSlot WeaponSlot() {
|
||||
return new EquipmentSlot(EquipmentSlotType.主手, VerifyWeapon);
|
||||
}
|
||||
/// <summary> 副手插槽 </summary>
|
||||
public EquipmentSlot DeputySlot() {
|
||||
return new EquipmentSlot(EquipmentSlotType.副手, VerifyDeputy);
|
||||
}
|
||||
/// <summary> 护甲插槽 </summary>
|
||||
public EquipmentSlot ArmorSlot(EquipmentSlotType type, ArmorType armor) {
|
||||
return new EquipmentSlot(type, (equipment) => VerifyCommon(equipment, armor.ToString()));
|
||||
}
|
||||
/// <summary> 饰品插槽 </summary>
|
||||
public EquipmentSlot AccessorySlot(EquipmentSlotType type, AccessoryType accessory) {
|
||||
return new EquipmentSlot(type, (equipment) => VerifyCommon(equipment, accessory.ToString()));
|
||||
}
|
||||
// /// <summary> 武器插槽 </summary>
|
||||
// public EquipmentSlot WeaponSlot() {
|
||||
// return new EquipmentSlot(EquipmentSlotType.主手, VerifyWeapon);
|
||||
// }
|
||||
// /// <summary> 副手插槽 </summary>
|
||||
// public EquipmentSlot DeputySlot() {
|
||||
// return new EquipmentSlot(EquipmentSlotType.副手, VerifyDeputy);
|
||||
// }
|
||||
// /// <summary> 护甲插槽 </summary>
|
||||
// public EquipmentSlot ArmorSlot(EquipmentSlotType type, ArmorType armor) {
|
||||
// return new EquipmentSlot(type, (equipment) => VerifyCommon(equipment, armor.ToString()));
|
||||
// }
|
||||
// /// <summary> 饰品插槽 </summary>
|
||||
// public EquipmentSlot AccessorySlot(EquipmentSlotType type, AccessoryType accessory) {
|
||||
// return new EquipmentSlot(type, (equipment) => VerifyCommon(equipment, accessory.ToString()));
|
||||
// }
|
||||
|
||||
/// <summary> 通用校验 </summary>
|
||||
public static bool VerifyCommon(Equipment equipment, string type) {
|
||||
string[] types = equipment.type.Split("/");
|
||||
if (types[0] == type) { return true; }
|
||||
return false;
|
||||
}
|
||||
// public static bool VerifyCommon(Equipment equipment, string type) {
|
||||
// string[] types = equipment.type.Split("/");
|
||||
// if (types[0] == type) { return true; }
|
||||
// return false;
|
||||
// }
|
||||
/// <summary> 主手校验 </summary>
|
||||
public static bool VerifyWeapon(Equipment equipment) {
|
||||
string[] type = equipment.type.Split("/");
|
||||
if (type[0] == WeaponType.单手.ToString()) { return true; }
|
||||
if (type[0] == WeaponType.双手.ToString()) { return true; }
|
||||
return false;
|
||||
}
|
||||
// public static bool VerifyWeapon(Equipment equipment) {
|
||||
// string[] type = equipment.type.Split("/");
|
||||
// if (type[0] == WeaponType.单手.ToString()) { return true; }
|
||||
// if (type[0] == WeaponType.双手.ToString()) { return true; }
|
||||
// return false;
|
||||
// }
|
||||
/// <summary> 副手校验 </summary>
|
||||
public static bool VerifyDeputy(Equipment equipment) {
|
||||
string[] type = equipment.type.Split("/");
|
||||
if (type[0] == WeaponType.副手.ToString()) { return true; }
|
||||
return false;
|
||||
}
|
||||
// public static bool VerifyDeputy(Equipment equipment) {
|
||||
// string[] type = equipment.type.Split("/");
|
||||
// if (type[0] == WeaponType.副手.ToString()) { return true; }
|
||||
// return false;
|
||||
// }
|
||||
}
|
||||
@@ -10,11 +10,11 @@ public class AccessoryConst : EquipmentConst {
|
||||
/// <summary> 饰品类型 </summary>
|
||||
public AccessoryType type;
|
||||
|
||||
public override InventoryItem To() {
|
||||
Equipment item = new Equipment();
|
||||
item.name = name;
|
||||
item.sprite = sprite;
|
||||
item.type = type.ToString();
|
||||
return item;
|
||||
}
|
||||
// public override InventoryItem To() {
|
||||
// Equipment item = new Equipment();
|
||||
// item.name = name;
|
||||
// item.sprite = sprite;
|
||||
// item.type = type.ToString();
|
||||
// return item;
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -11,11 +11,11 @@ public class ArmorConst : EquipmentConst {
|
||||
/// <summary> 护甲类型 </summary>
|
||||
public ArmorType type;
|
||||
|
||||
public override InventoryItem To() {
|
||||
Equipment item = new Equipment();
|
||||
item.name = name;
|
||||
item.sprite = sprite;
|
||||
item.type = type.ToString();
|
||||
return item;
|
||||
}
|
||||
// public override InventoryItem To() {
|
||||
// Equipment item = new Equipment();
|
||||
// item.name = name;
|
||||
// item.sprite = sprite;
|
||||
// item.type = type.ToString();
|
||||
// return item;
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -12,11 +12,11 @@ public class WeaponConst : EquipmentConst {
|
||||
/// <summary> 武器类型 </summary>
|
||||
public WeaponCategory category;
|
||||
|
||||
public override InventoryItem To() {
|
||||
Equipment item = new Equipment();
|
||||
item.name = name;
|
||||
item.sprite = sprite;
|
||||
item.type = $"{type}/{category}";
|
||||
return item;
|
||||
}
|
||||
// public override InventoryItem To() {
|
||||
// Equipment item = new Equipment();
|
||||
// item.name = name;
|
||||
// item.sprite = sprite;
|
||||
// item.type = $"{type}/{category}";
|
||||
// return item;
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 装备插槽
|
||||
/// </summary>
|
||||
public class EquipmentSlot {
|
||||
/// <summary> 名字 </summary>
|
||||
public string name;
|
||||
/// <summary> 物品 </summary>
|
||||
public Equipment item;
|
||||
/// <summary> 装备验证 </summary>
|
||||
public Func<Equipment, bool> verify;
|
||||
|
||||
public EquipmentSlot(EquipmentSlotType slot, Func<Equipment, bool> verify) {
|
||||
name = slot.ToString();
|
||||
this.verify = verify;
|
||||
}
|
||||
|
||||
/// <summary> 设置 </summary>
|
||||
public void Settings(InventoryItem item) {
|
||||
if (item is Equipment equipment) { this.item = equipment; }
|
||||
else { this.item = null; }
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@
|
||||
font-size: 14px;
|
||||
-unity-font-style: bold;
|
||||
-unity-font: url("project://database/Assets/UI%20Toolkit/FontLibrary/Fonts/SourceHanSansCN-Medium.otf?fileID=12800000&guid=3ceb88ff2ced01a439c5b2d1b63c86a5&type=3#SourceHanSansCN-Medium");
|
||||
-unity-font-definition: url("project://database/Assets/UI%20Toolkit/FontLibrary/Fonts/SourceHanSansCN-Medium%20SDF.asset?fileID=11400000&guid=0239ab36009b94e479c9c67877764f1e&type=2#SourceHanSansCN-Medium SDF");
|
||||
-unity-font-definition: url('project://database/Assets/UI%20Toolkit/FontLibrary/Fonts/SourceHanSansCN-Medium%20SDF.asset?fileID=11400000&guid=0239ab36009b94e479c9c67877764f1e&type=2#SourceHanSansCN-Medium SDF');
|
||||
}
|
||||
|
||||
.ep-separate-label {
|
||||
@@ -24,6 +24,7 @@
|
||||
padding-left: 2px;
|
||||
font-size: 12px;
|
||||
-unity-font: url("project://database/Assets/UI%20Toolkit/FontLibrary/Fonts/SourceHanSansCN-Medium.otf?fileID=12800000&guid=3ceb88ff2ced01a439c5b2d1b63c86a5&type=3#SourceHanSansCN-Medium");
|
||||
-unity-font-definition: url("project://database/Assets/UI%20Toolkit/FontLibrary/Fonts/SourceHanSansCN-Medium%20SDF.asset?fileID=11400000&guid=0239ab36009b94e479c9c67877764f1e&type=2#SourceHanSansCN-Medium SDF");
|
||||
-unity-font-definition: url('project://database/Assets/UI%20Toolkit/FontLibrary/Fonts/SourceHanSansCN-Medium%20SDF.asset?fileID=11400000&guid=0239ab36009b94e479c9c67877764f1e&type=2#SourceHanSansCN-Medium SDF');
|
||||
-unity-font-style: normal;
|
||||
-unity-background-image-tint-color: rgb(255, 255, 255);
|
||||
}
|
||||
|
||||
@@ -2,9 +2,11 @@
|
||||
<ui:Template name="EquipmentSeparate" src="project://database/Assets/ModuleCore/ModuleEquipment/UI%20Toolkit/EquipmentPanel/EquipmentSeparate.uxml?fileID=9197481963319205126&guid=9560b815ca2481d48bb0dd7f66557436&type=3#EquipmentSeparate" />
|
||||
<Style src="project://database/Assets/ModuleCore/ModuleEquipment/UI%20Toolkit/EquipmentPanel/EquipmentPanel.uss?fileID=7433441132597879392&guid=8659d41deeaac2e4c83d9287f11f74bd&type=3#EquipmentPanel" />
|
||||
<ui:Label tabindex="-1" text="符文主宰者" parse-escape-sequences="true" display-tooltip-when-elided="true" name="Name" style="margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; font-size: 20px; -unity-font-style: bold;" />
|
||||
<ui:Label tabindex="-1" text="Lv77 神话级 单手 斧头" parse-escape-sequences="true" display-tooltip-when-elided="true" name="Type" class="ep-label" />
|
||||
<ui:Label tabindex="-1" text="Lv77 神话级 单手武器 斧头" parse-escape-sequences="true" display-tooltip-when-elided="true" name="Type" class="ep-label" />
|
||||
<ui:Label tabindex="-1" text="Lv66 稀有级 皮甲 上衣" parse-escape-sequences="true" display-tooltip-when-elided="true" name="Type" class="ep-label" />
|
||||
<ui:Label tabindex="-1" text="Lv99 传奇级 首饰 项链" parse-escape-sequences="true" display-tooltip-when-elided="true" name="Type" class="ep-label" />
|
||||
<ui:Instance template="EquipmentSeparate" name="EquipmentSeparate" />
|
||||
<ui:Label tabindex="-1" text="基础攻击力 2-99" parse-escape-sequences="true" display-tooltip-when-elided="true" class="ep-label" />
|
||||
<ui:Label tabindex="-1" text="攻击力 2-99" parse-escape-sequences="true" display-tooltip-when-elided="true" class="ep-label" />
|
||||
<ui:Label tabindex="-1" text="攻击速度 -10%" parse-escape-sequences="true" display-tooltip-when-elided="true" class="ep-label" />
|
||||
<ui:VisualElement name="EquipmentSeparate">
|
||||
<ui:VisualElement style="flex-direction: row; align-items: center;">
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ccf9ef6e831628349a83b354e196e98d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,20 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 材料 - 物品常量
|
||||
/// </summary>
|
||||
[CreateAssetMenu(menuName = "MuHua/物品系统/材料")]
|
||||
public class ConstMaterial : InventoryItemConst {
|
||||
/// <summary> 最大堆叠数 </summary>
|
||||
public int maxStack = 99;
|
||||
|
||||
public override InventoryItem To() {
|
||||
DataMaterial item = new DataMaterial();
|
||||
item.name = name;
|
||||
item.sprite = sprite;
|
||||
item.maxStack = maxStack;
|
||||
return item;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5592cd11563474d42a1f6805b66f7a1f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,13 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 材料 - 物品
|
||||
/// </summary>
|
||||
public class DataMaterial : InventoryItem {
|
||||
/// <summary> 最大堆叠数 </summary>
|
||||
public int maxStack;
|
||||
|
||||
public override int MaxStack => maxStack;
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fc5511946a6586b42a9a026b078f6736
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -9,8 +9,6 @@ using MuHua;
|
||||
/// </summary>
|
||||
public class InputMenu : InputControl {
|
||||
|
||||
private UIMenuPanel menu;
|
||||
|
||||
protected override void ModuleInput_OnInputMode(InputMode mode) {
|
||||
// throw new System.NotImplementedException();
|
||||
}
|
||||
@@ -19,11 +17,11 @@ public class InputMenu : InputControl {
|
||||
/// <summary> 鼠标左键 </summary>
|
||||
public void OnMouseLeft(InputValue inputValue) {
|
||||
if (inputValue.isPressed) return;
|
||||
UIPopupManager.I.shortcutMenu.Close();
|
||||
ShortcutMenu.I.Close();
|
||||
}
|
||||
/// <summary> 鼠标右键 </summary>
|
||||
public void OnMouseRight(InputValue inputValue) {
|
||||
UIPopupManager.I.shortcutMenu.Open();
|
||||
ShortcutMenu.I.Open();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d3a7044b333aacb4286fef636118cfec
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,16 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 物品
|
||||
/// </summary>
|
||||
public class InventoryItem {
|
||||
/// <summary> 名字 </summary>
|
||||
public string name;
|
||||
/// <summary> 图片 </summary>
|
||||
public Sprite sprite;
|
||||
|
||||
/// <summary> 堆叠数量 </summary>
|
||||
public virtual int MaxStack => 1;
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 库存插槽
|
||||
/// </summary>
|
||||
public class InventorySlot {
|
||||
/// <summary> 数量 </summary>
|
||||
public int count;
|
||||
/// <summary> 物品 </summary>
|
||||
public InventoryItem item;
|
||||
|
||||
// /// <summary> 图片 </summary>
|
||||
public Sprite Sprite => item != null ? item.sprite : null;
|
||||
// /// <summary> 堆叠数量 </summary>
|
||||
public int MaxStack => item != null ? item.MaxStack : 0;
|
||||
|
||||
public InventorySlot() { }
|
||||
|
||||
public InventorySlot(InventoryItem item, int count) {
|
||||
this.item = item;
|
||||
this.count = count;
|
||||
}
|
||||
/// <summary> 设置 </summary>
|
||||
public void Settings(InventoryItem item, int count) {
|
||||
this.item = item;
|
||||
this.count = count;
|
||||
}
|
||||
/// <summary> 是否相同 </summary>
|
||||
public bool Same(InventoryItem obj) {
|
||||
return item != null && item.name == obj.name && count < MaxStack;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 253123fa56cb88f4e969b587327d3f7f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,5 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c87e8c5e71a81ec459fc58f79c0ab960
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 06f31db1c09e8a0409a8b3b960a13216
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,48 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using MuHua;
|
||||
|
||||
/// <summary>
|
||||
/// SliderInputH - Panel
|
||||
/// </summary>
|
||||
public class UISliderInputH : ModuleUIPanel {
|
||||
|
||||
public float value;
|
||||
public Vector2 range = new Vector2(1, 1);
|
||||
public UISliderH slider;
|
||||
public event Action<float> ValueChanged;
|
||||
|
||||
public VisualElement Slider => Q<VisualElement>("Slider");
|
||||
public UIFloatField FloatField => Q<UIFloatField>("UIFloatField");
|
||||
|
||||
public UISliderInputH(VisualElement element, VisualElement canvas) : base(element) {
|
||||
slider = new UISliderH(element, canvas);
|
||||
|
||||
slider.ValueChanged += Slider_ValueChanged;
|
||||
FloatField.RegisterCallback<ChangeEvent<float>>(FloatField_ValueChanged);
|
||||
}
|
||||
private void Slider_ValueChanged(float obj) {
|
||||
value = Mathf.Lerp(range.x, range.y, obj);
|
||||
FloatField.SetValueWithoutNotify(value);
|
||||
ValueChanged?.Invoke(value);
|
||||
}
|
||||
private void FloatField_ValueChanged(ChangeEvent<float> obj) {
|
||||
value = Mathf.Clamp(obj.newValue, range.x, range.y);
|
||||
float scale = Mathf.InverseLerp(range.x, range.y, value);
|
||||
slider.UpdateValue(scale, false);
|
||||
ValueChanged?.Invoke(value);
|
||||
}
|
||||
public void Update() {
|
||||
slider.Update();
|
||||
}
|
||||
/// <summary> 更新值 </summary>
|
||||
public void UpdateValue(float value) {
|
||||
this.value = Mathf.Clamp(range.x, range.y, value);
|
||||
float scale = Mathf.InverseLerp(range.x, range.y, value);
|
||||
slider.UpdateValue(scale, false);
|
||||
FloatField.SetValueWithoutNotify(value);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d5f8ad3cc3aff1940bdf68f3d911a263
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,64 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using MuHua;
|
||||
|
||||
/// <summary>
|
||||
/// Vector2 - Panel
|
||||
/// </summary>
|
||||
public class UIVector2 : ModuleUIPanel {
|
||||
|
||||
public bool isLock;
|
||||
public Vector2 value;
|
||||
public UISliderInputH sliderX;
|
||||
public UISliderInputH sliderY;
|
||||
public event Action<Vector2, bool> ValueChanged;
|
||||
|
||||
public Button Lock => Q<Button>("Lock");
|
||||
public VisualElement SliderX => Q<VisualElement>("SliderInputX");
|
||||
public VisualElement SliderY => Q<VisualElement>("SliderInputY");
|
||||
|
||||
public UIVector2(VisualElement element, VisualElement canvas) : base(element) {
|
||||
sliderX = new UISliderInputH(SliderX, canvas);
|
||||
sliderY = new UISliderInputH(SliderY, canvas);
|
||||
|
||||
Lock.clicked += Lock_clicked;
|
||||
sliderX.ValueChanged += SliderX_ValueChanged;
|
||||
sliderY.ValueChanged += SliderY_ValueChanged;
|
||||
}
|
||||
private void Lock_clicked() {
|
||||
isLock = !isLock;
|
||||
Lock.EnableInClassList("dashboard-button-s", isLock);
|
||||
if (isLock) { value.y = value.x; sliderY.UpdateValue(value.x); }
|
||||
ValueChanged?.Invoke(value, isLock);
|
||||
}
|
||||
private void SliderX_ValueChanged(float obj) {
|
||||
value.x = obj;
|
||||
if (isLock) { value.y = obj; sliderY.UpdateValue(obj); }
|
||||
ValueChanged?.Invoke(value, isLock);
|
||||
}
|
||||
private void SliderY_ValueChanged(float obj) {
|
||||
value.y = obj;
|
||||
if (isLock) { value.x = obj; sliderX.UpdateValue(obj); }
|
||||
ValueChanged?.Invoke(value, isLock);
|
||||
}
|
||||
public void Update() {
|
||||
sliderX.Update();
|
||||
sliderY.Update();
|
||||
}
|
||||
/// <summary> 更新值 </summary>
|
||||
public void UpdateValue(Vector2 value, bool isLock) {
|
||||
this.value = value;
|
||||
this.isLock = isLock;
|
||||
sliderX.UpdateValue(value.x);
|
||||
sliderY.UpdateValue(value.y);
|
||||
Lock.EnableInClassList("dashboard-button-s", isLock);
|
||||
}
|
||||
/// <summary> 设置范围 </summary>
|
||||
public void Settings(Vector2 range) {
|
||||
sliderX.range = range;
|
||||
sliderY.range = range;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c0898288ac15d9a4e9a82e0d6d36ff17
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,63 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using MuHua;
|
||||
|
||||
/// <summary>
|
||||
/// Vector3 - Panel
|
||||
/// </summary>
|
||||
public class UIVector3 : ModuleUIPanel {
|
||||
|
||||
public Vector3 value;
|
||||
public UISliderInputH sliderX;
|
||||
public UISliderInputH sliderY;
|
||||
public UISliderInputH sliderZ;
|
||||
public event Action<Vector3> ValueChanged;
|
||||
|
||||
public VisualElement SliderInputX => Q<VisualElement>("SliderInputX");
|
||||
public VisualElement SliderInputY => Q<VisualElement>("SliderInputY");
|
||||
public VisualElement SliderInputZ => Q<VisualElement>("SliderInputZ");
|
||||
|
||||
public UIVector3(VisualElement element, VisualElement canvas) : base(element) {
|
||||
sliderX = new UISliderInputH(SliderInputX, canvas);
|
||||
sliderY = new UISliderInputH(SliderInputY, canvas);
|
||||
sliderZ = new UISliderInputH(SliderInputZ, canvas);
|
||||
|
||||
sliderX.ValueChanged += SliderX_ValueChanged;
|
||||
sliderY.ValueChanged += SliderY_ValueChanged;
|
||||
sliderZ.ValueChanged += SliderZ_ValueChanged;
|
||||
}
|
||||
|
||||
private void SliderX_ValueChanged(float obj) {
|
||||
value.x = obj;
|
||||
ValueChanged?.Invoke(value);
|
||||
}
|
||||
private void SliderY_ValueChanged(float obj) {
|
||||
value.y = obj;
|
||||
ValueChanged?.Invoke(value);
|
||||
}
|
||||
private void SliderZ_ValueChanged(float obj) {
|
||||
value.z = obj;
|
||||
ValueChanged?.Invoke(value);
|
||||
}
|
||||
public void Update() {
|
||||
sliderX.Update();
|
||||
sliderY.Update();
|
||||
sliderZ.Update();
|
||||
}
|
||||
/// <summary> 更新值 </summary>
|
||||
public void UpdateValue(Vector3 value) {
|
||||
this.value = value;
|
||||
sliderX.UpdateValue(value.x);
|
||||
sliderY.UpdateValue(value.y);
|
||||
sliderZ.UpdateValue(value.z);
|
||||
}
|
||||
/// <summary> 设置范围 </summary>
|
||||
public void Settings(Vector2 range) {
|
||||
sliderX.range = range;
|
||||
sliderY.range = range;
|
||||
sliderZ.range = range;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 36d613e41a27e8f40be6e6c05de1aeb1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,113 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using UnityEngine.Video;
|
||||
using MuHua;
|
||||
|
||||
/// <summary>
|
||||
/// 视频播放控件
|
||||
/// </summary>
|
||||
public class UIVideoPlayPanel : ModuleUIPanel {
|
||||
private float showTime;
|
||||
private bool isDownSlider;
|
||||
private Action fullAction;
|
||||
private RenderTexture renderTexture;
|
||||
private VideoPlayer videoPlayer;
|
||||
private UISliderH slider;
|
||||
|
||||
private VisualElement VideoView => element.Q<VisualElement>("VideoView");
|
||||
private VisualElement VideoController => element.Q<VisualElement>("VideoController");
|
||||
private VisualElement Slider => element.Q<VisualElement>("Slider");
|
||||
private Label Time => element.Q<Label>("Time");
|
||||
private Button Play => element.Q<Button>("Play");
|
||||
private Button Pause => element.Q<Button>("Pause");
|
||||
private Button FullScreen => element.Q<Button>("FullScreen");
|
||||
|
||||
public UIVideoPlayPanel(VisualElement element, VisualElement canvas, VideoPlayer videoPlayer, Action fullAction = null) : base(element) {
|
||||
this.videoPlayer = videoPlayer;
|
||||
this.fullAction = fullAction;
|
||||
|
||||
int width = (int)element.parent.resolvedStyle.width;
|
||||
int height = (int)element.parent.resolvedStyle.height;
|
||||
renderTexture = new RenderTexture(width, height, 0);
|
||||
Background background = Background.FromRenderTexture(renderTexture);
|
||||
VideoView.style.backgroundImage = new StyleBackground(background);
|
||||
|
||||
Play.clicked += Play_clicked;
|
||||
Pause.clicked += Pause_clicked;
|
||||
FullScreen.clicked += FullScreen_clicked;
|
||||
|
||||
VideoView.RegisterCallback<PointerDownEvent>((evt) => showTime = 5);
|
||||
VideoController.RegisterCallback<PointerDownEvent>((evt) => showTime = 5);
|
||||
|
||||
Slider.RegisterCallback<PointerDownEvent>((evt) => isDownSlider = true);
|
||||
Slider.RegisterCallback<PointerUpEvent>((evt) => isDownSlider = false);
|
||||
Slider.RegisterCallback<PointerLeaveEvent>((evt) => isDownSlider = false);
|
||||
|
||||
slider = new UISliderH(element, canvas);
|
||||
slider.ValueChanged += Slider_SlidingValueChanged;
|
||||
}
|
||||
|
||||
/// <summary> 启用 </summary>
|
||||
public void Enable(string url) {
|
||||
videoPlayer.url = url; Enable();
|
||||
}
|
||||
/// <summary> 启用 </summary>
|
||||
public void Enable() {
|
||||
UpdateRenderTexture();
|
||||
videoPlayer.targetTexture = renderTexture;
|
||||
if (videoPlayer.isPlaying) { Play_clicked(); }
|
||||
else { Pause_clicked(); }
|
||||
}
|
||||
|
||||
/// <summary> 更新 </summary>
|
||||
public void Update() {
|
||||
if (videoPlayer == null) { return; }
|
||||
showTime -= UnityEngine.Time.deltaTime;
|
||||
Visibility visibility = showTime > 0 ? Visibility.Visible : Visibility.Hidden;
|
||||
VideoController.style.visibility = visibility;
|
||||
//进度条
|
||||
float value = (float)videoPlayer.frame / (float)videoPlayer.frameCount;
|
||||
if (!isDownSlider) { slider.UpdateValue(value, false); }
|
||||
//播放时间
|
||||
string clockTime = TimeSpan.FromSeconds(videoPlayer.clockTime).ToString(@"mm\:ss");
|
||||
string length = TimeSpan.FromSeconds(videoPlayer.length).ToString(@"mm\:ss");
|
||||
Time.text = clockTime + "/" + length;
|
||||
}
|
||||
/// <summary> 播放 </summary>
|
||||
public void Play_clicked() {
|
||||
if (videoPlayer == null) { return; }
|
||||
videoPlayer.Play(); showTime = 5;
|
||||
Play.style.display = DisplayStyle.None;
|
||||
Pause.style.display = DisplayStyle.Flex;
|
||||
}
|
||||
/// <summary> 暂停 </summary>
|
||||
public void Pause_clicked() {
|
||||
if (videoPlayer == null) { return; }
|
||||
videoPlayer.Pause();
|
||||
Play.style.display = DisplayStyle.Flex;
|
||||
Pause.style.display = DisplayStyle.None;
|
||||
}
|
||||
|
||||
/// <summary> 更新渲染纹理 </summary>
|
||||
private void UpdateRenderTexture() {
|
||||
int width = (int)element.parent.resolvedStyle.width;
|
||||
int height = (int)element.parent.resolvedStyle.height;
|
||||
if (renderTexture.width == width && renderTexture.height == height) { return; }
|
||||
renderTexture.Release();
|
||||
renderTexture = new RenderTexture(width, height, 0);
|
||||
Background background = Background.FromRenderTexture(renderTexture);
|
||||
VideoView.style.backgroundImage = new StyleBackground(background);
|
||||
}
|
||||
/// <summary> 全屏 </summary>
|
||||
private void FullScreen_clicked() {
|
||||
fullAction?.Invoke();
|
||||
}
|
||||
/// <summary> 进度条更新 </summary>
|
||||
private void Slider_SlidingValueChanged(float obj) {
|
||||
if (videoPlayer == null) { return; }
|
||||
videoPlayer.frame = (long)obj;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 00c04ca4ef821d0469a77408648f5ff2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1a20e449063139b4ea0d19bd0677c7d1
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5003b2a36519747449a4b6e4d7e5f56e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,25 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using MuHua;
|
||||
|
||||
/// <summary>
|
||||
/// 消息页面1
|
||||
/// </summary>
|
||||
public class UIMessage1 : ModuleUIPanel {
|
||||
|
||||
public Label Content => Q<Label>("Content");
|
||||
|
||||
public UIMessage1(VisualElement element) : base(element) { }
|
||||
|
||||
/// <summary>
|
||||
/// 设置消息内容
|
||||
/// </summary>
|
||||
/// <param name="active"></param>
|
||||
/// <param name="value"></param>
|
||||
public void Settings(bool active, string value = "") {
|
||||
element.EnableInClassList("document-page-hide", !active);
|
||||
Content.text = value;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c0d9cdd61f07fb14a93de29e68c71787
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,31 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using MuHua;
|
||||
|
||||
/// <summary>
|
||||
/// 消息页面2
|
||||
/// </summary>
|
||||
public class UIMessage2 : ModuleUIPanel {
|
||||
|
||||
private Action callback;
|
||||
|
||||
public Label Content => Q<Label>("Content");
|
||||
public Button Button => Q<Button>("Button");
|
||||
|
||||
public UIMessage2(VisualElement element) : base(element) {
|
||||
Button.clicked += () => { callback?.Invoke(); Settings(false); };
|
||||
}
|
||||
|
||||
public void Settings(bool active) {
|
||||
element.EnableInClassList("document-page-hide", !active);
|
||||
callback = null;
|
||||
}
|
||||
public void Settings(bool active, string value = "", Action callback = null) {
|
||||
element.EnableInClassList("document-page-hide", !active);
|
||||
Content.text = value;
|
||||
this.callback = callback;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d21953f5fb6c41e40b2df711d80a42b3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,31 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using MuHua;
|
||||
|
||||
/// <summary>
|
||||
/// 消息页面3
|
||||
/// </summary>
|
||||
public class UIMessage3 : ModuleUIPanel {
|
||||
|
||||
private Action callback1;
|
||||
private Action callback2;
|
||||
|
||||
public Label Content => Q<Label>("Content");
|
||||
public Button Button1 => Q<Button>("Button1");
|
||||
public Button Button2 => Q<Button>("Button2");
|
||||
|
||||
public UIMessage3(VisualElement element) : base(element) {
|
||||
Button1.clicked += () => { callback1?.Invoke(); Settings(false); };
|
||||
Button2.clicked += () => { callback2?.Invoke(); Settings(false); };
|
||||
}
|
||||
|
||||
public void Settings(bool active, string value = "", Action callback1 = null, Action callback2 = null) {
|
||||
element.EnableInClassList("document-page-hide", !active);
|
||||
Content.text = value;
|
||||
this.callback1 = callback1;
|
||||
this.callback2 = callback2;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 496a1fe1e90187b45b931ec732c0bde6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,18 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class UIBannerTip : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7279e9c7234eb6645b7b1e172b70919d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,132 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using MuHua;
|
||||
|
||||
/// <summary>
|
||||
/// 指针提示
|
||||
/// </summary>
|
||||
public class UIGuidance : ModuleUIPanel {
|
||||
|
||||
private bool isDown;
|
||||
private Action callback;
|
||||
private Action<bool> ValueChanged;
|
||||
private Vector2 offset;
|
||||
private Vector3 originalPosition;
|
||||
private Vector3 pointerPosition;
|
||||
private VisualElement target;
|
||||
private UIToggle toggle;
|
||||
|
||||
public Label Prompt => Q<Label>("Prompt");
|
||||
public VisualElement Toggle => Q<VisualElement>("Toggle");
|
||||
public VisualElement Button => Q<VisualElement>("Button");
|
||||
public VisualElement Pointer => Q<VisualElement>("Pointer");
|
||||
|
||||
public UIGuidance(VisualElement element) : base(element) {
|
||||
toggle = new UIToggle(Toggle);
|
||||
toggle.ValueChanged += (value) => { ValueChanged?.Invoke(value); };
|
||||
|
||||
Button.RegisterCallback<ClickEvent>(ClickEvent);
|
||||
|
||||
element.RegisterCallback<MouseDownEvent>(MouseDownEvent);
|
||||
element.RegisterCallback<MouseUpEvent>(MouseUpEvent);
|
||||
}
|
||||
|
||||
public void Update() {
|
||||
#if UNITY_EDITOR
|
||||
if (target == null) { return; }
|
||||
if (isDown) {
|
||||
Vector3 mousePosition = UITool.GetMousePosition();
|
||||
Vector3 differ = new Vector3(mousePosition.x, Screen.height - mousePosition.y) - pointerPosition;
|
||||
|
||||
Pointer.transform.position = originalPosition + differ;
|
||||
}
|
||||
else {
|
||||
Pointer.transform.position = target.worldBound.position + offset;
|
||||
}
|
||||
#else
|
||||
if (target == null) { return; }
|
||||
Pointer.transform.position = target.worldBound.position + offset;
|
||||
#endif
|
||||
}
|
||||
|
||||
private void ClickEvent(ClickEvent evt) {
|
||||
element.EnableInClassList("document-page-hide", true);
|
||||
callback?.Invoke();
|
||||
}
|
||||
private void MouseDownEvent(MouseDownEvent evt) {
|
||||
#if UNITY_EDITOR
|
||||
isDown = true;
|
||||
originalPosition = Pointer.transform.position;
|
||||
Vector3 mousePosition = UITool.GetMousePosition();
|
||||
pointerPosition = new Vector3(mousePosition.x, Screen.height - mousePosition.y);
|
||||
#endif
|
||||
}
|
||||
private void MouseUpEvent(MouseUpEvent evt) {
|
||||
isDown = false;
|
||||
float x = Pointer.transform.position.x - target.worldBound.position.x;
|
||||
float y = Pointer.transform.position.y - target.worldBound.position.y;
|
||||
Vector3 offset = new Vector3(x, y);
|
||||
Debug.Log(offset);
|
||||
}
|
||||
|
||||
/// <summary> 打开提示 </summary>
|
||||
public void Settings(string content, VisualElement target, Vector2 offset, Action callback) {
|
||||
this.target = target;
|
||||
this.offset = offset;
|
||||
this.callback = callback;
|
||||
Prompt.text = content;
|
||||
element.EnableInClassList("document-page-hide", false);
|
||||
}
|
||||
/// <summary> 设置提示 </summary>
|
||||
public void Settings(bool value, Action<bool> ValueChanged) {
|
||||
this.ValueChanged = ValueChanged;
|
||||
toggle.UpdateValue(value, false);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 图案页指引
|
||||
/// </summary>
|
||||
public class UIPatternPageGuidance : ModuleUIPanel {
|
||||
|
||||
private bool isNot;
|
||||
|
||||
public VisualElement Top => Q<VisualElement>("Top");
|
||||
public Button Button1 => Top.Q<Button>("Button1");// 创建图案
|
||||
public Button Button4 => Top.Q<Button>("Button4");// 创建元素
|
||||
|
||||
public VisualElement Dashboard => Q<VisualElement>("Dashboard");
|
||||
public VisualElement PatternLibrary => Q<VisualElement>("PatternLibrary");
|
||||
public VisualElement TemplateLibrary => Q<VisualElement>("TemplateLibrary");
|
||||
|
||||
public UIPatternPageGuidance(VisualElement element) : base(element) { }
|
||||
|
||||
public void Guidance1() {
|
||||
if (isNot) { return; }
|
||||
string content = "第一步 点击【创建图案】按钮,即可新建一个空白画板,开始您的设计。";
|
||||
Guidance(content, Button1, new Vector2(140, -55), Guidance2);
|
||||
}
|
||||
public void Guidance2() {
|
||||
string content = "第二步 提供两种创作方式 \n1,选用模板:点击【图案模板】,选择模板后参考其结构与配色,进行纹样重构与创新设计。";
|
||||
Guidance(content, TemplateLibrary, new Vector2(310, 0), Guidance3);
|
||||
}
|
||||
public void Guidance3() {
|
||||
string content = "2,全新创作:点击【创建元素】创建空白图案框,自行选择【图案元素库】内的图案素材进行创新设计。";
|
||||
Guidance(content, Button4, new Vector2(-530, -65), Guidance4);
|
||||
}
|
||||
public void Guidance4() {
|
||||
string content = "导入个人素材:点击【自定义】-【导入素材】,导入后请点击【自定义】刷新以更新显示。";
|
||||
Guidance(content, PatternLibrary, new Vector2(310, 0), Guidance5);
|
||||
}
|
||||
public void Guidance5() {
|
||||
string content = "图案编辑功能:选中图案元素,可调整其颜色、位置、大小、镜像、连续排列等操作。\n画布设置:如设计透明背景的图案,可根据图案色彩风格自定义画板颜色,便于更直观地进行设计。";
|
||||
Guidance(content, Dashboard, new Vector2(-530, 0), null);
|
||||
}
|
||||
public void Guidance(string content, VisualElement visual, Vector3 offset, Action action) {
|
||||
// UIGuidance guidance = ModuleUI.I.popupManager.guidance;
|
||||
// guidance.Settings(content, visual, offset, action);
|
||||
// guidance.Settings(isNot, (value) => { isNot = value; });
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8df138b434ab51f40b134f831376120e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,31 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using MuHua;
|
||||
|
||||
/// <summary>
|
||||
/// 加载页面
|
||||
/// </summary>
|
||||
public class UILoading : ModuleUIPanel {
|
||||
|
||||
public UISliderH slider;
|
||||
|
||||
public VisualElement Slider => Q<VisualElement>("Slider");
|
||||
|
||||
public UILoading(VisualElement element, VisualElement canvas) : base(element) {
|
||||
slider = new UISliderH(Slider, canvas);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置加载进度
|
||||
/// </summary>
|
||||
/// <param name="active"></param>
|
||||
/// <param name="value1"></param>
|
||||
/// <param name="value2"></param>
|
||||
public void Settings(bool active, float value1, string value2) {
|
||||
element.EnableInClassList("document-page-hide", !active);
|
||||
slider.UpdateValue(value1);
|
||||
slider.Title.text = value2;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 637e7bc032a4bee4aa936fb481495299
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,170 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using MuHua;
|
||||
|
||||
/// <summary>
|
||||
/// UI快捷菜单
|
||||
/// </summary>
|
||||
public class UIShortcutMenu : ModuleUIPanel, UIControl {
|
||||
/// <summary> 菜单模板 </summary>
|
||||
public VisualTreeAsset menuTreeAsset;
|
||||
/// <summary> 项目模板 </summary>
|
||||
public VisualTreeAsset itemTreeAsset;
|
||||
|
||||
/// <summary> 数据列表 </summary>
|
||||
public List<DataMenuItem> datas = new List<DataMenuItem>();
|
||||
/// <summary> 控件列表 </summary>
|
||||
public static List<UIControl> controls = new List<UIControl>();
|
||||
|
||||
public UIShortcutMenu(VisualElement element, VisualTreeAsset menuTreeAsset, VisualTreeAsset itemTreeAsset) : base(element) {
|
||||
this.menuTreeAsset = menuTreeAsset;
|
||||
this.itemTreeAsset = itemTreeAsset;
|
||||
ModuleUI.AddControl(this);
|
||||
}
|
||||
|
||||
public void Update() => controls.ForEach(control => control.Update());
|
||||
|
||||
public void Dispose() => controls.ForEach(control => control.Dispose());
|
||||
|
||||
/// <summary> 打开菜单 </summary>
|
||||
public void Open() {
|
||||
Close();
|
||||
Vector3 position = UITool.GetMousePosition(element);
|
||||
UIMenuPanel menuPanel = Create();
|
||||
menuPanel.Settings(position, datas);
|
||||
}
|
||||
/// <summary> 关闭菜单 </summary>
|
||||
public void Close() {
|
||||
controls.ForEach(control => control.Dispose());
|
||||
controls.Clear();
|
||||
element.Clear();
|
||||
}
|
||||
/// <summary> 创建子菜单 </summary>
|
||||
public UIMenuPanel Create() {
|
||||
// 创建菜单元素
|
||||
VisualElement menu = menuTreeAsset.Instantiate();
|
||||
menu.EnableInClassList("menu", true);
|
||||
element.Add(menu);
|
||||
UIMenuPanel menuPanel = new UIMenuPanel(menu, itemTreeAsset, this);
|
||||
controls.Add(menuPanel);
|
||||
return menuPanel;
|
||||
}
|
||||
|
||||
/// <summary> 添加菜单项(方法) </summary>
|
||||
public void Add(string name, Action callback) {
|
||||
string[] names = name.Split('/');
|
||||
|
||||
List<DataMenuItem> datas = this.datas;
|
||||
for (int i = 0; i < names.Length; i++) {
|
||||
DataMenuItem item = Find(names[i], datas);
|
||||
datas = item.items;
|
||||
if (i == names.Length - 1) { item.callback = callback; }
|
||||
}
|
||||
}
|
||||
/// <summary> 移除菜单项 </summary>
|
||||
public void Remove(string name) {
|
||||
string[] names = name.Split('/');
|
||||
List<DataMenuItem> datas = this.datas;
|
||||
|
||||
for (int i = 0; i < names.Length; i++) {
|
||||
DataMenuItem item = Find(names[i], datas, false);
|
||||
// 未找到,直接返回
|
||||
if (item == null) { return; }
|
||||
// 找到要移除的项
|
||||
if (i == names.Length - 1) { datas.Remove(item); }
|
||||
datas = item.items;
|
||||
}
|
||||
}
|
||||
/// <summary> 查询菜单项 </summary>
|
||||
public DataMenuItem Find(string name, List<DataMenuItem> datas, bool isCreate = true) {
|
||||
DataMenuItem item = datas.Find(obj => obj.name == name);
|
||||
if (item != null || !isCreate) { return item; }
|
||||
item = new DataMenuItem { name = name };
|
||||
datas.Add(item);
|
||||
return item;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// UI快捷菜单面板
|
||||
/// </summary>
|
||||
public class UIMenuPanel : ModuleUIPanel, UIControl {
|
||||
public readonly UIShortcutMenu parent;
|
||||
public UIMenuPanel menuPanel;
|
||||
public VisualElement submenu;
|
||||
public ModuleUIItems<UIItem, DataMenuItem> items;
|
||||
|
||||
public VisualElement Container => Q<VisualElement>("Container");
|
||||
|
||||
public UIMenuPanel(VisualElement element, VisualTreeAsset templateAsset, UIShortcutMenu parent) : base(element) {
|
||||
this.parent = parent;
|
||||
items = new ModuleUIItems<UIItem, DataMenuItem>(Container, templateAsset,
|
||||
(data, element) => new UIItem(data, element, this, parent));
|
||||
}
|
||||
|
||||
public void Update() { }
|
||||
|
||||
public void Dispose() => items.Release();
|
||||
|
||||
public void Settings(Vector3 position, List<DataMenuItem> datas) {
|
||||
items.Create(datas);
|
||||
element.transform.position = position;
|
||||
}
|
||||
|
||||
/// <summary> 打开子菜单 </summary>
|
||||
public void Open(VisualElement submenu, List<DataMenuItem> datas) {
|
||||
if (this.submenu == submenu) { return; }
|
||||
// 更新子菜单
|
||||
this.submenu = submenu;
|
||||
if (menuPanel == null) { menuPanel = parent.Create(); }
|
||||
float x = submenu.worldBound.position.x + submenu.resolvedStyle.width;
|
||||
float y = submenu.worldBound.position.y - 5;
|
||||
Vector3 position = new Vector3(x, y, 0);
|
||||
menuPanel.Settings(position, datas);
|
||||
bool isEnable = datas != null && datas.Count > 0;
|
||||
menuPanel.OpenSubmenu(isEnable);
|
||||
}
|
||||
public void OpenSubmenu(bool open) {
|
||||
element.EnableInClassList("menu-hide", !open);
|
||||
menuPanel?.OpenSubmenu(false);
|
||||
}
|
||||
|
||||
/// <summary> UI项目 </summary>
|
||||
public class UIItem : ModuleUIItem<DataMenuItem> {
|
||||
public readonly UIMenuPanel parent;
|
||||
public readonly UIShortcutMenu shortcutMenu;
|
||||
|
||||
public Label Name => element.Q<Label>("Name");
|
||||
public VisualElement Arrow => element.Q<VisualElement>("Arrow");
|
||||
|
||||
public UIItem(DataMenuItem value, VisualElement element, UIMenuPanel parent, UIShortcutMenu shortcutMenu) : base(value, element) {
|
||||
this.parent = parent;
|
||||
this.shortcutMenu = shortcutMenu;
|
||||
|
||||
Name.text = value.name;
|
||||
Arrow.EnableInClassList("menu-arrow-hide", value.items == null || value.items.Count == 0);
|
||||
element.RegisterCallback<MouseDownEvent>(MouseDownEvent);
|
||||
element.RegisterCallback<MouseMoveEvent>(MouseMoveEvent);
|
||||
}
|
||||
private void MouseDownEvent(MouseDownEvent evt) {
|
||||
value.callback?.Invoke();
|
||||
shortcutMenu.Close();
|
||||
}
|
||||
private void MouseMoveEvent(MouseMoveEvent evt) {
|
||||
parent.Open(element, value.items);
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 菜单项目
|
||||
/// </summary>
|
||||
public class DataMenuItem {
|
||||
/// <summary> 名称 </summary>
|
||||
public string name;
|
||||
/// <summary> 回调 </summary>
|
||||
public Action callback;
|
||||
/// <summary> 子菜单项 </summary>
|
||||
public List<DataMenuItem> items = new List<DataMenuItem>();
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using MuHua;
|
||||
|
||||
/// <summary>
|
||||
/// UI加载管理器
|
||||
/// </summary>
|
||||
public class UILoadManager : ModuleUIPage {
|
||||
|
||||
// public UIProgres progres;
|
||||
|
||||
public override VisualElement Element => root.Q<VisualElement>("Popup");
|
||||
|
||||
public VisualElement PopupDialog => Q<VisualElement>("PopupDialog");
|
||||
|
||||
private void Awake() {
|
||||
// progres = new UIProgres(PopupDialog);
|
||||
}
|
||||
private void OnDestroy() {
|
||||
// config.Release();
|
||||
// configMaterial.Release();
|
||||
// equipmentSelection.Release();
|
||||
// paramrInput.Release();
|
||||
}
|
||||
private void Update() {
|
||||
// config.Update();
|
||||
// configMaterial.Update();
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2da9aad7a772f434080f14bd479de19c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c3fd76fa2f8dd174cbb580a5890fd90d
|
||||
guid: d73f0702f68e73243ab4c6940caafa59
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 51b8c6d3c0b5b3d459dca741e39b455e
|
||||
guid: 6477bb920cf3e3a4fbaf3e01082e3ae3
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using MuHua;
|
||||
|
||||
/// <summary>
|
||||
/// 快捷菜单
|
||||
/// </summary>
|
||||
public class ShortcutMenu : Module<ShortcutMenu> {
|
||||
/// <summary> 数据列表 </summary>
|
||||
public List<ShortcutMenuItem> menuItems = new List<ShortcutMenuItem>();
|
||||
|
||||
/// <summary> 打开菜单 </summary>
|
||||
public void Open() => UIShortcutMenu.I?.Open(menuItems);
|
||||
|
||||
/// <summary> 关闭菜单 </summary>
|
||||
public void Close() => UIShortcutMenu.I?.Close();
|
||||
|
||||
/// <summary> 添加菜单项(1级菜单/2级菜单/3级菜单) </summary>
|
||||
public void Add(string name, Action callback) {
|
||||
string[] names = name.Split('/');
|
||||
ShortcutMenuItem item = Find(names[0], menuItems, true);
|
||||
for (int i = 1; i < names.Length; i++) {
|
||||
item = Find(names[i], item.menuItems, true);
|
||||
}
|
||||
item.callback = callback;
|
||||
}
|
||||
/// <summary> 移除菜单项(???/???/子级菜单) </summary>
|
||||
public void Remove(string name) {
|
||||
string[] names = name.Split('/');
|
||||
List<ShortcutMenuItem> menuItems = this.menuItems;
|
||||
ShortcutMenuItem item = Find(names[0], menuItems, false);
|
||||
for (int i = 1; i < names.Length; i++) {
|
||||
if (item == null) return;
|
||||
menuItems = item.menuItems;
|
||||
item = Find(names[i], menuItems, false);
|
||||
}
|
||||
menuItems.Remove(item);
|
||||
}
|
||||
|
||||
/// <summary> 子项目查找 </summary>
|
||||
private ShortcutMenuItem Find(string menu, List<ShortcutMenuItem> menuItems, bool isCreate) {
|
||||
ShortcutMenuItem item = menuItems.Find(obj => obj.name == menu);
|
||||
if (item != null || !isCreate) { return item; }
|
||||
item = new ShortcutMenuItem { name = menu };
|
||||
menuItems.Add(item);
|
||||
return item;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 23403840a9d12654f8f15c6188728498
|
||||
guid: 23732e20aab811a4eba63cc0f810d659
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 菜单项目
|
||||
/// </summary>
|
||||
public class ShortcutMenuItem {
|
||||
/// <summary> 名称 </summary>
|
||||
public string name;
|
||||
/// <summary> 回调 </summary>
|
||||
public Action callback;
|
||||
/// <summary> 子菜单项 </summary>
|
||||
public List<ShortcutMenuItem> menuItems = new List<ShortcutMenuItem>();
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 82adca68fa56cb14382ebd547a8bf044
|
||||
guid: fac2916b09800194a8389027d4b54ce8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -0,0 +1,75 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using MuHua;
|
||||
|
||||
/// <summary>
|
||||
/// UI快捷菜单面板
|
||||
/// </summary>
|
||||
public class UIMenuPanel : ModuleUIPanel, UIControl {
|
||||
|
||||
public UIMenuPanel menuPanel;
|
||||
public VisualElement submenu;
|
||||
public ModuleUIItems<UIItem, ShortcutMenuItem> items;
|
||||
|
||||
public VisualElement Container => Q<VisualElement>("Container");
|
||||
|
||||
public UIMenuPanel(VisualElement element, VisualTreeAsset templateAsset) : base(element) {
|
||||
items = new ModuleUIItems<UIItem, ShortcutMenuItem>(Container, templateAsset,
|
||||
(data, element) => new UIItem(data, element, this));
|
||||
}
|
||||
public void Update() {
|
||||
// throw new NotImplementedException();
|
||||
}
|
||||
public void Dispose() {
|
||||
items.Release();
|
||||
}
|
||||
|
||||
public void Settings(Vector3 position, List<ShortcutMenuItem> datas) {
|
||||
items.Create(datas);
|
||||
element.transform.position = position;
|
||||
}
|
||||
|
||||
/// <summary> 打开子菜单 </summary>
|
||||
public void Open(VisualElement submenu, List<ShortcutMenuItem> datas) {
|
||||
if (this.submenu == submenu) { return; }
|
||||
// 更新子菜单
|
||||
this.submenu = submenu;
|
||||
if (menuPanel == null) { menuPanel = UIShortcutMenu.I.Create(); }
|
||||
float x = submenu.worldBound.position.x + submenu.resolvedStyle.width;
|
||||
float y = submenu.worldBound.position.y - 4;
|
||||
Vector3 position = new Vector3(x, y, 0);
|
||||
menuPanel.Settings(position, datas);
|
||||
bool isEnable = datas != null && datas.Count > 0;
|
||||
menuPanel.OpenSubmenu(isEnable);
|
||||
}
|
||||
public void OpenSubmenu(bool open) {
|
||||
element.EnableInClassList("menu-hide", !open);
|
||||
menuPanel?.OpenSubmenu(false);
|
||||
}
|
||||
|
||||
/// <summary> UI项目 </summary>
|
||||
public class UIItem : ModuleUIItem<ShortcutMenuItem> {
|
||||
public readonly UIMenuPanel parent;
|
||||
|
||||
public Label Name => element.Q<Label>("Name");
|
||||
public VisualElement Arrow => element.Q<VisualElement>("Arrow");
|
||||
|
||||
public UIItem(ShortcutMenuItem value, VisualElement element, UIMenuPanel parent) : base(value, element) {
|
||||
this.parent = parent;
|
||||
Name.text = value.name;
|
||||
Arrow.EnableInClassList("menu-arrow-hide", value.menuItems == null || value.menuItems.Count == 0);
|
||||
element.RegisterCallback<MouseDownEvent>(MouseDownEvent);
|
||||
element.RegisterCallback<MouseMoveEvent>(MouseMoveEvent);
|
||||
}
|
||||
private void MouseDownEvent(MouseDownEvent evt) {
|
||||
value.callback?.Invoke();
|
||||
UIShortcutMenu.I.Close();
|
||||
}
|
||||
private void MouseMoveEvent(MouseMoveEvent evt) {
|
||||
parent.Open(element, value.menuItems);
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4aeb4c96a0ef14c4f9cb2b8afdfc091c
|
||||
guid: cbfff4523d382a14eb835f39d022b39d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using MuHua;
|
||||
|
||||
/// <summary>
|
||||
/// UI快捷菜单
|
||||
/// </summary>
|
||||
public class UIShortcutMenu : ModuleUISingle<UIShortcutMenu> {
|
||||
/// <summary> 菜单模板 </summary>
|
||||
public VisualTreeAsset MenuPanel;
|
||||
/// <summary> 项目模板 </summary>
|
||||
public VisualTreeAsset MenuTemplate;
|
||||
|
||||
/// <summary> 控件列表 </summary>
|
||||
public static List<UIControl> controls = new List<UIControl>();
|
||||
|
||||
public override VisualElement Element => root.Q<VisualElement>("ShortcutMenu");
|
||||
|
||||
protected override void Awake() => NoReplace(false);
|
||||
|
||||
private void Update() => controls.ForEach(control => control.Update());
|
||||
|
||||
private void OnDestroy() => controls.ForEach(control => control.Dispose());
|
||||
|
||||
/// <summary> 打开菜单 </summary>
|
||||
public void Open(List<ShortcutMenuItem> datas) {
|
||||
Close();
|
||||
Vector3 position = UITool.GetMousePosition(Element);
|
||||
UIMenuPanel menuPanel = Create();
|
||||
menuPanel.Settings(position, datas);
|
||||
}
|
||||
/// <summary> 关闭菜单 </summary>
|
||||
public void Close() {
|
||||
controls.ForEach(control => control.Dispose());
|
||||
controls.Clear();
|
||||
Element.Clear();
|
||||
}
|
||||
/// <summary> 创建子菜单 </summary>
|
||||
public UIMenuPanel Create() {
|
||||
// 创建菜单元素
|
||||
VisualElement element = MenuPanel.Instantiate();
|
||||
element.EnableInClassList("menu", true);
|
||||
Element.Add(element);
|
||||
UIMenuPanel menuPanel = new UIMenuPanel(element, MenuTemplate);
|
||||
controls.Add(menuPanel);
|
||||
return menuPanel;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 535afb79004b58e43a958d46e4f3eb20
|
||||
guid: 32fa60a7591d8e149b02b5fac56adfb4
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6a2d6badedf74af4a8e4faffb6130a48
|
||||
guid: f405743ede2617b4c92bf64862e7402e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
+6
-11
@@ -1,14 +1,9 @@
|
||||
.menu {
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.menu-hide {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.menu-unit {
|
||||
flex-direction: row;
|
||||
align-self: flex-start;
|
||||
flex-grow: 0;
|
||||
width: 100%;
|
||||
height: 25px;
|
||||
}
|
||||
|
||||
.menu-unit:hover {
|
||||
@@ -21,10 +16,10 @@
|
||||
|
||||
.menu-arrow {
|
||||
flex-grow: 0;
|
||||
height: 30px;
|
||||
width: 30px;
|
||||
height: 25px;
|
||||
width: 25px;
|
||||
background-image: url("project://database/Assets/UI%20Toolkit/UnityThemes/UnityDefaultRuntimeTheme.tss?fileID=-1087164816274819069&guid=05f864e67ee1ecb4bbe67427564d394c&type=3#arrow-right@2x");
|
||||
-unity-background-image-tint-color: rgb(51, 51, 51);
|
||||
-unity-background-image-tint-color: rgb(51, 50, 50);
|
||||
}
|
||||
|
||||
.menu-arrow-hide {
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6f6de86e3bf3ec348a2cfde1e36e77bd
|
||||
guid: 4b1be5340ef21d843bdd2f0eb2375cfe
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
@@ -0,0 +1,11 @@
|
||||
<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="Item" src="project://database/Assets/ModuleCore/ModuleUISMenu/UI%20Toolkit/MenuPanel/MenuTemplate.uxml?fileID=9197481963319205126&guid=1ee167986f6e9a840a45450b4b6adfc2&type=3#MenuTemplate" />
|
||||
<Style src="project://database/Assets/ModuleCore/ModuleUISMenu/UI%20Toolkit/MenuPanel/MenuPanel.uss?fileID=7433441132597879392&guid=4b1be5340ef21d843bdd2f0eb2375cfe&type=3#MenuPanel" />
|
||||
<ui:VisualElement name="Container" style="background-color: rgb(255, 255, 255); border-top-left-radius: 5px; border-top-right-radius: 5px; border-bottom-right-radius: 5px; border-bottom-left-radius: 5px; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; align-self: flex-start; min-width: 150px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-left-color: rgb(51, 51, 51); border-right-color: rgb(51, 51, 51); border-top-color: rgb(51, 51, 51); border-bottom-color: rgb(51, 51, 51);">
|
||||
<ui:Instance template="Item" name="Item" />
|
||||
<ui:Instance template="Item" name="Item" />
|
||||
<ui:Instance template="Item" name="Item" />
|
||||
<ui:Instance template="Item" name="Item" />
|
||||
<ui:Instance template="Item" name="Item" />
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
+4
-2
@@ -1,7 +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/UI%20Toolkit/GamePopup/ShortcutMenu/ShortcutMenu.uss?fileID=7433441132597879392&guid=a53da9fc389948e40ac96af14dd02c10&type=3#ShortcutMenu" />
|
||||
<Style src="project://database/Assets/ModuleCore/ModuleUISMenu/UI%20Toolkit/MenuPanel/MenuPanel.uss?fileID=7433441132597879392&guid=4b1be5340ef21d843bdd2f0eb2375cfe&type=3#MenuPanel" />
|
||||
<ui:VisualElement class="menu-unit">
|
||||
<ui:Label tabindex="-1" text="Label" parse-escape-sequences="true" display-tooltip-when-elided="true" name="Name" style="-unity-text-align: middle-center; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px; height: 30px;" />
|
||||
<ui:VisualElement style="width: 30px;" />
|
||||
<ui:Label tabindex="-1" text="Label" parse-escape-sequences="true" display-tooltip-when-elided="true" name="Name" style="-unity-text-align: middle-center; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px;" />
|
||||
<ui:VisualElement style="flex-grow: 1;" />
|
||||
<ui:VisualElement name="Arrow" class="menu-arrow" />
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
@@ -0,0 +1,7 @@
|
||||
.menu {
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.menu-hide {
|
||||
display: none;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user