UGUI导出工具

This commit is contained in:
2025-07-16 13:36:21 +08:00
parent 9c65b58134
commit 60c1185b87
20 changed files with 1726 additions and 31 deletions

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 48f786d98d3d1d24296e6825756cf55a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,8 +1,11 @@
namespace CreatGame
{
public class GameLogic
public class GameLogic : Singleton<GameLogic>
{
public void Start()
{
AssetBundle.AssetBundleManager.Instance.Initialize();
}
}
}

View File

@@ -1,4 +1,11 @@
namespace CreatGame.AssetBundle
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.AddressableAssets.ResourceLocators;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine.ResourceManagement.ResourceLocations;
namespace CreatGame.AssetBundle
{
public class AssetBundleManager : Singleton<AssetBundleManager>
{
@@ -7,7 +14,47 @@
/// </summary>
public AssetBundleManager()
{
Addressables.InitializeAsync();
}
public void Initialize()
{
Addressables.InitializeAsync().Completed += OnInitializeCompleted;
}
/// <summary>
/// 初始化信息回调
/// </summary>
private void OnInitializeCompleted(AsyncOperationHandle<IResourceLocator> operationHandle)
{
if (operationHandle.Status == AsyncOperationStatus.Succeeded)
{
Debug.Log("Addressables initialization succeeded");
#region MyRegion
// IResourceLocator locator = operationHandle.Result;
// foreach (object locatorKey in locator.Keys)
// {
// locator.Locate(locatorKey,typeof(UnityEngine.Object),out IList<IResourceLocation> locations);
// if (locations == null)
// {
// continue;
// }
//
// foreach (var location in locations)
// {
// string key = location.PrimaryKey;
// Addressables.LoadAssetAsync<UnityEngine.Object>(key).Completed += (handle) =>
// {
// if (handle.Status == AsyncOperationStatus.Succeeded)
// {
// Debug.Log("Addressables load asset succeeded");
// var asset = handle.Result;
// GameObject.Instantiate(asset);
// }
// };
// }
// }
#endregion
}
}
}
}

View File

@@ -1,15 +1,34 @@
using System.Collections.Generic;
using UnityEngine;
namespace CreatGame.UI
{
public class UIManager : Singleton<UIManager>
{
private Dictionary<UILayer,GameObject> m_UILayers;
private Dictionary<UILayer, Queue<UIViewBase>> m_Windows;
/// <summary>
///
/// </summary>
public UIManager()
{
m_UILayers = new Dictionary<UILayer, GameObject>();
m_Windows = new Dictionary<UILayer, Queue<UIViewBase>>();
}
/// <summary>
///
/// </summary>
/// <param name="layer"></param>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public UIViewBase OpenView<T>(UILayer layer) where T : UIViewBase , new()
{
var view = new T();
view.PreLoad();
view.InitView();
return view;
}
}
}

View File

@@ -2,6 +2,29 @@
{
public class UIViewBase
{
/// <summary>
/// 预制件的路径
/// </summary>
public virtual string PrefabPath { get; set; }
/// <summary>
/// 加载窗口的时候需要预先加载的东西
/// </summary>
public virtual void PreLoad()
{
}
/// <summary>
/// 初始化界面
/// </summary>
public virtual void InitView()
{
}
/// <summary>
/// 关闭窗口的时候的调用
/// </summary>
public virtual void CloseView()
{
}
}
}

View File

@@ -8,7 +8,7 @@ public class GameStar : MonoBehaviour
// Start is called before the first frame update
void Start()
{
CreatGame.GameLogic.Instance.Start();
}
// Update is called once per frame

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 07fbcc20f70d4d90bce50c964419e32d
timeCreated: 1752636609

View File

@@ -0,0 +1,16 @@
using System;
using UnityEngine;
using System.Collections.Generic;
public class UIExportTool : MonoBehaviour
{
[Serializable]
public class UIEntry
{
public string key;
public GameObject prefab;
public string selectedComponentName; // 存储选择的组件类型名
}
public List<UIEntry> entries = new List<UIEntry>();
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d7f07a01cdb5c7c4aa72a3a420035842
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: