UGUI导出工具
This commit is contained in:
8
UnityGame/Assets/Scripts/GameLogic/Export/UGUI.meta
Normal file
8
UnityGame/Assets/Scripts/GameLogic/Export/UGUI.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 48f786d98d3d1d24296e6825756cf55a
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +1,11 @@
|
||||
namespace CreatGame
|
||||
{
|
||||
public class GameLogic
|
||||
public class GameLogic : Singleton<GameLogic>
|
||||
{
|
||||
|
||||
public void Start()
|
||||
{
|
||||
AssetBundle.AssetBundleManager.Instance.Initialize();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user