This commit is contained in:
MuHua-123
2025-02-28 18:28:03 +08:00
parent 5bc834bfcd
commit fb849c9c25
75 changed files with 859 additions and 7 deletions
-3
View File
@@ -1,3 +0,0 @@
.unity-text-element {
-unity-font-definition: url("project://database/Assets/FontLibrary/UIToolkit/SourceHanSansCN-Medium%20SDF.asset?fileID=11400000&guid=500f473f880266d43aaf04a728879085&type=2#SourceHanSansCN-Medium SDF");
}
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 6d1bcd63c2c24d540bc4736439c8dc7d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 96a17be56bd1a684388f693fae44f7c9
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,9 @@
@import url("unity-theme://default");
@import url("/Assets/MuHua/UITool/FontLibrary/Fonts.uss");
@import url("/Assets/MuHua/UITool/UIScroller/ScrollerHorizontal.uss");
VisualElement {}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 59bfacbee7a859f42904b05799bf9437
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 12388, guid: 0000000000000000e000000000000000, type: 0}
disableValidation: 0
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: a5bdaff13d0987148992bf7cc1af29a2
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,3 @@
.unity-text-element {
-unity-font-definition: url("project://database/Assets/MuHua/UITool/FontLibrary/SourceHanSansCN-Medium%20SDF.asset?fileID=11400000&guid=500f473f880266d43aaf04a728879085&type=2#SourceHanSansCN-Medium SDF");
}
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e7cdf28a5161c094ea27a8b5ad54d741
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,95 @@
.window {
position: absolute;
top: auto;
left: auto;
width: 400px;
height: 300px;
background-color: rgba(0, 0, 0, 0);
border-radius: 10px;
padding: 20px;
display: flex;
flex-direction: column;
opacity: 1;
padding-top: 0;
padding-right: 0;
padding-bottom: 0;
padding-left: 0;
border-top-left-radius: 0;
border-top-right-radius: 0;
border-bottom-right-radius: 0;
border-bottom-left-radius: 0;
}
.window-top {
justify-content: space-between;
background-color: rgb(44, 62, 80);
border-top-left-radius: 10px;
border-top-right-radius: 10px;
padding-left: 10px;
height: 50px;
flex-direction: row;
flex-shrink: 1;
flex-grow: 0;
align-items: center;
}
.window-title {
font-size: 24px;
color: rgb(236, 240, 241);
margin-bottom: 0;
margin-top: 0;
margin-right: 0;
margin-left: 0;
padding-top: 0;
padding-right: 0;
padding-bottom: 0;
padding-left: 0;
-unity-text-align: middle-left;
}
.window-close-button {
background-color: rgb(231, 76, 60);
color: rgb(236, 240, 241);
border-radius: 5px;
margin-top: 10px;
margin-right: 10px;
margin-bottom: 10px;
margin-left: 10px;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
border-bottom-left-radius: 5px;
border-top-width: 2px;
border-right-width: 2px;
border-bottom-width: 2px;
border-left-width: 2px;
border-left-color: rgba(0, 0, 0, 0);
border-right-color: rgba(0, 0, 0, 0);
border-top-color: rgba(0, 0, 0, 0);
border-bottom-color: rgba(0, 0, 0, 0);
height: 30px;
}
.window-close-button:hover {
background-color: rgb(192, 57, 43);
border-top-width: 2px;
border-right-width: 2px;
border-bottom-width: 2px;
border-left-width: 2px;
border-left-color: rgb(0, 157, 255);
border-right-color: rgb(0, 157, 255);
border-top-color: rgb(0, 157, 255);
border-bottom-color: rgb(0, 157, 255);
}
.window-container {
border-bottom-right-radius: 10px;
border-bottom-left-radius: 10px;
background-color: rgb(242, 242, 242);
overflow: hidden;
}
.window-hidden {
display: none;
opacity: 0;
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 71fd1505cc1aa1e4297e4f4534cc0124
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 12385, guid: 0000000000000000e000000000000000, type: 0}
disableValidation: 0
@@ -0,0 +1,10 @@
<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/MuHua/UITool/USS/FloatingWindow.uss?fileID=7433441132597879392&amp;guid=71fd1505cc1aa1e4297e4f4534cc0124&amp;type=3#FloatingWindow" />
<ui:VisualElement name="Window" class="window window-hidden" style="width: 510px; height: auto;">
<ui:VisualElement name="Top" class="window-top">
<ui:Label text="窗口" name="Title" class="window-title" />
<ui:Button name="Close" text="X" class="window-close-button" />
</ui:VisualElement>
<ui:VisualElement name="Container" class="window-container" />
</ui:VisualElement>
</ui:UXML>
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: f58c5527cf4cda147b239b37b0afcb85
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: bebc51f45f54a904a8e07157976da6bb
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d8db2d69206657346a4fe9aebc592327
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 12385, guid: 0000000000000000e000000000000000, type: 0}
disableValidation: 0
@@ -0,0 +1,4 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
<Style src="project://database/Assets/MuHua/UITool/USS/ScrollView.uss?fileID=7433441132597879392&amp;guid=d8db2d69206657346a4fe9aebc592327&amp;type=3#ScrollView" />
<MuHua.MUScrollViewVertical />
</ui:UXML>
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: e95fad6397f22504eb724a8ea0c8d926
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b0a55937e12435144b4b7c36d1fd6e95
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 12385, guid: 0000000000000000e000000000000000, type: 0}
disableValidation: 0
@@ -0,0 +1,3 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
<Style src="project://database/Assets/MuHua/UITool/UIScrollView/ScrollViewHorizontal.uss?fileID=7433441132597879392&amp;guid=b0a55937e12435144b4b7c36d1fd6e95&amp;type=3#ScrollViewHorizontal" />
</ui:UXML>
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: ac460a2d93de869499c04a4295795595
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: fd72798a2f7a89b4b96b9d8249af66ad
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 12385, guid: 0000000000000000e000000000000000, type: 0}
disableValidation: 0
@@ -0,0 +1,3 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
<Style src="project://database/Assets/MuHua/UITool/UIScrollView/ScrollViewVertical.uss?fileID=7433441132597879392&amp;guid=fd72798a2f7a89b4b96b9d8249af66ad&amp;type=3#ScrollViewVertical" />
</ui:UXML>
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: a75122cc6293a3d4f9ba44b98f4bed9e
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: bd2ae276ee0cc884cbe88f423b8f35fd
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,11 @@
.scroller-horizontal {
width: 100%;
height: 30px;
background-color: rgb(255, 255, 255);
}
.scroller-horizontal-dragger {
background-color: rgb(255, 126, 126);
width: 30px;
height: 100%;
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: fa60433f4fc03c34e8b51e6a8c9b32db
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 12385, guid: 0000000000000000e000000000000000, type: 0}
disableValidation: 0
@@ -0,0 +1,6 @@
<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/MuHua/UITool/UIScroller/ScrollerHorizontal.uss?fileID=7433441132597879392&amp;guid=fa60433f4fc03c34e8b51e6a8c9b32db&amp;type=3#ScrollerHorizontal" />
<ui:VisualElement name="ScrollerHorizontal" class="scroller-horizontal">
<ui:VisualElement name="Dragger" class="scroller-horizontal-dragger" />
</ui:VisualElement>
</ui:UXML>
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 14902068774d28f4daf1887a57533a75
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
@@ -0,0 +1,11 @@
.vertical-scroller {
width: 30px;
height: 100%;
background-color: rgb(255, 255, 255);
}
.vertical-scroller-dragger {
background-color: rgb(255, 126, 126);
width: 100%;
height: 30px;
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a7fd7497066a90d4cad4bb96a3d9cf68
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 12385, guid: 0000000000000000e000000000000000, type: 0}
disableValidation: 0
@@ -0,0 +1,8 @@
<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/MuHua/UITool/USS/Scroller.uss?fileID=7433441132597879392&amp;guid=a7fd7497066a90d4cad4bb96a3d9cf68&amp;type=3#Scroller" />
<MuHua.MUScrollerHorizontal />
<MuHua.MUScrollerVertical />
<ui:VisualElement name="ScrollerVertical" style="flex-grow: 1;">
<ui:VisualElement name="Dragger" style="flex-grow: 1;" />
</ui:VisualElement>
</ui:UXML>
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: f1b09f67b8d868f48ae3011621da6b73
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
+66
View File
@@ -122,6 +122,67 @@ NavMeshSettings:
debug: debug:
m_Flags: 0 m_Flags: 0
m_NavMeshData: {fileID: 0} m_NavMeshData: {fileID: 0}
--- !u!1 &36355707
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 36355710}
- component: {fileID: 36355709}
- component: {fileID: 36355708}
m_Layer: 5
m_Name: UIDocument
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &36355708
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 36355707}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 48270532e0731284a92ff8556d892c7e, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &36355709
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 36355707}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 19102, guid: 0000000000000000e000000000000000, type: 0}
m_Name:
m_EditorClassIdentifier:
m_PanelSettings: {fileID: 11400000, guid: 4caef6f0e9981084a9e0cbfd447fac06, type: 2}
m_ParentUI: {fileID: 0}
sourceAsset: {fileID: 9197481963319205126, guid: 337d91fd31b0b764f97868cdacc90f66, type: 3}
m_SortingOrder: 0
--- !u!4 &36355710
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 36355707}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &218982090 --- !u!1 &218982090
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@@ -863,6 +924,10 @@ PrefabInstance:
propertyPath: m_Name propertyPath: m_Name
value: StandardLabel value: StandardLabel
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 1923445833930100383, guid: 9df2d2c64a5c06245be7e81572bcfe4e, type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: [] m_RemovedComponents: []
m_RemovedGameObjects: [] m_RemovedGameObjects: []
m_AddedGameObjects: [] m_AddedGameObjects: []
@@ -877,3 +942,4 @@ SceneRoots:
- {fileID: 495038690} - {fileID: 495038690}
- {fileID: 851831250} - {fileID: 851831250}
- {fileID: 8592585726815668701} - {fileID: 8592585726815668701}
- {fileID: 36355710}
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 255179b9440614542b26d46561680a31
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+20
View File
@@ -0,0 +1,20 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UIElements;
using MuHua;
public class TestUI : MonoBehaviour
{
/// <summary> 绑定文档 </summary>
public UIDocument document;
/// <summary> 根目录文档 </summary>
public VisualElement root => document.rootVisualElement;
private UIScrollerHorizontal scroller;
private void Awake()
{
VisualElement Scroller = root.Q<VisualElement>();
scroller = new UIScrollerHorizontal(Scroller, root);
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 48270532e0731284a92ff8556d892c7e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+5
View File
@@ -0,0 +1,5 @@
<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:VisualElement name="ScrollerHorizontal" class="scroller-horizontal" style="width: 300px; position: absolute; left: 50px; top: 50px;">
<ui:VisualElement name="Dragger" class="scroller-horizontal-dragger" />
</ui:VisualElement>
</ui:UXML>
+10
View File
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 337d91fd31b0b764f97868cdacc90f66
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
+1 -1
View File
@@ -12,7 +12,7 @@ MonoBehaviour:
m_Script: {fileID: 19101, guid: 0000000000000000e000000000000000, type: 0} m_Script: {fileID: 19101, guid: 0000000000000000e000000000000000, type: 0}
m_Name: PanelSettings m_Name: PanelSettings
m_EditorClassIdentifier: m_EditorClassIdentifier:
themeUss: {fileID: -4733365628477956816, guid: a1f3f61784a9b574bb5b683d542e7d39, type: 3} themeUss: {fileID: -4733365628477956816, guid: 59bfacbee7a859f42904b05799bf9437, type: 3}
m_TargetTexture: {fileID: 0} m_TargetTexture: {fileID: 0}
m_ScaleMode: 2 m_ScaleMode: 2
m_ReferenceSpritePixelsPerUnit: 100 m_ReferenceSpritePixelsPerUnit: 100
@@ -1,4 +1,4 @@
@import url("/Packages/com.muhua.uicontrol/Assets/Themes/DefaultRuntimeTheme.tss"); @import url("/Packages/com.muhua.uicontrol/Assets/Themes/DefaultRuntimeTheme.tss");
@import url("/Assets/FontLibrary/UIToolkit/Fonts.uss");
+1 -1
View File
@@ -5,7 +5,7 @@
"description": "FiniteStateMachine\u6709\u9650\u72b6\u6001\u673a\u6846\u67b6", "description": "FiniteStateMachine\u6709\u9650\u72b6\u6001\u673a\u6846\u67b6",
"author": { "author": {
"name": "MuHua", "name": "MuHua",
"email": "2960208585@qq.com" "email": "muhua233@qq.com"
}, },
"type": "tool", "type": "tool",
"samples": [ "samples": [
+1 -1
View File
@@ -5,7 +5,7 @@
"description": "\u6d6e\u52a8\u6807\u7b7e\u7cfb\u7edf", "description": "\u6d6e\u52a8\u6807\u7b7e\u7cfb\u7edf",
"author": { "author": {
"name": "MuHua", "name": "MuHua",
"email": "2960208585@qq.com" "email": "muhua233@qq.com"
}, },
"type": "tool", "type": "tool",
"samples": [ "samples": [
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 687421b262e8f94438ea3821bca49d6b
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,3 @@
{
"name": "MuHua.UITool"
}
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 6206345d516a2bb4a821a7ee90e1b5d5
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 5c114499ba33d59478f35ca583231e02
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+26
View File
@@ -0,0 +1,26 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
#if ENABLE_INPUT_SYSTEM && UNITY_INPUT_SYSTEM_PACKAGE
using UnityEngine.InputSystem;
#endif
namespace MuHua
{
/// <summary>
/// UI工具
/// </summary>
public static class UITool
{
/// <summary> 获取鼠标位置 </summary>
public static Vector3 GetMousePosition()
{
#if ENABLE_INPUT_SYSTEM && UNITY_INPUT_SYSTEM_PACKAGE
return Mouse.current.position.ReadValue();
#else
return Input.mousePosition;
#endif
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ac8f1de11a0d473409df019e3d014d21
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,77 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UIElements;
#if ENABLE_INPUT_SYSTEM && UNITY_INPUT_SYSTEM_PACKAGE
using UnityEngine.InputSystem;
#endif
namespace MuHua
{
/// <summary>
/// 悬浮窗口
/// </summary>
public abstract class UIFloatingWindow
{
/// <summary> 绑定的元素 </summary>
public readonly VisualElement element;
/// <summary> 绑定的画布 </summary>
public readonly VisualElement canvas;
private bool isDownMove;
private Vector3 pointerPosition;
private Vector3 originalPosition;
public VisualElement Window => element.Q<VisualElement>("Window");
public VisualElement Top => element.Q<VisualElement>("Top");
public VisualElement Container => element.Q<VisualElement>("Container");
public Label Title => element.Q<Label>("Title");
public Button Close => element.Q<Button>("Close");
public UIFloatingWindow(VisualElement element, VisualElement canvas)
{
this.element = element;
this.canvas = canvas;
Top.RegisterCallback<PointerDownEvent>(TopDown);
canvas.RegisterCallback<PointerUpEvent>((evt) => isDownMove = false);
canvas.RegisterCallback<PointerLeaveEvent>((evt) => isDownMove = false);
Close.clicked += () => { SetActive(false); };
}
/// <summary> 按下Top </summary>
private void TopDown(PointerDownEvent evt)
{
isDownMove = true;
pointerPosition = UITool.GetMousePosition();
originalPosition = Window.transform.position;
}
/// <summary> 设置活动状态 </summary>
public virtual void SetActive(bool active)
{
Window.EnableInClassList("window-hidden", !active);
}
/// <summary> 更新状态 </summary>
public virtual void Update()
{
if (!isDownMove) { return; }
Vector3 mousePosition = UITool.GetMousePosition();
Vector3 offset = mousePosition - pointerPosition;
Vector3 position = originalPosition + new Vector3(offset.x, -offset.y);
float width = canvas.resolvedStyle.width - Window.resolvedStyle.width;
float height = canvas.resolvedStyle.height - Window.resolvedStyle.height;
position.x = Mathf.Clamp(position.x, 0, width);
position.y = Mathf.Clamp(position.y, 0, height);
Window.transform.position = position;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8db6302b07dcf8649b966f15c6fad581
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 347543776b7c9134c8f51ee8930b55ea
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,14 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace MuHua
{
/// <summary>
/// 滚动视图
/// </summary>
public class UIScrollView
{
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9fa4135858d72ac4e8a90212625ec7db
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,15 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace MuHua
{
/// <summary>
/// 滚动视图(水平)
/// </summary>
public class UIScrollViewHorizontal
{
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: cce3cdf2fe4ebe14e8afcf78f68c9469
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,14 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace MuHua
{
/// <summary>
/// 滚动视图(垂直)
/// </summary>
public class UIScrollViewVertical
{
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d15576153e2ca2d40b07796a726007bf
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: be53e2c2d10706340aa8ed31656a6473
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,76 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UIElements;
namespace MuHua
{
/// <summary>
/// 滑块(水平)
/// </summary>
public class UIScrollerHorizontal
{
/// <summary> 绑定的元素 </summary>
public readonly VisualElement element;
/// <summary> 绑定的画布 </summary>
public readonly VisualElement canvas;
/// <summary> 值改变时 </summary>
public event Action<float> ValueChanged;
public float value;
public bool isDragger;
public float originalPosition;
public float pointerPosition;
public VisualElement dragger => element.Q<VisualElement>("Dragger");
public UIScrollerHorizontal(VisualElement element, VisualElement canvas)
{
this.element = element;
this.canvas = canvas;
//设置事件
dragger.RegisterCallback<PointerDownEvent>(DraggerDown);
element.RegisterCallback<PointerDownEvent>(ElementDown);
canvas.RegisterCallback<PointerUpEvent>((evt) => isDragger = false);
canvas.RegisterCallback<PointerLeaveEvent>((evt) => isDragger = false);
}
public void DraggerDown(PointerDownEvent evt)
{
isDragger = true;
originalPosition = dragger.transform.position.x;
pointerPosition = UITool.GetMousePosition().x;
}
public void ElementDown(PointerDownEvent evt)
{
float offset = evt.localPosition.x - dragger.resolvedStyle.width * 0.5f;
float max = element.resolvedStyle.width - dragger.resolvedStyle.width;
float value = Mathf.InverseLerp(0, max, offset);
UpdateValue(value);
}
/// <summary> 更新状态 </summary>
public virtual void Update()
{
if (!isDragger) { return; }
float differ = UITool.GetMousePosition().x - pointerPosition;
float offset = differ + originalPosition;
float max = element.resolvedStyle.width - dragger.resolvedStyle.width;
float value = Mathf.InverseLerp(0, max, offset);
UpdateValue(value);
}
/// <summary> 更新值(0-1) </summary>
public void UpdateValue(float value)
{
this.value = value;
ValueChanged?.Invoke(value);
float max = element.resolvedStyle.width - dragger.resolvedStyle.width;
float x = Mathf.Lerp(0, max, value);
dragger.transform.position = new Vector3(x, 0);
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b0bf333809175ae4ebc4469feab46cc7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,14 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace MuHua
{
/// <summary>
/// 滑块(垂直)
/// </summary>
public class UIScrollerVertical
{
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d1f12d534a6e94f4d93a1a91f85e0519
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 6dd1dbe68787bc14f9eb6804be3484f5
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+11
View File
@@ -0,0 +1,11 @@
{
"name": "muhua-ui-tool",
"version": "1.0.0",
"displayName": "MuHua UITool",
"description": "\u57fa\u4e8eUI Toolkit\u7684\u6269\u5c55\u5de5\u5177\u5305",
"author": {
"name": "MuHua",
"email": "muhua233@qq.com"
},
"type": "tool"
}
+7
View File
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: e89edc7869c0e2643ac846f99ac5928c
PackageManifestImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+6
View File
@@ -227,6 +227,12 @@
"source": "embedded", "source": "embedded",
"dependencies": {} "dependencies": {}
}, },
"muhua-ui-tool": {
"version": "file:UITool",
"depth": 0,
"source": "embedded",
"dependencies": {}
},
"com.unity.modules.ai": { "com.unity.modules.ai": {
"version": "1.0.0", "version": "1.0.0",
"depth": 0, "depth": 0,