You've already forked taptap2024_GJ_chidouren
init
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace IcecreamView
|
||||
{
|
||||
[CreateAssetMenu(fileName = "IC_GlobalSetting", menuName = "IceCreamView/GlobalSetting")]
|
||||
public class IC_GlobalSetting : ScriptableObject
|
||||
{
|
||||
[Header("命名空间")] public string NameSpacePath = "View";
|
||||
[Header("代码生成路径")] public string FilePath = "Scripts/View";
|
||||
[Header("预制体保存路径")] public string PrefabsPath = "Resources/View";
|
||||
[Header("继承类")] public string AbstractClass = "IcecreamView.IC_AbstractModule";
|
||||
public string AssemblyName = "Assembly-CSharp";
|
||||
#if UNITY_EDITOR
|
||||
[Header("UI场景")]public SceneAsset UiSceneAsset;
|
||||
#endif
|
||||
[Header("自定义UI控件配置表")] public List<CustomUIConfig> CustomUIConfigs;
|
||||
[Header("自定义UI页面配置表")] public List<CustomUIPanelConfig> CustomPanelConfigs;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class CustomUIConfig
|
||||
{
|
||||
// [HorizontalGroup("Box")]
|
||||
[HorizontalGroup("Prefab", 55), PropertyOrder(-1)]
|
||||
[PreviewField(50, Sirenix.OdinInspector.ObjectFieldAlignment.Left), HideLabel]
|
||||
public CustomUIConnector Prefab;
|
||||
[BoxGroup("Prefab/info"), LabelText("UI控件名称")]
|
||||
public string Name;
|
||||
[BoxGroup("Prefab/info"), LabelText("UI控件描述")]
|
||||
public string Desc;
|
||||
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class CustomUIPanelConfig
|
||||
{
|
||||
// [HorizontalGroup("Box")]
|
||||
[HorizontalGroup("Prefab", 55), PropertyOrder(-1)]
|
||||
[PreviewField(50, Sirenix.OdinInspector.ObjectFieldAlignment.Left), HideLabel]
|
||||
public IcecreamView.IC_ModuleConnector Prefab;
|
||||
[BoxGroup("Prefab/info"), LabelText("页面名称")]
|
||||
public string Name;
|
||||
[BoxGroup("Prefab/info"), LabelText("页面描述")]
|
||||
public string Desc;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1badf54a3ca64034bdd3fdf4100c8202
|
||||
timeCreated: 1588251654
|
||||
@@ -0,0 +1,21 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace IcecreamView {
|
||||
public interface IC_IViewConfig
|
||||
{
|
||||
void OnInit();
|
||||
|
||||
string GetDefaultViewTable();
|
||||
|
||||
bool ContainsKey(string viewTable);
|
||||
|
||||
List<string> GetCacheTables();
|
||||
|
||||
IC_IViewInfo OnAddView(string viewTable);
|
||||
|
||||
void OnRemoveView(IC_AbstractView view);
|
||||
|
||||
void OnDispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a3b4639ae73b9f740a4fb233227a3b4d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,11 @@
|
||||
|
||||
namespace IcecreamView {
|
||||
public interface IC_IViewInfo
|
||||
{
|
||||
string GetTable();
|
||||
bool IsOnce();
|
||||
bool IsCache();
|
||||
IC_AbstractView GetView();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8eee9fefcf41d154c9ca69c2c1a66ccf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,69 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
namespace IcecreamView {
|
||||
|
||||
[CreateAssetMenu(fileName = "IC_Resource_ViewConfig", menuName = "IceCreamView/IceView Config(Resource link)", order = 89)]
|
||||
public class IC_Resource_ViewConfig : ScriptableObject, IC_IViewConfig
|
||||
{
|
||||
[Header("UI预制体相对Resources下的根目录")]
|
||||
public string ResourceViewPath;
|
||||
|
||||
[Header("默认打开页面")]
|
||||
public string DefaultView;
|
||||
|
||||
[Header("需要复用View白名单(关闭View后不会销毁,类似对象池存储)")]
|
||||
public List<string> persistenceList = new List<string>();
|
||||
|
||||
private Dictionary<string, IC_IViewInfo> mViewDic;
|
||||
|
||||
public bool ContainsKey(string viewTable)
|
||||
{
|
||||
if (mViewDic.ContainsKey(viewTable))
|
||||
return true;
|
||||
var view = Resources.Load<IC_AbstractView>(ResourceViewPath + viewTable);
|
||||
if (view != null)
|
||||
{
|
||||
var viewInfo = new IC_ViewInfo() { autoLoad = this.persistenceList.Contains(viewTable) , isOnce = !persistenceList.Contains(viewTable) , Table = viewTable , View = view};
|
||||
mViewDic.Add(viewTable , viewInfo);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<string> GetCacheTables()
|
||||
{
|
||||
return this.persistenceList;
|
||||
}
|
||||
|
||||
public string GetDefaultViewTable()
|
||||
{
|
||||
if(string.IsNullOrEmpty(DefaultView))
|
||||
return null;
|
||||
return DefaultView;
|
||||
}
|
||||
|
||||
public IC_IViewInfo OnAddView(string viewTable)
|
||||
{
|
||||
return mViewDic[viewTable];
|
||||
}
|
||||
|
||||
public void OnRemoveView(IC_AbstractView view)
|
||||
{
|
||||
GameObject.Destroy(view.gameObject);
|
||||
}
|
||||
|
||||
public void OnDispose()
|
||||
{
|
||||
mViewDic.Clear();
|
||||
Resources.UnloadUnusedAssets();
|
||||
System.GC.Collect();
|
||||
}
|
||||
|
||||
public void OnInit()
|
||||
{
|
||||
mViewDic = new Dictionary<string, IC_IViewInfo>();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 628ff49fd857e0b4cb7f99680f51b40b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,123 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
namespace IcecreamView {
|
||||
|
||||
[System.Serializable]
|
||||
public class IC_ViewInfo : IC_IViewInfo{
|
||||
|
||||
public IC_AbstractView View;
|
||||
[Header("可选填,默认为View预制体名称")]
|
||||
public string Table;
|
||||
[Header("是否提前缓存(用于大型View)")]
|
||||
public bool autoLoad;
|
||||
[Header("是否作为一次性使用,当页面被关闭时直接销毁")]
|
||||
public bool isOnce;
|
||||
|
||||
public string GetTable()
|
||||
{
|
||||
return Table;
|
||||
}
|
||||
|
||||
public bool IsCache()
|
||||
{
|
||||
return autoLoad;
|
||||
}
|
||||
|
||||
public IC_AbstractView GetView()
|
||||
{
|
||||
return View;
|
||||
}
|
||||
|
||||
public bool IsOnce()
|
||||
{
|
||||
return isOnce;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 游戏View配置表
|
||||
/// </summary>
|
||||
[CreateAssetMenu(fileName = "IC_ViewConfig" , menuName = "IceCreamView/IceView Config(Prefabs link)" , order = 88)]
|
||||
public class IC_ViewConfig : ScriptableObject , IC_IViewConfig
|
||||
{
|
||||
|
||||
public string ConfigName;
|
||||
|
||||
public string DefaultViewTable;
|
||||
|
||||
public List<IC_ViewInfo> GameViewList;
|
||||
|
||||
private Dictionary<string, IC_IViewInfo> mViewDic;
|
||||
|
||||
public void OnInit()
|
||||
{
|
||||
Debug.Log("Init ViewConfig : " + ConfigName);
|
||||
mViewDic = new Dictionary<string, IC_IViewInfo>();
|
||||
mViewDic = GetViewModleDic();
|
||||
}
|
||||
|
||||
public Dictionary<string, IC_IViewInfo> GetViewModleDic()
|
||||
{
|
||||
Dictionary<string, IC_IViewInfo> viewDic = new Dictionary<string, IC_IViewInfo>();
|
||||
|
||||
if (GameViewList != null && GameViewList.Count > 0)
|
||||
{
|
||||
GameViewList.ForEach(view =>
|
||||
{
|
||||
if (string.IsNullOrEmpty(view.Table))
|
||||
{
|
||||
view.Table = view.View.name;
|
||||
}
|
||||
if (!viewDic.ContainsKey(view.Table))
|
||||
{
|
||||
viewDic.Add(view.Table, view);
|
||||
}
|
||||
else {
|
||||
Debug.LogError("[IceCreamView] View数据出现重名数据:" + view.Table);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
return viewDic;
|
||||
}
|
||||
|
||||
public string GetDefaultViewTable()
|
||||
{
|
||||
return DefaultViewTable;
|
||||
}
|
||||
|
||||
public bool ContainsKey(string viewTable)
|
||||
{
|
||||
return mViewDic.ContainsKey(viewTable);
|
||||
}
|
||||
|
||||
public List<string> GetCacheTables()
|
||||
{
|
||||
List<string> tableList = new List<string>();
|
||||
foreach (IC_ViewInfo IcViewInfo in GameViewList)
|
||||
{
|
||||
if (IcViewInfo.autoLoad)
|
||||
{
|
||||
tableList.Add(IcViewInfo.Table);
|
||||
}
|
||||
}
|
||||
return tableList;
|
||||
}
|
||||
|
||||
public IC_IViewInfo OnAddView(string viewTable)
|
||||
{
|
||||
return mViewDic[viewTable];
|
||||
}
|
||||
|
||||
public void OnRemoveView(IC_AbstractView view)
|
||||
{
|
||||
GameObject.Destroy(view.gameObject);
|
||||
}
|
||||
|
||||
public void OnDispose()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9dd6fc253e125ee4e8c3efae89432f15
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,109 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace IcecreamView
|
||||
{
|
||||
public class IC_ViewConfigGroup : IC_IViewConfig
|
||||
{
|
||||
private List<IC_IViewConfig> _configs;
|
||||
|
||||
|
||||
public IC_ViewConfigGroup ()
|
||||
{
|
||||
OnInit ();
|
||||
}
|
||||
|
||||
public void OnInit ()
|
||||
{
|
||||
this._configs = new List<IC_IViewConfig> ();
|
||||
}
|
||||
|
||||
public bool AddConfig (IC_IViewConfig config)
|
||||
{
|
||||
if (_configs.Contains (config) == false)
|
||||
{
|
||||
this._configs.Add (config);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void RemoveConfig (IC_IViewConfig config)
|
||||
{
|
||||
this._configs.Remove (config);
|
||||
config.OnDispose ();
|
||||
}
|
||||
|
||||
public string GetDefaultViewTable ()
|
||||
{
|
||||
if (this._configs.Count > 0)
|
||||
{
|
||||
return this._configs[^1].GetDefaultViewTable ();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool ContainsKey (string viewTable)
|
||||
{
|
||||
foreach (var config in this._configs)
|
||||
{
|
||||
if (config.ContainsKey (viewTable))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public bool TryContainsKeyConfig (string viewTable, out IC_IViewConfig config)
|
||||
{
|
||||
foreach (var c in this._configs)
|
||||
{
|
||||
if (c.ContainsKey (viewTable))
|
||||
{
|
||||
config = c;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
config = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<string> GetCacheTables ()
|
||||
{
|
||||
List<string> tables = new List<string> ();
|
||||
foreach (var config in this._configs)
|
||||
{
|
||||
tables.AddRange (config.GetCacheTables ());
|
||||
}
|
||||
return tables;
|
||||
}
|
||||
|
||||
|
||||
public IC_IViewInfo OnAddView (string viewTable)
|
||||
{
|
||||
throw new System.NotImplementedException ();
|
||||
}
|
||||
|
||||
public void OnRemoveView (IC_AbstractView view)
|
||||
{
|
||||
foreach (var config in this._configs)
|
||||
{
|
||||
if (config.GetHashCode () == view._configID)
|
||||
{
|
||||
config.OnRemoveView (view);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OnDispose ()
|
||||
{
|
||||
foreach (var config in this._configs)
|
||||
{
|
||||
config.OnDispose ();
|
||||
}
|
||||
this._configs.Clear ();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 37c69d0bb73d4652b6f6f61207031437
|
||||
timeCreated: 1716797150
|
||||
Reference in New Issue
Block a user