├── .gitignore ├── Assets ├── RecycleView.meta ├── RecycleView │ ├── ExpandableView.cs │ ├── ExpandableView.cs.meta │ ├── ExpandableViewEditor.cs │ ├── ExpandableViewEditor.cs.meta │ ├── RecycleView.cs │ ├── RecycleView.cs.meta │ ├── RecycleViewEditor.cs │ ├── RecycleViewEditor.cs.meta │ ├── RecycleViewTest.cs │ └── RecycleViewTest.cs.meta ├── Scenes.meta └── Scenes │ ├── MainDemo.unity │ └── MainDemo.unity.meta ├── Document ├── gif.meta └── img │ ├── demo.gif │ ├── demo.gif.meta │ ├── demo1.gif │ ├── rv01.png │ ├── rv02.png │ ├── rv03.png │ ├── rv04.png │ ├── rv05.png │ └── rv06.png ├── Packages ├── manifest.json └── packages-lock.json ├── ProjectSettings ├── AudioManager.asset ├── AutoStreamingSettings.asset ├── ClusterInputManager.asset ├── DynamicsManager.asset ├── EditorBuildSettings.asset ├── EditorSettings.asset ├── GraphicsSettings.asset ├── InputManager.asset ├── MemorySettings.asset ├── NavMeshAreas.asset ├── PackageManagerSettings.asset ├── Packages │ └── com.unity.testtools.codecoverage │ │ └── Settings.json ├── Physics2DSettings.asset ├── PresetManager.asset ├── ProjectSettings.asset ├── ProjectVersion.txt ├── QualitySettings.asset ├── SceneTemplateSettings.json ├── TagManager.asset ├── TimeManager.asset ├── UnityConnectSettings.asset ├── VFXManager.asset ├── VersionControlSettings.asset ├── XRSettings.asset └── boot.config ├── README.md └── UserSettings ├── EditorUserSettings.asset └── Layouts └── default-2021.dwlt /.gitignore: -------------------------------------------------------------------------------- 1 | # This .gitignore file should be placed at the root of your Unity project directory 2 | # 3 | # Get latest from https://github.com/github/gitignore/blob/master/Unity.gitignore 4 | # 5 | /[Ll]ibrary/ 6 | /[Tt]emp/ 7 | /[Oo]bj/ 8 | /[Bb]uild/ 9 | /[Bb]uilds/ 10 | /[Ll]ogs/ 11 | /[Mm]emoryCaptures/ 12 | /[Uu]serSettings/ 13 | /.idea 14 | 15 | 16 | 17 | # Asset meta data should only be ignored when the corresponding asset is also ignored 18 | !/[Aa]ssets/**/*.meta 19 | 20 | # Uncomment this line if you wish to ignore the asset store tools plugin 21 | # /[Aa]ssets/AssetStoreTools* 22 | 23 | # Autogenerated Jetbrains Rider plugin 24 | [Aa]ssets/Plugins/Editor/JetBrains* 25 | 26 | # Visual Studio cache directory 27 | .vs/ 28 | 29 | # Gradle cache directory 30 | .gradle/ 31 | 32 | # Autogenerated VS/MD/Consulo solution and project files 33 | ExportedObj/ 34 | .consulo/ 35 | *.csproj 36 | *.unityproj 37 | *.sln 38 | *.suo 39 | *.tmp 40 | *.user 41 | *.userprefs 42 | *.pidb 43 | *.booproj 44 | *.svd 45 | *.pdb 46 | *.mdb 47 | *.opendb 48 | *.VC.db 49 | 50 | # Unity3D generated meta files 51 | *.pidb.meta 52 | *.pdb.meta 53 | *.mdb.meta 54 | 55 | # Unity3D generated file on crash reports 56 | sysinfo.txt 57 | 58 | # Builds 59 | *.apk 60 | *.unitypackage 61 | 62 | # Crashlytics generated file 63 | crashlytics-build.properties 64 | 65 | -------------------------------------------------------------------------------- /Assets/RecycleView.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2373c1b0512abc046b96d86dc4aaa966 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/RecycleView/ExpandableView.cs: -------------------------------------------------------------------------------- 1 | //*****************************-》 可收展 循环列表 《-**************************** 2 | //初始化: 3 | // Init(CallBack) //不需要 回调Cell点击函数时用此 Init() 4 | // Init(CallBack, OnClickCallBack) //需要回调 Cell点击函数时用此 Init() 5 | //刷新列表: 6 | // ShowList(数量格式: string = "5|5|6") 7 | //回调: 8 | //Func(GameObject = 收展按钮, GameObject = Cell, int = 收展按钮索引 Index, int = 子cell索引) 9 | //OnClickCell(GameObject = Cell, int = Index) //点击Cell 10 | 11 | using System; 12 | using System.Collections.Generic; 13 | using UnityEngine; 14 | using UnityEngine.UI; 15 | using WenRuo; 16 | 17 | namespace WenRuo 18 | { 19 | public class ExpandableView : RecycleView 20 | { 21 | public GameObject m_ExpandButton; 22 | public float m_BackgroundMargin; 23 | public bool m_IsExpand = false; 24 | 25 | private float m_ExpandButtonX; 26 | private float m_ExpandButtonY; 27 | private float m_ExpandButtonWidth; 28 | private float m_ExpandButtonHeight; 29 | 30 | private Vector2 m_BackgroundOriginSize; 31 | 32 | //展开信息 33 | struct ExpandInfo 34 | { 35 | public GameObject button; 36 | public bool isExpand; 37 | public CellInfo[] cellInfos; 38 | public float size; 39 | public int cellCount; 40 | } 41 | 42 | private ExpandInfo[] m_ExpandInfos = null; 43 | 44 | private Dictionary m_IsAddedListener = new Dictionary(); //用于 判断是否重复添加 点击事件 45 | 46 | private new Action m_FuncCallBackFunc; 47 | protected new Action m_FuncOnClickCallBack; 48 | 49 | public void Init(Action callBack) 50 | { 51 | Init(callBack, null); 52 | } 53 | 54 | public void Init(Action callBack, 55 | Action onClickCallBack, 56 | Action onButtonClickCallBack) 57 | { 58 | FuncOnButtonClickCallBack = onButtonClickCallBack; 59 | Init(callBack, onClickCallBack); 60 | } 61 | 62 | public void Init(Action callBack, 63 | Action onClickCallBack) 64 | { 65 | base.Init(null, null); 66 | 67 | m_FuncCallBackFunc = callBack; 68 | 69 | /* Button 处理 */ 70 | if (m_ExpandButton == null) 71 | { 72 | if (content.transform.Find("Button") != null) 73 | { 74 | m_ExpandButton = content.transform.Find("Button").gameObject; 75 | } 76 | } 77 | 78 | if (m_ExpandButton != null) 79 | { 80 | RectTransform rectTrans = m_ExpandButton.transform.GetComponent(); 81 | m_ExpandButtonX = rectTrans.anchoredPosition.x; 82 | m_ExpandButtonY = rectTrans.anchoredPosition.y; 83 | 84 | SetPoolsButtonObj(m_ExpandButton); 85 | 86 | m_ExpandButtonWidth = rectTrans.rect.width; 87 | m_ExpandButtonHeight = rectTrans.rect.height; 88 | 89 | var background = m_ExpandButton.transform.Find("background"); 90 | if (background != null) 91 | { 92 | m_BackgroundOriginSize = background.GetComponent().sizeDelta; 93 | } 94 | } 95 | } 96 | 97 | public override void ShowList(string numStr) 98 | { 99 | ClearCell(); //清除所有Cell (非首次调Showlist时执行) 100 | 101 | int totalCount = 0; 102 | 103 | int beforeCellCount = 0; 104 | 105 | string[] numArray = numStr.Split('|'); 106 | int buttonCount = numArray.Length; 107 | 108 | bool isReset; 109 | if (isInited && m_ExpandInfos.Length == buttonCount) 110 | { 111 | isReset = false; 112 | } 113 | else 114 | { 115 | m_ExpandInfos = new ExpandInfo[buttonCount]; 116 | isReset = true; 117 | } 118 | 119 | for (int k = 0; k < buttonCount; k++) 120 | { 121 | //-> Button 物体处理 122 | GameObject button = GetPoolsButtonObj(); 123 | button.name = k.ToString(); 124 | Button buttonComponent = button.GetComponent