初始化工程

This commit is contained in:
2025-07-15 15:33:35 +08:00
parent ead49da3e8
commit bbd78128d0
301 changed files with 23953 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: b32bd69d879747c8bdf5a3e8c313560c
timeCreated: 1752544984

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 7ae98d1b6ba74880a5bdbd3cefd09faa
timeCreated: 1752544970

View File

@@ -0,0 +1,30 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using Luban;
namespace cfg
{
public partial class Tables
{
public demo.Tbitem Tbitem {get; }
public Tables(System.Func<string, ByteBuf> loader)
{
Tbitem = new demo.Tbitem(loader("demo_tbitem"));
ResolveRef();
}
private void ResolveRef()
{
Tbitem.ResolveRef(this);
}
}
}

View File

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

View File

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

View File

@@ -0,0 +1,52 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using Luban;
namespace cfg.demo
{
public partial class Tbitem
{
private readonly System.Collections.Generic.Dictionary<int, demo.item> _dataMap;
private readonly System.Collections.Generic.List<demo.item> _dataList;
public Tbitem(ByteBuf _buf)
{
_dataMap = new System.Collections.Generic.Dictionary<int, demo.item>();
_dataList = new System.Collections.Generic.List<demo.item>();
for(int n = _buf.ReadSize() ; n > 0 ; --n)
{
demo.item _v;
_v = global::cfg.demo.item.Deserializeitem(_buf);
_dataList.Add(_v);
_dataMap.Add(_v.Id, _v);
}
}
public System.Collections.Generic.Dictionary<int, demo.item> DataMap => _dataMap;
public System.Collections.Generic.List<demo.item> DataList => _dataList;
public demo.item GetOrDefault(int key) => _dataMap.TryGetValue(key, out var v) ? v : null;
public demo.item Get(int key) => _dataMap[key];
public demo.item this[int key] => _dataMap[key];
public void ResolveRef(Tables tables)
{
foreach(var _v in _dataList)
{
_v.ResolveRef(tables);
}
}
}
}

View File

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

View File

@@ -0,0 +1,65 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using Luban;
namespace cfg.demo
{
public sealed partial class item : Luban.BeanBase
{
public item(ByteBuf _buf)
{
Id = _buf.ReadInt();
Name = _buf.ReadString();
Desc = _buf.ReadString();
Count = _buf.ReadInt();
}
public static item Deserializeitem(ByteBuf _buf)
{
return new demo.item(_buf);
}
/// <summary>
/// id
/// </summary>
public readonly int Id;
/// <summary>
/// 名称
/// </summary>
public readonly string Name;
/// <summary>
/// 描述
/// </summary>
public readonly string Desc;
/// <summary>
/// 个数
/// </summary>
public readonly int Count;
public const int __ID__ = 750578750;
public override int GetTypeId() => __ID__;
public void ResolveRef(Tables tables)
{
}
public override string ToString()
{
return "{ "
+ "id:" + Id + ","
+ "name:" + Name + ","
+ "desc:" + Desc + ","
+ "count:" + Count + ","
+ "}";
}
}
}

View File

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

View File

@@ -0,0 +1,45 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using Luban;
namespace cfg
{
public partial struct vector2
{
public vector2(ByteBuf _buf)
{
X = _buf.ReadFloat();
Y = _buf.ReadFloat();
}
public static vector2 Deserializevector2(ByteBuf _buf)
{
return new vector2(_buf);
}
public readonly float X;
public readonly float Y;
public void ResolveRef(Tables tables)
{
}
public override string ToString()
{
return "{ "
+ "x:" + X + ","
+ "y:" + Y + ","
+ "}";
}
}
}

View File

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

View File

@@ -0,0 +1,48 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using Luban;
namespace cfg
{
public partial struct vector3
{
public vector3(ByteBuf _buf)
{
X = _buf.ReadFloat();
Y = _buf.ReadFloat();
Z = _buf.ReadFloat();
}
public static vector3 Deserializevector3(ByteBuf _buf)
{
return new vector3(_buf);
}
public readonly float X;
public readonly float Y;
public readonly float Z;
public void ResolveRef(Tables tables)
{
}
public override string ToString()
{
return "{ "
+ "x:" + X + ","
+ "y:" + Y + ","
+ "z:" + Z + ","
+ "}";
}
}
}

View File

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

View File

@@ -0,0 +1,51 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using Luban;
namespace cfg
{
public partial struct vector4
{
public vector4(ByteBuf _buf)
{
X = _buf.ReadFloat();
Y = _buf.ReadFloat();
Z = _buf.ReadFloat();
W = _buf.ReadFloat();
}
public static vector4 Deserializevector4(ByteBuf _buf)
{
return new vector4(_buf);
}
public readonly float X;
public readonly float Y;
public readonly float Z;
public readonly float W;
public void ResolveRef(Tables tables)
{
}
public override string ToString()
{
return "{ "
+ "x:" + X + ","
+ "y:" + Y + ","
+ "z:" + Z + ","
+ "w:" + W + ","
+ "}";
}
}
}

