From 5374616980194ff5eea750959691236493b9844e Mon Sep 17 00:00:00 2001 From: MuHua-123 <136542559+MuHua-123@users.noreply.github.com> Date: Tue, 17 Jun 2025 10:53:45 +0800 Subject: [PATCH] 1 --- .../AssetsPackage/Cleaner/AssetCollector.cs | 195 ---------- .../Cleaner/AssetReferenceCollection.cs | 58 --- .../Cleaner/ClassReferenceCollection.cs | 356 ------------------ .../AssetsPackage/Cleaner/CollectionData.cs | 42 --- .../Cleaner/FindUnusedAssetsWindow.cs | 214 ----------- .../Cleaner/ShaderReferenceCollection.cs | 95 ----- .../{Cleaner.meta => HexagonMapSystem.meta} | 2 +- .../HexagonMapSystem/Hexagon.fbx | Bin 0 -> 11788 bytes .../HexagonMapSystem/Hexagon.fbx.meta | 109 ++++++ .../HexagonMapSystem/HexagonMapSystem.cs | 61 +++ .../HexagonMapSystem/HexagonMapSystem.cs.meta | 11 + .../HexagonMapSystem/新建材质 1.mat | 83 ++++ .../HexagonMapSystem/新建材质 1.mat.meta | 8 + .../HexagonMapSystem/新建材质.mat | 83 ++++ .../HexagonMapSystem/新建材质.mat.meta | 8 + .../ModuleUI/ModuleUIPage/UITestPage.cs | 20 +- .../Component/ScrollView/ScrollView.uss | 2 + .../ScrollView/ScrollViewHorizontal.uxml | 6 +- .../ScrollView/ScrollViewVertical.uxml | 8 +- .../Component/Scroller/Scroller.uss | 2 +- .../Component/Scroller/ScrollerVertical.uxml | 1 + Assets/UI Toolkit/Document/TestDocument.uxml | 126 +++++-- Packages/Cleaner/Editor.meta | 8 + Packages/Cleaner/Editor/AssetCollector.cs | 196 ++++++++++ .../Cleaner/Editor}/AssetCollector.cs.meta | 0 .../Editor/AssetReferenceCollection.cs | 59 +++ .../Editor}/AssetReferenceCollection.cs.meta | 0 .../Editor/ClassReferenceCollection.cs | 356 ++++++++++++++++++ .../Editor}/ClassReferenceCollection.cs.meta | 0 Packages/Cleaner/Editor/CollectionData.cs | 44 +++ .../Cleaner/Editor}/CollectionData.cs.meta | 0 .../Cleaner/Editor/FindUnusedAssetsWindow.cs | 215 +++++++++++ .../Editor}/FindUnusedAssetsWindow.cs.meta | 0 .../Cleaner/Editor/MuHuaEditor.Cleaner.asmdef | 16 + .../Editor/MuHuaEditor.Cleaner.asmdef.meta | 7 + .../Editor/ShaderReferenceCollection.cs | 95 +++++ .../Editor}/ShaderReferenceCollection.cs.meta | 0 Packages/Cleaner/package.json | 11 + Packages/Cleaner/package.json.meta | 7 + Packages/Tools/Assets.meta | 8 + Packages/Tools/Assets/Component.meta | 8 + .../Tools/Assets/Component/ScrollView.meta | 8 + .../Component/ScrollView/ScrollView.uss | 51 +++ .../Component/ScrollView/ScrollView.uss.meta | 11 + .../Component/ScrollView/ScrollView.uxml | 31 ++ .../Component/ScrollView/ScrollView.uxml.meta | 10 + .../ScrollView/ScrollViewHorizontal.uxml | 31 ++ .../ScrollView/ScrollViewHorizontal.uxml.meta | 10 + .../ScrollView/ScrollViewVertical.uxml | 22 ++ .../ScrollView/ScrollViewVertical.uxml.meta | 10 + Packages/Tools/Assets/Component/Scroller.meta | 8 + .../Assets/Component/Scroller/Scroller.uss | 23 ++ .../Component/Scroller/Scroller.uss.meta | 11 + .../Assets/Component/Scroller/Scroller.uxml | 9 + .../Component/Scroller/Scroller.uxml.meta | 10 + .../Scroller/ScrollerHorizontal.uxml | 5 + .../Scroller/ScrollerHorizontal.uxml.meta | 10 + .../Component/Scroller/ScrollerVertical.uxml | 6 + .../Scroller/ScrollerVertical.uxml.meta | 10 + Packages/Tools/Assets/DefaultTheme.meta | 8 + .../Assets/DefaultTheme/DefaultTheme.tss | 6 + .../Assets/DefaultTheme/DefaultTheme.tss.meta | 11 + Packages/Tools/Editor.meta | 8 + Packages/Tools/Editor/CustomLabelDrawer.cs | 23 ++ .../Tools/Editor/CustomLabelDrawer.cs.meta | 11 + Packages/Tools/Editor/MuHuaEditor.asmdef | 18 + Packages/Tools/Editor/MuHuaEditor.asmdef.meta | 7 + Packages/Tools/Editor/SceneNameDrawer.cs | 70 ++++ Packages/Tools/Editor/SceneNameDrawer.cs.meta | 11 + Packages/Tools/Runtime/ModuleAttribute.meta | 8 + .../ModuleAttribute/CustomLabelAttribute.cs | 20 + .../CustomLabelAttribute.cs.meta | 11 + .../ModuleAttribute/SceneNameAttribute.cs | 8 + .../SceneNameAttribute.cs.meta | 11 + .../Runtime/ModuleUIPanel/UIScrollView.meta | 8 + .../{ => UIScrollView}/UIScrollList.cs | 0 .../{ => UIScrollView}/UIScrollList.cs.meta | 0 .../{ => UIScrollView}/UIScrollView.cs | 36 +- .../{ => UIScrollView}/UIScrollView.cs.meta | 0 .../UIScrollView/UIScrollViewV.cs | 117 ++++++ .../UIScrollView/UIScrollViewV.cs.meta | 11 + .../Runtime/ModuleUIPanel/UIScroller.meta | 8 + .../{ => UIScroller}/UIScroller.cs | 38 +- .../{ => UIScroller}/UIScroller.cs.meta | 0 .../ModuleUIPanel/UIScroller/UIScrollerV.cs | 22 ++ .../UIScroller/UIScrollerV.cs.meta | 11 + Packages/packages-lock.json | 6 + 87 files changed, 2265 insertions(+), 1019 deletions(-) delete mode 100644 Assets/AssetsPackage/Cleaner/AssetCollector.cs delete mode 100644 Assets/AssetsPackage/Cleaner/AssetReferenceCollection.cs delete mode 100644 Assets/AssetsPackage/Cleaner/ClassReferenceCollection.cs delete mode 100644 Assets/AssetsPackage/Cleaner/CollectionData.cs delete mode 100644 Assets/AssetsPackage/Cleaner/FindUnusedAssetsWindow.cs delete mode 100644 Assets/AssetsPackage/Cleaner/ShaderReferenceCollection.cs rename Assets/AssetsPackage/{Cleaner.meta => HexagonMapSystem.meta} (77%) create mode 100644 Assets/AssetsPackage/HexagonMapSystem/Hexagon.fbx create mode 100644 Assets/AssetsPackage/HexagonMapSystem/Hexagon.fbx.meta create mode 100644 Assets/AssetsPackage/HexagonMapSystem/HexagonMapSystem.cs create mode 100644 Assets/AssetsPackage/HexagonMapSystem/HexagonMapSystem.cs.meta create mode 100644 Assets/AssetsPackage/HexagonMapSystem/新建材质 1.mat create mode 100644 Assets/AssetsPackage/HexagonMapSystem/新建材质 1.mat.meta create mode 100644 Assets/AssetsPackage/HexagonMapSystem/新建材质.mat create mode 100644 Assets/AssetsPackage/HexagonMapSystem/新建材质.mat.meta create mode 100644 Packages/Cleaner/Editor.meta create mode 100644 Packages/Cleaner/Editor/AssetCollector.cs rename {Assets/AssetsPackage/Cleaner => Packages/Cleaner/Editor}/AssetCollector.cs.meta (100%) create mode 100644 Packages/Cleaner/Editor/AssetReferenceCollection.cs rename {Assets/AssetsPackage/Cleaner => Packages/Cleaner/Editor}/AssetReferenceCollection.cs.meta (100%) create mode 100644 Packages/Cleaner/Editor/ClassReferenceCollection.cs rename {Assets/AssetsPackage/Cleaner => Packages/Cleaner/Editor}/ClassReferenceCollection.cs.meta (100%) create mode 100644 Packages/Cleaner/Editor/CollectionData.cs rename {Assets/AssetsPackage/Cleaner => Packages/Cleaner/Editor}/CollectionData.cs.meta (100%) create mode 100644 Packages/Cleaner/Editor/FindUnusedAssetsWindow.cs rename {Assets/AssetsPackage/Cleaner => Packages/Cleaner/Editor}/FindUnusedAssetsWindow.cs.meta (100%) create mode 100644 Packages/Cleaner/Editor/MuHuaEditor.Cleaner.asmdef create mode 100644 Packages/Cleaner/Editor/MuHuaEditor.Cleaner.asmdef.meta create mode 100644 Packages/Cleaner/Editor/ShaderReferenceCollection.cs rename {Assets/AssetsPackage/Cleaner => Packages/Cleaner/Editor}/ShaderReferenceCollection.cs.meta (100%) create mode 100644 Packages/Cleaner/package.json create mode 100644 Packages/Cleaner/package.json.meta create mode 100644 Packages/Tools/Assets.meta create mode 100644 Packages/Tools/Assets/Component.meta create mode 100644 Packages/Tools/Assets/Component/ScrollView.meta create mode 100644 Packages/Tools/Assets/Component/ScrollView/ScrollView.uss create mode 100644 Packages/Tools/Assets/Component/ScrollView/ScrollView.uss.meta create mode 100644 Packages/Tools/Assets/Component/ScrollView/ScrollView.uxml create mode 100644 Packages/Tools/Assets/Component/ScrollView/ScrollView.uxml.meta create mode 100644 Packages/Tools/Assets/Component/ScrollView/ScrollViewHorizontal.uxml create mode 100644 Packages/Tools/Assets/Component/ScrollView/ScrollViewHorizontal.uxml.meta create mode 100644 Packages/Tools/Assets/Component/ScrollView/ScrollViewVertical.uxml create mode 100644 Packages/Tools/Assets/Component/ScrollView/ScrollViewVertical.uxml.meta create mode 100644 Packages/Tools/Assets/Component/Scroller.meta create mode 100644 Packages/Tools/Assets/Component/Scroller/Scroller.uss create mode 100644 Packages/Tools/Assets/Component/Scroller/Scroller.uss.meta create mode 100644 Packages/Tools/Assets/Component/Scroller/Scroller.uxml create mode 100644 Packages/Tools/Assets/Component/Scroller/Scroller.uxml.meta create mode 100644 Packages/Tools/Assets/Component/Scroller/ScrollerHorizontal.uxml create mode 100644 Packages/Tools/Assets/Component/Scroller/ScrollerHorizontal.uxml.meta create mode 100644 Packages/Tools/Assets/Component/Scroller/ScrollerVertical.uxml create mode 100644 Packages/Tools/Assets/Component/Scroller/ScrollerVertical.uxml.meta create mode 100644 Packages/Tools/Assets/DefaultTheme.meta create mode 100644 Packages/Tools/Assets/DefaultTheme/DefaultTheme.tss create mode 100644 Packages/Tools/Assets/DefaultTheme/DefaultTheme.tss.meta create mode 100644 Packages/Tools/Editor.meta create mode 100644 Packages/Tools/Editor/CustomLabelDrawer.cs create mode 100644 Packages/Tools/Editor/CustomLabelDrawer.cs.meta create mode 100644 Packages/Tools/Editor/MuHuaEditor.asmdef create mode 100644 Packages/Tools/Editor/MuHuaEditor.asmdef.meta create mode 100644 Packages/Tools/Editor/SceneNameDrawer.cs create mode 100644 Packages/Tools/Editor/SceneNameDrawer.cs.meta create mode 100644 Packages/Tools/Runtime/ModuleAttribute.meta create mode 100644 Packages/Tools/Runtime/ModuleAttribute/CustomLabelAttribute.cs create mode 100644 Packages/Tools/Runtime/ModuleAttribute/CustomLabelAttribute.cs.meta create mode 100644 Packages/Tools/Runtime/ModuleAttribute/SceneNameAttribute.cs create mode 100644 Packages/Tools/Runtime/ModuleAttribute/SceneNameAttribute.cs.meta create mode 100644 Packages/UITool/Runtime/ModuleUIPanel/UIScrollView.meta rename Packages/UITool/Runtime/ModuleUIPanel/{ => UIScrollView}/UIScrollList.cs (100%) rename Packages/UITool/Runtime/ModuleUIPanel/{ => UIScrollView}/UIScrollList.cs.meta (100%) rename Packages/UITool/Runtime/ModuleUIPanel/{ => UIScrollView}/UIScrollView.cs (83%) rename Packages/UITool/Runtime/ModuleUIPanel/{ => UIScrollView}/UIScrollView.cs.meta (100%) create mode 100644 Packages/UITool/Runtime/ModuleUIPanel/UIScrollView/UIScrollViewV.cs create mode 100644 Packages/UITool/Runtime/ModuleUIPanel/UIScrollView/UIScrollViewV.cs.meta create mode 100644 Packages/UITool/Runtime/ModuleUIPanel/UIScroller.meta rename Packages/UITool/Runtime/ModuleUIPanel/{ => UIScroller}/UIScroller.cs (92%) rename Packages/UITool/Runtime/ModuleUIPanel/{ => UIScroller}/UIScroller.cs.meta (100%) create mode 100644 Packages/UITool/Runtime/ModuleUIPanel/UIScroller/UIScrollerV.cs create mode 100644 Packages/UITool/Runtime/ModuleUIPanel/UIScroller/UIScrollerV.cs.meta diff --git a/Assets/AssetsPackage/Cleaner/AssetCollector.cs b/Assets/AssetsPackage/Cleaner/AssetCollector.cs deleted file mode 100644 index 6c5f006..0000000 --- a/Assets/AssetsPackage/Cleaner/AssetCollector.cs +++ /dev/null @@ -1,195 +0,0 @@ -using UnityEngine; -using System.Collections; -using System.Collections.Generic; -using System.Linq; -using UnityEditor; -using System.IO; -using System.Text.RegularExpressions; -using System.Text; -using System.Runtime.Serialization.Formatters.Binary; -using System.Xml.Serialization; - -namespace AssetClean { - public class AssetCollector { - public static readonly string exportXMLPath = "referencemap.xml"; - - public List deleteFileList = new List(); - List referenceCollection = new List(); - - public bool useCodeStrip = true; - public bool saveEditorExtensions = true; - - public void Collection(string[] collectionFolders) { - try { - - XmlSerializer serialize = new XmlSerializer(typeof(List)); - - deleteFileList.Clear(); - referenceCollection.Clear(); - - if (File.Exists(exportXMLPath)) { - using (StreamReader fileStream = new StreamReader(exportXMLPath)) { - referenceCollection = (List)serialize.Deserialize(fileStream); - fileStream.Close(); - } - } - - List collectionList = new List(); - - if (useCodeStrip) { - collectionList.Add(new ClassReferenceCollection(saveEditorExtensions)); - } - - collectionList.AddRange(new IReferenceCollection[] { - new ShaderReferenceCollection (), - new AssetReferenceCollection (), - }); - - foreach (IReferenceCollection collection in collectionList) { - collection.Init(referenceCollection); - collection.CollectionFiles(); - } - - // Find assets - var files = StripTargetPathsAll(useCodeStrip, collectionFolders); - - foreach (var path in files) { - var guid = AssetDatabase.AssetPathToGUID(path); - deleteFileList.Add(guid); - } - EditorUtility.DisplayProgressBar("checking", "collection all files", 0.2f); - UnregistReferenceFromResources(); - - EditorUtility.DisplayProgressBar("checking", "check reference from resources", 0.4f); - UnregistReferenceFromScenes(); - - EditorUtility.DisplayProgressBar("checking", "check reference from scenes", 0.6f); - if (saveEditorExtensions) { - UnregistEditorCodes(); - } - - EditorUtility.DisplayProgressBar("checking", "check reference from ignorelist", 0.8f); - UnregistReferenceFromIgnoreList(); - UnregistReferenceFromExtensionMethod(); - - using (var fileStream = new StreamWriter(exportXMLPath)) { - serialize.Serialize(fileStream, referenceCollection); - fileStream.Close(); - } - - } finally { - EditorUtility.ClearProgressBar(); - } - } - - List StripTargetPathsAll(bool isUseCodeStrip, string[] pathes) { - var files = pathes.SelectMany(c => Directory.GetFiles(c, "*.*", SearchOption.AllDirectories)) - .Distinct() - .Where(item => Path.GetExtension(item) != ".meta") - .Where(item => Path.GetExtension(item) != ".js") - .Where(item => Path.GetExtension(item) != ".dll") - .Where(item => Regex.IsMatch(item, "[\\/\\\\]Gizmos[\\/\\\\]") == false) - .Where(item => Regex.IsMatch(item, "[\\/\\\\]Plugins[\\/\\\\]Android[\\/\\\\]") == false) - .Where(item => Regex.IsMatch(item, "[\\/\\\\]Plugins[\\/\\\\]iOS[\\/\\\\]") == false) - .Where(item => Regex.IsMatch(item, "[\\/\\\\]Resources[\\/\\\\]") == false); - - if (isUseCodeStrip == false) { - files = files.Where(item => Path.GetExtension(item) != ".cs"); - } - - return files.ToList(); - } - - void UnregistReferenceFromIgnoreList() { - var codePaths = deleteFileList.Where(fileName => Path.GetExtension(fileName) == ".cs"); - - foreach (var path in codePaths) { - var code = ClassReferenceCollection.StripComment(File.ReadAllText(path)); - if (Regex.IsMatch(code, "static\\s*(partial)*\\s*class")) { - UnregistFromDelteList(AssetDatabase.AssetPathToGUID(path)); - continue; - } - } - } - - void UnregistReferenceFromExtensionMethod() { - var resourcesFiles = deleteFileList - .Where(item => Path.GetExtension(item) != ".meta") - .ToArray(); - foreach (var path in AssetDatabase.GetDependencies(resourcesFiles)) { - UnregistFromDelteList(AssetDatabase.AssetPathToGUID(path)); - } - } - - void UnregistReferenceFromResources() { - var resourcesFiles = deleteFileList - .Where(item => Regex.IsMatch(item, "[\\/\\\\]Resources[\\/\\\\]") == true) - .Where(item => Path.GetExtension(item) != ".meta") - .ToArray(); - foreach (var path in AssetDatabase.GetDependencies(resourcesFiles)) { - - UnregistFromDelteList(AssetDatabase.AssetPathToGUID(path)); - } - } - - void UnregistReferenceFromScenes() { - // Exclude objects that reference from scenes. - var scenes = EditorBuildSettings.scenes - .Where(item => item.enabled == true) - .Select(item => item.path) - .ToArray(); - foreach (var path in AssetDatabase.GetDependencies(scenes)) { - - UnregistFromDelteList(AssetDatabase.AssetPathToGUID(path)); - } - } - - void UnregistEditorCodes() { - // Exclude objects that reference from Editor API - var editorcodes = Directory.GetFiles("Assets", "*.*", SearchOption.AllDirectories) - .Where(fileName => Path.GetExtension(fileName) == ".cs") - .Where(item => Regex.IsMatch(item, "[\\/\\\\]Editor[\\/\\\\]") == true) - .ToArray(); - - EditorUtility.DisplayProgressBar("checking", "check reference from editor codes", 0.8f); - - foreach (var path in editorcodes) { - var code = ClassReferenceCollection.StripComment(File.ReadAllText(path)); - if (Regex.IsMatch(code, "(\\[MenuItem|AssetPostprocessor|EditorWindow)")) { - UnregistFromDelteList(AssetDatabase.AssetPathToGUID(path)); - continue; - } - } - foreach (var path in editorcodes) { - var guid = AssetDatabase.AssetPathToGUID(path); - - if (referenceCollection.Exists(c => c.fileGuid == guid) == false) { - continue; - } - - var referenceGuids = referenceCollection.First(c => c.fileGuid == guid).referenceGids; - - - - if (referenceGuids.Any(c => deleteFileList.Contains(c) == true) == false) { - UnregistFromDelteList(AssetDatabase.AssetPathToGUID(path)); - } - } - } - - void UnregistFromDelteList(string guid) { - if (deleteFileList.Contains(guid) == false) { - return; - } - deleteFileList.Remove(guid); - - if (referenceCollection.Exists(c => c.fileGuid == guid)) { - var refInfo = referenceCollection.First(c => c.fileGuid == guid); - foreach (var referenceGuid in refInfo.referenceGids) { - UnregistFromDelteList(referenceGuid); - } - } - - } - } -} diff --git a/Assets/AssetsPackage/Cleaner/AssetReferenceCollection.cs b/Assets/AssetsPackage/Cleaner/AssetReferenceCollection.cs deleted file mode 100644 index 9209445..0000000 --- a/Assets/AssetsPackage/Cleaner/AssetReferenceCollection.cs +++ /dev/null @@ -1,58 +0,0 @@ -using UnityEngine; -using System.Collections; -using System.Collections.Generic; -using System.IO; -using UnityEditor; -using System.Linq; - -public class AssetReferenceCollection : IReferenceCollection { - public void Init(List refs) { - references = refs; - } - - private List references = null; - - public void CollectionFiles() { - var allFiles = Directory.GetFiles("Assets", "*.*", SearchOption.AllDirectories) - .Where(c => Path.GetExtension(c) != ".meta") - .Where(c => Path.GetExtension(c) != ".shader") - .Where(c => Path.GetExtension(c) != ".cg") - .Where(c => Path.GetExtension(c) != ".cginc") - .Where(c => Path.GetExtension(c) != ".cs"); - - foreach (var file in allFiles) { - CollectionReferenceAssets(file); - } - } - - public void CollectionReferenceAssets(string path) { - string guid = AssetDatabase.AssetPathToGUID(path); - if (File.Exists(path) == false) { return; } - - string[] referenceFiles = AssetDatabase.GetDependencies(new string[] { path }); - List referenceList = null; - CollectionData reference = null; - - if (references.Exists(c => c.fileGuid == guid) == false) { - referenceList = new List(); - reference = new CollectionData() { - fileGuid = guid, - referenceGids = referenceList, - }; - references.Add(reference); - } - else { - reference = references.Find(c => c.fileGuid == guid); - referenceList = reference.referenceGids; - } - if (string.IsNullOrEmpty(AssetDatabase.GUIDToAssetPath(guid)) == false) { - reference.timeStamp = File.GetLastWriteTime(AssetDatabase.GUIDToAssetPath(guid)); - } - - foreach (string file in referenceFiles) { - if (referenceList.Contains(file) == false) - referenceList.Add(AssetDatabase.AssetPathToGUID(file)); - } - } - -} diff --git a/Assets/AssetsPackage/Cleaner/ClassReferenceCollection.cs b/Assets/AssetsPackage/Cleaner/ClassReferenceCollection.cs deleted file mode 100644 index e20749d..0000000 --- a/Assets/AssetsPackage/Cleaner/ClassReferenceCollection.cs +++ /dev/null @@ -1,356 +0,0 @@ -using UnityEngine; -using System.Collections; -using System.Collections.Generic; -using System.Text.RegularExpressions; -using UnityEditor; -using System.IO; -using System.Reflection; -using System.Linq; -using System.Xml.Serialization; - -namespace AssetClean { - public class ClassReferenceCollection : IReferenceCollection { - // guid : types - private List references = null; - - // type : guid - private Dictionary> code2FileDic = new Dictionary>(); - private List fileTypeList = null; - public static readonly string xmlPath = "referenceType2File.xml"; - - private List fileTypeXML { - get { - if (File.Exists(xmlPath) == true) { - using (var reader = new StreamReader(xmlPath)) { - XmlSerializer serialize = new XmlSerializer(typeof(List)); - return (List)serialize.Deserialize(reader); - } - } - else { - return new List(); - } - } - set { - using (var writer = new StreamWriter(xmlPath)) { - XmlSerializer serialize = new XmlSerializer(typeof(List)); - serialize.Serialize(writer, value); - } - } - } - - TypeDate GetTypeData(string guid) { - if (fileTypeList.Exists(c => c.guid == guid) == false) { - - var path = AssetDatabase.GUIDToAssetPath(guid); - - fileTypeList.Add(new TypeDate() { - guid = guid, - fileName = path, - timeStamp = File.GetLastWriteTime(path) - }); - } - - return fileTypeList.First(c => c.guid == guid); - } - - private bool isSaveEditorCode = false; - - public ClassReferenceCollection(bool saveStiroCode = false) { - isSaveEditorCode = saveStiroCode; - fileTypeList = fileTypeXML; - } - - public void Init(List refs) { - references = refs; - } - - public void CollectionFiles() { - - // connect each classes. - var firstPassList = new List(); - if (Directory.Exists("Assets/Plugins")) - firstPassList.AddRange(CodeList("Assets/Plugins")); - if (Directory.Exists("Assets/Standard Assets")) - firstPassList.AddRange(CodeList("Assets/Standard Assets")); - - // Connect the files and class. - var codes = CodeList("Assets/").Where(c => firstPassList.Contains(c) == false); - - var allFirstpassTypes = collectionAllFastspassClasses(); - CollectionCodeFileDictionary(allFirstpassTypes, firstPassList.ToArray()); - - var alltypes = CollectionAllClasses(); - CollectionCodeFileDictionary(alltypes, codes.ToArray()); - alltypes.AddRange(allFirstpassTypes); - - - fileTypeXML = fileTypeList; - - foreach (var type in alltypes) { - List list = null; - if (code2FileDic.ContainsKey(type) == false) { - list = new List(); - code2FileDic.Add(type, list); - } - else { - list = code2FileDic[type]; - } - - var fullName = type.FullName; - var assembly = type.Assembly.FullName; - if (fileTypeList.Exists(c => c.assemblly == assembly && c.typeFullName.Contains(fullName))) { - var datas = fileTypeList.Where(c => c.assemblly == assembly && c.typeFullName.Contains(fullName)); - foreach (var data in datas) { - list.Add(data.guid); - } - } - } - - float count = 1, max = firstPassList.Count; - foreach (var codepath in firstPassList) { - EditorUtility.DisplayProgressBar("analytics", codepath, count++ / max); - CollectionReferenceClasses(AssetDatabase.AssetPathToGUID(codepath), allFirstpassTypes); - } - count = 1; - max = codes.Count(); - foreach (var codepath in codes) { - EditorUtility.DisplayProgressBar("analytics", codepath, count++ / max); - CollectionReferenceClasses(AssetDatabase.AssetPathToGUID(codepath), alltypes); - } - - if (isSaveEditorCode) { - CollectionCustomEditorClasses(alltypes); - } - } - - List CodeList(string path) { - string[] codes = Directory.GetFiles(path, "*.cs", SearchOption.AllDirectories); - - List needUpdateFileList = new List(); - - foreach (var code in codes) { - var guid = AssetDatabase.AssetPathToGUID(code); - if (fileTypeList.Exists(c => c.guid == guid) == false) { - needUpdateFileList.Add(code); - continue; - } - - var filetype = GetTypeData(guid); - - var timeStamp = filetype.timeStamp; - var time = File.GetLastWriteTime(code); - if (time != timeStamp) { - filetype.timeStamp = time; - needUpdateFileList.Add(code); - continue; - } - } - return needUpdateFileList; - } - - void CollectionCodeFileDictionary(List alltypes, string[] codes) { - float count = 1; - foreach (var codePath in codes) { - EditorUtility.DisplayProgressBar("checking", "search files", count++ / codes.Length); - - // connect file and classes. - var code = StripComment(System.IO.File.ReadAllText(codePath)); - var guid = AssetDatabase.AssetPathToGUID(codePath); - - var typeList = GetTypeData(guid); - typeList.typeFullName.Clear(); - - foreach (var type in alltypes) { - - if (type.IsNested) { - continue; - } - - if (string.IsNullOrEmpty(type.Namespace) == false) { - var namespacepattern = string.Format("namespace\\s*{0}[{{\\s\\n]", type.Namespace); - if (Regex.IsMatch(code, namespacepattern) == false) { - continue; - } - } - - string typeName = type.IsGenericTypeDefinition ? type.GetGenericTypeDefinition().Name.Split('`')[0] : type.Name; - if (type.IsClass) { - if (Regex.IsMatch(code, string.Format("class\\s*{0}?[\\s:<{{]", typeName))) { - typeList.Add(type); - - var nested = type.GetNestedTypes(BindingFlags.Public | BindingFlags.Instance); - - foreach (var nestedType in nested) { - typeList.Add(nestedType); - } - - continue; - } - } - else if (type.IsInterface) { - - if (Regex.IsMatch(code, string.Format("interface\\s*{0}[\\s<{{]", typeName))) { - typeList.Add(type); - continue; - } - } - else if (type.IsEnum) { - - if (Regex.IsMatch(code, string.Format("enum\\s*{0}[\\s{{]", type.Name))) { - typeList.Add(type); - continue; - } - } - else { - if (Regex.IsMatch(code, string.Format("struct\\s*{0}[\\s:<{{]", typeName))) { - typeList.Add(type); - continue; - } - if (Regex.IsMatch(code, string.Format("delegate\\s*{0}\\s\\(", typeName))) { - typeList.Add(type); - continue; - } - } - } - } - } - - List CollectionAllClasses() { - string path = Application.dataPath; - string absolutePath = path.Remove(path.Length - 6); - List alltypes = new List(); - if (File.Exists(absolutePath + "Library/ScriptAssemblies/Assembly-CSharp.dll")) - alltypes.AddRange(Assembly.LoadFile(absolutePath + "Library/ScriptAssemblies/Assembly-CSharp.dll").GetTypes()); - if (isSaveEditorCode && File.Exists(absolutePath + "Library/ScriptAssemblies/Assembly-CSharp-Editor.dll")) - alltypes.AddRange(Assembly.LoadFile(absolutePath + "Library/ScriptAssemblies/Assembly-CSharp-Editor.dll").GetTypes()); - - return alltypes.ToList(); - } - - List collectionAllFastspassClasses() { - string path = Application.dataPath; - string absolutePath = path.Remove(path.Length - 6); - List alltypes = new List(); - if (File.Exists(absolutePath + "Library/ScriptAssemblies/Assembly-CSharp-firstpass.dll")) - alltypes.AddRange(Assembly.LoadFile(absolutePath + "Library/ScriptAssemblies/Assembly-CSharp-firstpass.dll").GetTypes()); - if (isSaveEditorCode && File.Exists(absolutePath + "Library/ScriptAssemblies/Assembly-CSharp-Editor-firstpass.dll")) - alltypes.AddRange(Assembly.LoadFile(absolutePath + "Library/ScriptAssemblies/Assembly-CSharp-Editor-firstpass.dll").GetTypes()); - return alltypes; - } - - public static string StripComment(string code) { - code = Regex.Replace(code, "//.*[\\n\\r]", ""); - code = Regex.Replace(code, "/\\*.*[\\n\\r]\\*/", ""); - return code; - } - - void CollectionReferenceClasses(string guid, List types) { - var codePath = AssetDatabase.GUIDToAssetPath(guid); - if (string.IsNullOrEmpty(codePath) || File.Exists(codePath) == false) { - return; - } - - var code = StripComment(System.IO.File.ReadAllText(codePath)); - - List referenceList = null; - CollectionData reference = null; - - if (references.Exists(c => c.fileGuid == guid) == false) { - referenceList = new List(); - reference = new CollectionData() { - fileGuid = guid, - referenceGids = referenceList, - }; - references.Add(reference); - } - else { - reference = references.Find(c => c.fileGuid == guid); - referenceList = reference.referenceGids; - } - - referenceList.Clear(); - - var timestamp = File.GetLastWriteTime(codePath); - reference.timeStamp = timestamp; - - foreach (var type in types) { - - if (code2FileDic.ContainsKey(type) == false || code2FileDic[type].Contains(guid)) { - continue; - } - - if (string.IsNullOrEmpty(type.Namespace) == false) { - var namespacepattern = string.Format("([namespace|using][\\s]{0}[{{\\s\\r\\n\\r;]|{0}\\.)", type.Namespace); - if (Regex.IsMatch(code, namespacepattern) == false) { - continue; - } - } - - string match = string.Empty; - - if (type.IsGenericTypeDefinition) { - string typeName = type.GetGenericTypeDefinition().Name.Split('`')[0]; - match = string.Format("[!|&\\]\\[\\.\\s<(]{0}[\\.\\s\\n\\r>,<(){{]", typeName); - - } - else { - string typeName = type.Name.Split('`')[0].Replace("Attribute", ""); - match = string.Format("[!|&\\]\\[\\.\\s<(]{0}[\\.\\s\\n\\r>,<(){{\\]]", typeName); - - - // check Extension Methods - - if (Regex.IsMatch(code, string.Format("this\\s{0}\\s", typeName))) { - foreach (var file in code2FileDic[type]) { - foreach (var baseReference in references.Where(c => c.fileGuid == file)) { - baseReference.referenceGids.Add(guid); - } - } - } - } - if (Regex.IsMatch(code, match)) { - var typeGuids = code2FileDic[type]; - foreach (var typeGuid in typeGuids) { - - if (referenceList.Contains(typeGuid) == false) { - referenceList.Add(typeGuid); - } - } - } - } - } - - void CollectionCustomEditorClasses(IEnumerable types) { - foreach (var type in types) { - - if (code2FileDic.ContainsKey(type) == false) { - continue; - } - - var attributes = type.GetCustomAttributes(typeof(CustomEditor), true); - foreach (var attribute in attributes) { - if (attribute is CustomEditor == false) { - continue; - } - var customEditor = attribute as CustomEditor; - var customEditorReferenceTypeField = typeof(CustomEditor).GetField("m_InspectedType", BindingFlags.Instance | BindingFlags.NonPublic); - var customEditorReferenceType = (System.Type)customEditorReferenceTypeField.GetValue(customEditor); - - if (code2FileDic.ContainsKey(customEditorReferenceType) == false) { - continue; - } - - foreach (var filePath in code2FileDic[customEditorReferenceType]) { - if (references.Exists(c => c.fileGuid == filePath) == false) { - continue; - } - foreach (var refs in references.Where(c => c.fileGuid == filePath)) { - var list = refs.referenceGids; - list.AddRange(code2FileDic[type]); - } - } - } - } - } - } -} diff --git a/Assets/AssetsPackage/Cleaner/CollectionData.cs b/Assets/AssetsPackage/Cleaner/CollectionData.cs deleted file mode 100644 index 4fe0602..0000000 --- a/Assets/AssetsPackage/Cleaner/CollectionData.cs +++ /dev/null @@ -1,42 +0,0 @@ -using UnityEngine; -using System.Collections; -using System.Collections.Generic; -using System; -using System.Linq; - -[System.Serializable] -public class CollectionData { - public string fileGuid; - public string fileName; - public List referenceGids = new List(); - public DateTime timeStamp; -} - -[System.Serializable] -public class TypeDate { - public string guid; - public string fileName; - public DateTime timeStamp; - public List typeFullName = new List(); - public string assemblly; - - public void Add(Type addtype) { - assemblly = addtype.Assembly.FullName; - var typeName = addtype.FullName; - if (typeFullName.Contains(typeName) == false) { - typeFullName.Add(typeName); - } - } - - public Type[] types { - get { - return typeFullName.Select(c => Type.GetType(c)).ToArray(); - } - } -} - -public interface IReferenceCollection { - void CollectionFiles(); - void Init(List refs); -} - diff --git a/Assets/AssetsPackage/Cleaner/FindUnusedAssetsWindow.cs b/Assets/AssetsPackage/Cleaner/FindUnusedAssetsWindow.cs deleted file mode 100644 index 8ede58c..0000000 --- a/Assets/AssetsPackage/Cleaner/FindUnusedAssetsWindow.cs +++ /dev/null @@ -1,214 +0,0 @@ -using UnityEngine; -using System.Collections; -using System.Collections.Generic; -using UnityEditor; -using System.IO; -using System.Linq; - -namespace AssetClean { - public class FindUnusedAssetsWindow : EditorWindow { - AssetCollector collection = new AssetCollector(); - List deleteAssets = new List(); - Vector2 scroll; - - [MenuItem("Window/Delete Unused Assets/only resource", false, 50)] - static void InitWithoutCode() { - var window = FindUnusedAssetsWindow.CreateInstance(); - window.collection.useCodeStrip = false; - window.collection.Collection(new string[] { "Assets" }); - window.CopyDeleteFileList(window.collection.deleteFileList); - - window.Show(); - } - - [MenuItem("Window/Delete Unused Assets/unused by editor", false, 51)] - static void InitWithout() { - var window = FindUnusedAssetsWindow.CreateInstance(); - window.collection.Collection(new string[] { "Assets" }); - window.CopyDeleteFileList(window.collection.deleteFileList); - - window.Show(); - } - - [MenuItem("Window/Delete Unused Assets/unused by game", false, 52)] - static void Init() { - FindUnusedAssetsWindow window = CreateInstance(); - window.collection.saveEditorExtensions = false; - window.collection.Collection(new string[] { "Assets" }); - window.CopyDeleteFileList(window.collection.deleteFileList); - - window.Show(); - } - - // [MenuItem("Assets/Delete Unused Assets/unused by editor", false, 52)] - // static void InitAssets () - // { - // var paths = Selection.objects - // .Select(c=>AssetDatabase.GetAssetPath(c)) - // .Where(c=>Directory.Exists(c)); - // if( paths.Any(c=> string.IsNullOrEmpty(c) ) ){ - // return; - // } - // - // var window = FindUnusedAssetsWindow.CreateInstance (); - // window.collection.Collection (paths.ToArray()); - // window.CopyDeleteFileList (window.collection.deleteFileList); - // - // window.Show (); - // } - // - // [MenuItem("Assets/Delete Unused Assets/unused by editor", true)] - // static bool InitAssetsA () - // { - // var paths = Selection.objects - // .Select(c=>AssetDatabase.GetAssetPath(c)) - // .Where(c=>Directory.Exists(c)); - // return ! paths.Any(c=> string.IsNullOrEmpty(c) ); - // } - - - - [MenuItem("Assets/Delete Unused Assets/unused only resources", false, 52)] - static void InitAssetsOnlyResources() { - var paths = Selection.objects - .Select(c => AssetDatabase.GetAssetPath(c)) - .Where(c => Directory.Exists(c)); - if (paths.Any(c => string.IsNullOrEmpty(c))) { - return; - } - - var window = FindUnusedAssetsWindow.CreateInstance(); - window.collection.useCodeStrip = false; - window.collection.Collection(paths.ToArray()); - window.CopyDeleteFileList(window.collection.deleteFileList); - - window.Show(); - } - [MenuItem("Assets/Delete Unused Assets/unused only resources", true)] - static bool InitAssetsOnlyResourcesA() { - var paths = Selection.objects - .Select(c => AssetDatabase.GetAssetPath(c)) - .Where(c => Directory.Exists(c)); - return !paths.Any(c => string.IsNullOrEmpty(c)); - } - - [MenuItem("Window/Delete Unused Assets/Clear cache")] - static void ClearCache() { - File.Delete(AssetClean.AssetCollector.exportXMLPath); - File.Delete(AssetClean.ClassReferenceCollection.xmlPath); - - EditorUtility.DisplayDialog("clear file", "clear file", "OK"); - } - - - void OnGUI() { - using (var horizonal = new EditorGUILayout.HorizontalScope("box")) { - EditorGUILayout.LabelField("delete unreference assets from buildsettings and resources"); - } - - using (var scrollScope = new EditorGUILayout.ScrollViewScope(scroll)) { - scroll = scrollScope.scrollPosition; - foreach (var asset in deleteAssets) { - if (string.IsNullOrEmpty(asset.path)) { - continue; - } - - using (var horizonal = new EditorGUILayout.HorizontalScope()) { - asset.isDelete = EditorGUILayout.Toggle(asset.isDelete, GUILayout.Width(20)); - var icon = AssetDatabase.GetCachedIcon(asset.path); - GUILayout.Label(icon, GUILayout.Width(20), GUILayout.Height(20)); - if (GUILayout.Button(asset.path, EditorStyles.largeLabel)) { - Selection.activeObject = AssetDatabase.LoadAssetAtPath(asset.path); - } - } - } - - - } - using (var horizonal = new EditorGUILayout.HorizontalScope("box")) { - EditorGUILayout.Space(); - if (GUILayout.Button("Exclude from Project", GUILayout.Width(160)) && deleteAssets.Count != 0) { - EditorApplication.delayCall += Exclude; - } - } - - } - - void Exclude() { - RemoveFiles(); - Close(); - } - - static void CleanDir() { - RemoveEmptyDirectry("Assets"); - AssetDatabase.Refresh(); - } - - void CopyDeleteFileList(IEnumerable deleteFileList) { - foreach (var asset in deleteFileList) { - var filePath = AssetDatabase.GUIDToAssetPath(asset); - if (string.IsNullOrEmpty(filePath) == false) { - deleteAssets.Add(new DeleteAsset() { path = filePath }); - } - } - } - - void RemoveFiles() { - try { - string exportDirectry = "BackupUnusedAssets"; - Directory.CreateDirectory(exportDirectry); - var files = deleteAssets.Where(item => item.isDelete == true).Select(item => item.path).ToArray(); - string backupPackageName = exportDirectry + "/package" + System.DateTime.Now.ToString("yyyyMMddHHmmss") + ".unitypackage"; - EditorUtility.DisplayProgressBar("export package", backupPackageName, 0); - - AssetDatabase.ExportPackage(files, backupPackageName); - - int i = 0; - int length = deleteAssets.Count; - - foreach (var assetPath in files) { - i++; - EditorUtility.DisplayProgressBar("delete unused assets", assetPath, (float)i / length); - AssetDatabase.DeleteAsset(assetPath); - if (File.Exists(assetPath)) { - File.Delete(assetPath); - } - } - - EditorUtility.DisplayProgressBar("clean directory", "", 1); - foreach (var dir in Directory.GetDirectories("Assets")) { - RemoveEmptyDirectry(dir); - } - - System.Diagnostics.Process.Start(exportDirectry); - - AssetDatabase.Refresh(); - } - catch (System.Exception e) { - Debug.Log(e.Message); - } finally { - EditorUtility.ClearProgressBar(); - } - } - - static void RemoveEmptyDirectry(string path) { - var dirs = Directory.GetDirectories(path); - foreach (var dir in dirs) { - RemoveEmptyDirectry(dir); - } - - - var files = Directory.GetFiles(path, "*", SearchOption.TopDirectoryOnly).Where(item => Path.GetExtension(item) != ".meta"); - if (files.Count() == 0 && Directory.GetDirectories(path).Count() == 0) { - var metaFile = AssetDatabase.GetTextMetaFilePathFromAssetPath(path); - UnityEditor.FileUtil.DeleteFileOrDirectory(path); - UnityEditor.FileUtil.DeleteFileOrDirectory(metaFile); - } - } - - class DeleteAsset { - public bool isDelete = true; - public string path; - } - } -} diff --git a/Assets/AssetsPackage/Cleaner/ShaderReferenceCollection.cs b/Assets/AssetsPackage/Cleaner/ShaderReferenceCollection.cs deleted file mode 100644 index f8b990a..0000000 --- a/Assets/AssetsPackage/Cleaner/ShaderReferenceCollection.cs +++ /dev/null @@ -1,95 +0,0 @@ -using UnityEngine; -using System.Collections; -using System.Collections.Generic; -using System.IO; -using System.Text.RegularExpressions; -using UnityEditor; - -namespace AssetClean { - public class ShaderReferenceCollection : IReferenceCollection { - // shader name / shader file guid - public Dictionary shaderFileList = new Dictionary(); - private List references = new List(); - - public void Init(List refs) { - references = refs; - } - - public void CollectionFiles() { - CollectionShaderFiles(); - CheckReference(); - } - - void CollectionShaderFiles() { - var shaderFiles = Directory.GetFiles("Assets", "*.shader", SearchOption.AllDirectories); - foreach (var shaderFilePath in shaderFiles) { - var code = File.ReadAllText(shaderFilePath); - var match = Regex.Match(code, "Shader \"(?.*)\""); - if (match.Success) { - var shaderName = match.Groups["name"].ToString(); - if (shaderFileList.ContainsKey(shaderName) == false) { - shaderFileList.Add(shaderName, AssetDatabase.AssetPathToGUID(shaderFilePath)); - } - } - } - - var cgFiles = Directory.GetFiles("Assets", "*.cg", SearchOption.AllDirectories); - foreach (var cgFilePath in cgFiles) { - var file = Path.GetFileName(cgFilePath); - shaderFileList.Add(file, cgFilePath); - } - - var cgincFiles = Directory.GetFiles("Assets", "*.cginc", SearchOption.AllDirectories); - foreach (var cgincPath in cgincFiles) { - var file = Path.GetFileName(cgincPath); - if (shaderFileList.ContainsKey(file) == false) { - shaderFileList.Add(file, cgincPath); - } - } - } - - void CheckReference() { - foreach (var shader in shaderFileList) { - var shaderFilePath = AssetDatabase.GUIDToAssetPath(shader.Value); - if (File.Exists(shaderFilePath) == false) { - continue; - } - - var guid = shader.Value; - - List referenceList = null; - CollectionData reference = null; - - if (references.Exists(c => c.fileGuid == guid) == false) { - referenceList = new List(); - reference = new CollectionData() { - fileGuid = guid, - referenceGids = referenceList, - }; - references.Add(reference); - } - else { - reference = references.Find(c => c.fileGuid == guid); - referenceList = reference.referenceGids; - } - - reference.timeStamp = File.GetLastWriteTime(AssetDatabase.GUIDToAssetPath(guid)); - - var code = ClassReferenceCollection.StripComment(File.ReadAllText(shaderFilePath)); - - foreach (var checkingShaderName in shaderFileList.Keys) { - if (checkingShaderName == shader.Key) { - continue; - } - - if (code.IndexOf(checkingShaderName) != -1 && shaderFileList.ContainsKey(checkingShaderName)) { - var fileGuid = shaderFileList[checkingShaderName]; - if (referenceList.Contains(fileGuid) == false) { - referenceList.Add(fileGuid); - } - } - } - } - } - } -} \ No newline at end of file diff --git a/Assets/AssetsPackage/Cleaner.meta b/Assets/AssetsPackage/HexagonMapSystem.meta similarity index 77% rename from Assets/AssetsPackage/Cleaner.meta rename to Assets/AssetsPackage/HexagonMapSystem.meta index 687fb53..193e8a5 100644 --- a/Assets/AssetsPackage/Cleaner.meta +++ b/Assets/AssetsPackage/HexagonMapSystem.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 0ecc08ef1d6ca1148a200120e465d381 +guid: 41a0350eab712da4c995987e78ea7730 folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Assets/AssetsPackage/HexagonMapSystem/Hexagon.fbx b/Assets/AssetsPackage/HexagonMapSystem/Hexagon.fbx new file mode 100644 index 0000000000000000000000000000000000000000..636bda235a8807f45f0c7d2a6c330460ec2c8ab2 GIT binary patch literal 11788 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 literal 0 HcmV?d00001 diff --git a/Assets/AssetsPackage/HexagonMapSystem/Hexagon.fbx.meta b/Assets/AssetsPackage/HexagonMapSystem/Hexagon.fbx.meta new file mode 100644 index 0000000..601e231 --- /dev/null +++ b/Assets/AssetsPackage/HexagonMapSystem/Hexagon.fbx.meta @@ -0,0 +1,109 @@ +fileFormatVersion: 2 +guid: 67c2fd624cee7914fba45f64a3cb04d1 +ModelImporter: + serializedVersion: 22200 + internalIDToNameTable: [] + externalObjects: {} + materials: + materialImportMode: 2 + materialName: 0 + materialSearch: 1 + materialLocation: 1 + animations: + legacyGenerateAnimations: 4 + bakeSimulation: 0 + resampleCurves: 1 + optimizeGameObjects: 0 + removeConstantScaleCurves: 0 + motionNodeName: + rigImportErrors: + rigImportWarnings: + animationImportErrors: + animationImportWarnings: + animationRetargetingWarnings: + animationDoRetargetingWarnings: 0 + importAnimatedCustomProperties: 0 + importConstraints: 0 + animationCompression: 1 + animationRotationError: 0.5 + animationPositionError: 0.5 + animationScaleError: 0.5 + animationWrapMode: 0 + extraExposedTransformPaths: [] + extraUserProperties: [] + clipAnimations: [] + isReadable: 0 + meshes: + lODScreenPercentages: [] + globalScale: 1 + meshCompression: 0 + addColliders: 0 + useSRGBMaterialColor: 1 + sortHierarchyByName: 1 + importPhysicalCameras: 1 + importVisibility: 1 + importBlendShapes: 1 + importCameras: 1 + importLights: 1 + nodeNameCollisionStrategy: 1 + fileIdsGeneration: 2 + swapUVChannels: 0 + generateSecondaryUV: 0 + useFileUnits: 1 + keepQuads: 0 + weldVertices: 1 + bakeAxisConversion: 0 + preserveHierarchy: 0 + skinWeightsMode: 0 + maxBonesPerVertex: 4 + minBoneWeight: 0.001 + optimizeBones: 1 + meshOptimizationFlags: -1 + indexFormat: 0 + secondaryUVAngleDistortion: 8 + secondaryUVAreaDistortion: 15.000001 + secondaryUVHardAngle: 88 + secondaryUVMarginMethod: 1 + secondaryUVMinLightmapResolution: 40 + secondaryUVMinObjectScale: 1 + secondaryUVPackMargin: 4 + useFileScale: 1 + strictVertexDataChecks: 0 + tangentSpace: + normalSmoothAngle: 60 + normalImportMode: 0 + tangentImportMode: 3 + normalCalculationMode: 4 + legacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes: 0 + blendShapeNormalImportMode: 1 + normalSmoothingSource: 0 + referencedClips: [] + importAnimation: 1 + humanDescription: + serializedVersion: 3 + human: [] + skeleton: [] + armTwist: 0.5 + foreArmTwist: 0.5 + upperLegTwist: 0.5 + legTwist: 0.5 + armStretch: 0.05 + legStretch: 0.05 + feetSpacing: 0 + globalScale: 1 + rootMotionBoneName: + hasTranslationDoF: 0 + hasExtraRoot: 0 + skeletonHasParents: 1 + lastHumanDescriptionAvatarSource: {instanceID: 0} + autoGenerateAvatarMappingIfUnspecified: 1 + animationType: 2 + humanoidOversampling: 1 + avatarSetup: 0 + addHumanoidExtraRootOnlyWhenUsingAvatar: 1 + importBlendShapeDeformPercent: 1 + remapMaterialsIfMaterialImportModeIsNone: 0 + additionalBone: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/AssetsPackage/HexagonMapSystem/HexagonMapSystem.cs b/Assets/AssetsPackage/HexagonMapSystem/HexagonMapSystem.cs new file mode 100644 index 0000000..ca2cba1 --- /dev/null +++ b/Assets/AssetsPackage/HexagonMapSystem/HexagonMapSystem.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using MuHua; + +public class HexagonMapSystem : MonoBehaviour { + public const float InnerDiam = 1f; + public const float OuterDiam = InnerDiam * 1.154700538379252f; + public const float InnerRadius = InnerDiam * 0.5f; + public const float OuterRadius = OuterDiam * 0.5f; + + public int wide, high; + public Transform prefab; + public GameObject[,] array; + private void Awake() { + array = new GameObject[wide, high]; + Loop((x, y) => { array[x, y] = Generate(x, y); }); + } + private void Update() { + if (Input.GetMouseButtonDown(0) && RayTool.GetMouseToWorldPosition(out Vector3 worldPosition)) { + Vector2Int xy = GetXY(worldPosition); + Debug.Log(xy); + } + } + public void Loop(Action action) { + for (int y = 0; y < high; y++) { + for (int x = 0; x < wide; x++) { action?.Invoke(x, y); } + } + } + public GameObject Generate(int x, int y) { + Transform temp = Instantiate(prefab, transform); + temp.position = GetWorldPosition(x, y); + temp.gameObject.SetActive(true); + return temp.gameObject; + } + public Vector3 GetWorldPosition(int x, int y) { + float offset = (y % 2) == 1 ? InnerRadius : 0; + float xPosition = x * InnerDiam + offset; + float zPosition = y * OuterDiam * 0.75f; + return new Vector3(xPosition, 0, zPosition); + } + public Vector2Int GetXY(Vector3 worldPosition) { + float offsetX = worldPosition.x / (InnerRadius * 2f); + float offsetZ = worldPosition.z / (OuterRadius * 3f); + float originalX = offsetX - offsetZ; + float originalY = -offsetX - offsetZ; + int iX = Mathf.RoundToInt(originalX); + int iY = Mathf.RoundToInt(originalY); + int iZ = Mathf.RoundToInt(-originalX - originalY); + if (iX + iY + iZ != 0) { + float differenceX = Mathf.Abs(originalX - iX); + float differenceY = Mathf.Abs(originalY - iY); + float differenceZ = Mathf.Abs(-originalX - originalY - iZ); + if (differenceX > differenceY && differenceX > differenceZ) { iX = -iY - iZ; } + else if (differenceZ > differenceY) { iZ = -iX - iY; } + } + int offset = iZ > 0 ? 0 : (iZ % 2); + return new Vector2Int(iX + ((iZ + offset) / 2), iZ); + } +} diff --git a/Assets/AssetsPackage/HexagonMapSystem/HexagonMapSystem.cs.meta b/Assets/AssetsPackage/HexagonMapSystem/HexagonMapSystem.cs.meta new file mode 100644 index 0000000..3c642e1 --- /dev/null +++ b/Assets/AssetsPackage/HexagonMapSystem/HexagonMapSystem.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e2f8faf05999aac48876a91674f33225 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/AssetsPackage/HexagonMapSystem/新建材质 1.mat b/Assets/AssetsPackage/HexagonMapSystem/新建材质 1.mat new file mode 100644 index 0000000..f78fdec --- /dev/null +++ b/Assets/AssetsPackage/HexagonMapSystem/新建材质 1.mat @@ -0,0 +1,83 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 8 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: "\u65B0\u5EFA\u6750\u8D28 1" + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_Parent: {fileID: 0} + m_ModifiedSerializedProperties: 0 + m_ValidKeywords: [] + m_InvalidKeywords: [] + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_LockedProperties: + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Ints: [] + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 0.9825768, g: 1, b: 0.48627448, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} + m_BuildTextureStacks: [] diff --git a/Assets/AssetsPackage/HexagonMapSystem/新建材质 1.mat.meta b/Assets/AssetsPackage/HexagonMapSystem/新建材质 1.mat.meta new file mode 100644 index 0000000..02bb7aa --- /dev/null +++ b/Assets/AssetsPackage/HexagonMapSystem/新建材质 1.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 99d8f3da04e2d5c4d8b313f164a0b496 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/AssetsPackage/HexagonMapSystem/新建材质.mat b/Assets/AssetsPackage/HexagonMapSystem/新建材质.mat new file mode 100644 index 0000000..821abab --- /dev/null +++ b/Assets/AssetsPackage/HexagonMapSystem/新建材质.mat @@ -0,0 +1,83 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 8 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: "\u65B0\u5EFA\u6750\u8D28" + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_Parent: {fileID: 0} + m_ModifiedSerializedProperties: 0 + m_ValidKeywords: [] + m_InvalidKeywords: [] + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_LockedProperties: + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Ints: [] + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 0.61900413, g: 1, b: 0.48584908, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} + m_BuildTextureStacks: [] diff --git a/Assets/AssetsPackage/HexagonMapSystem/新建材质.mat.meta b/Assets/AssetsPackage/HexagonMapSystem/新建材质.mat.meta new file mode 100644 index 0000000..f442855 --- /dev/null +++ b/Assets/AssetsPackage/HexagonMapSystem/新建材质.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9129ff6f94545cd4e9b3f6e8abed0635 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ModuleCore/ModuleUI/ModuleUIPage/UITestPage.cs b/Assets/ModuleCore/ModuleUI/ModuleUIPage/UITestPage.cs index 5294949..63481b5 100644 --- a/Assets/ModuleCore/ModuleUI/ModuleUIPage/UITestPage.cs +++ b/Assets/ModuleCore/ModuleUI/ModuleUIPage/UITestPage.cs @@ -13,13 +13,19 @@ public class UITestPage : ModuleUIPage { private UIToggle toggle; private UIDropdown dropdown; - private UIScrollView scrollView; + private UIScrollView scrollView1; + private UIScrollView scrollView2; + private UIScrollView scrollView3; + private UIScrollView scrollView4; public override VisualElement Element => root; public VisualElement Toggle => Q("Toggle"); public VisualElement Dropdown => Q("Dropdown"); - public VisualElement ScrollView => Q("ScrollView"); + public VisualElement ScrollView1 => Q("ScrollView1"); + public VisualElement ScrollView2 => Q("ScrollView2"); + public VisualElement ScrollView3 => Q("ScrollView3"); + public VisualElement ScrollView4 => Q("ScrollView4"); private void Awake() { toggle = new UIToggle(Toggle); @@ -29,11 +35,17 @@ public class UITestPage : ModuleUIPage { dropdown.SetValue(list); dropdown.ValueChanged += (value) => Debug.Log(value); - scrollView = new UIScrollView(ScrollView, root, UIDirection.Vertical, UIDirection.FromLeftToRight, UIDirection.FromTopToBottom); + scrollView1 = new UIScrollView(ScrollView1, root, UIDirection.Vertical, UIDirection.FromLeftToRight, UIDirection.FromTopToBottom); + scrollView2 = new UIScrollView(ScrollView2, root, UIDirection.Vertical, UIDirection.FromLeftToRight, UIDirection.FromBottomToTop); + scrollView3 = new UIScrollView(ScrollView3, root, UIDirection.Horizontal, UIDirection.FromLeftToRight); + scrollView4 = new UIScrollView(ScrollView4, root, UIDirection.Horizontal, UIDirection.FromLeftToRight); } private void Update() { dropdown.Update(); - scrollView.Update(); + scrollView1.Update(); + scrollView2.Update(); + scrollView3.Update(); + scrollView4.Update(); } private void OnDestroy() { dropdown.Release(); diff --git a/Assets/UI Toolkit/Component/ScrollView/ScrollView.uss b/Assets/UI Toolkit/Component/ScrollView/ScrollView.uss index cf84740..9281453 100644 --- a/Assets/UI Toolkit/Component/ScrollView/ScrollView.uss +++ b/Assets/UI Toolkit/Component/ScrollView/ScrollView.uss @@ -1,4 +1,5 @@ .scrollview { + flex-grow: 1; } .scrollview-viewport { @@ -15,6 +16,7 @@ flex-direction: column; align-self: flex-start; flex-shrink: 0; + width: 100%; } .scrollview-horizontal-scroller { diff --git a/Assets/UI Toolkit/Component/ScrollView/ScrollViewHorizontal.uxml b/Assets/UI Toolkit/Component/ScrollView/ScrollViewHorizontal.uxml index 374ee87..c4ea1e7 100644 --- a/Assets/UI Toolkit/Component/ScrollView/ScrollViewHorizontal.uxml +++ b/Assets/UI Toolkit/Component/ScrollView/ScrollViewHorizontal.uxml @@ -1,8 +1,8 @@ -