View File

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

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 5a8878e677b5471ab41dd9aa5de372cc
timeCreated: 1752544999

View File

@@ -0,0 +1,8 @@
namespace CreatGame
{
public class GameLogic
{
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 8bed5572501d4f149c84589085bec321
timeCreated: 1752463362

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 341fa7946cf046c1ae980f1f3efabbda
timeCreated: 1752547061

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 12e2e1bf012c4e74951a89b77d46f08c
timeCreated: 1752547082

View File

@@ -0,0 +1,101 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.AddressableAssets.ResourceLocators;
using UnityEngine.ResourceManagement.ResourceLocations;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine.ResourceManagement.ResourceProviders;
public class AddressableUpdater : MonoBehaviour
{
public string remoteCatalogUrl; // CDN catalog 路径
public Action<float> OnProgressChanged; // 进度更新回调 0~1
public Action<float> OnSpeedChanged; // 下载速度更新 (KB/s)
public Action<float> OnDownloadSizeFetched; // 总下载大小回调 (MB)
public Action OnCompleted; // 下载完成
private float lastDownloadedBytes = 0;
private float updateCheckInterval = 0.5f;
void Start()
{
StartCoroutine(UpdateAddressables());
}
IEnumerator UpdateAddressables()
{
// 1. 初始化 Addressables
var initHandle = Addressables.InitializeAsync();
yield return initHandle;
// 2. 更新 Catalog
var catalogHandle = Addressables.UpdateCatalogs();
yield return catalogHandle;
List<IResourceLocator> catalogs = catalogHandle.Result;
// 3. 获取资源下载大小
var sizeHandle = Addressables.GetDownloadSizeAsync(Addressables.ResourceManager.ResourceProviders);
yield return sizeHandle;
long totalDownloadSize = sizeHandle.Result;
if (totalDownloadSize <= 0)
{
Debug.Log("无需更新");
OnCompleted?.Invoke();
yield break;
}
OnDownloadSizeFetched?.Invoke(totalDownloadSize / (1024f * 1024f)); // MB
// 4. 开始下载所有资源
var downloadHandle = Addressables.DownloadDependenciesAsync(Addressables.ResourceManager.ResourceProviders, true);
StartCoroutine(TrackDownloadProgress(downloadHandle, totalDownloadSize));
yield return downloadHandle;
if (downloadHandle.Status == AsyncOperationStatus.Succeeded)
{
Debug.Log("热更完成!");
OnCompleted?.Invoke();
}
else
{
Debug.LogError("热更失败!");
}
}
IEnumerator TrackDownloadProgress(AsyncOperationHandle handle, long totalSize)
{
float lastTime = Time.realtimeSinceStartup;
float lastDownloaded = 0;
while (!handle.IsDone)
{
float percent = handle.PercentComplete;
OnProgressChanged?.Invoke(percent);
float currentTime = Time.realtimeSinceStartup;
float elapsed = currentTime - lastTime;
if (elapsed >= updateCheckInterval)
{
float currentDownloaded = percent * totalSize;
float speed = (currentDownloaded - lastDownloaded) / elapsed / 1024f; // KB/s
OnSpeedChanged?.Invoke(speed);
lastTime = currentTime;
lastDownloaded = currentDownloaded;
}
yield return null;
}
OnProgressChanged?.Invoke(1f);
OnSpeedChanged?.Invoke(0);
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 2bbf6478f2ed4dd0ac123f2a03fe3695
timeCreated: 1752549280

View File

@@ -0,0 +1,13 @@
namespace CreatGame.AssetBundle
{
public class AssetBundleManager : Singleton<AssetBundleManager>
{
/// <summary>
/// 需要初始化Addressble系统
/// </summary>
public AssetBundleManager()
{
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 01bfbdbb68f24f39bf248e1ce2907783
timeCreated: 1752547273

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 726911973e4b4b129678928347fc1de4
timeCreated: 1752547090

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 8f912db237c54e96b83e9c11a7ab6889
timeCreated: 1752547100

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: f208809c54934f6f911cc29d97c3519a
timeCreated: 1752550099

View File

@@ -0,0 +1,13 @@
namespace CreatGame.UI
{
/// <summary>
/// 窗口层级
/// </summary>
public enum UILayer
{
Main,
Popup,
Notify,
System,
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: a02dc47e9bb442079f60800e51c49b6e
timeCreated: 1752551035

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 0631ad95508b427c96e7748c13e0eb59
timeCreated: 1752550115

View File

@@ -0,0 +1,16 @@
using System.Collections.Generic;
namespace CreatGame.UI
{
public class UIManager : Singleton<UIManager>
{
private Dictionary<UILayer, Queue<UIViewBase>> m_Windows;
/// <summary>
///
/// </summary>
public UIManager()
{
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: b62361e051d040d696ac9c2485f57a3b
timeCreated: 1752550917

View File

@@ -0,0 +1,7 @@
namespace CreatGame.UI
{
public class UIViewBase
{
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: f48b029bf9fe4664a47a4ede05f4d396
timeCreated: 1752550141