| | |
| | | |
| | | public virtual void Init<T>(List<T> _datas, bool _stepByStep = false) |
| | | { |
| | | if (_datas == null) |
| | | if (_datas == null || _datas.Count == 0) |
| | | { |
| | | this.SetActive(false); |
| | | return; |
| | |
| | | |
| | | private void Arrange(Align _align) |
| | | { |
| | | if (infiniteItems.Count == 0) |
| | | return; |
| | | |
| | | var head = infiniteItems[0]; |
| | | |
| | | var offset1 = Vector2.zero; |
| | |
| | | |
| | | void OnEnable() |
| | | { |
| | | ExecuteNextFrame(); |
| | | ExecuteNextFrame().Forget(); |
| | | } |
| | | |
| | | protected async void ExecuteNextFrame() |
| | | protected async UniTask ExecuteNextFrame() |
| | | { |
| | | await UniTask.DelayFrame(1); |
| | | UpdateAllButtonsState(); |
| | |
| | | private void UpdateAllButtonsState() |
| | | { |
| | | // SortBtns(); |
| | | if (this == null || m_Buttons == null) |
| | | return; |
| | | |
| | | foreach (var btn in m_Buttons) |
| | | { |
| | |
| | | using System.Collections.Generic; |
| | | using System.Collections.Generic; |
| | | using Cysharp.Threading.Tasks; |
| | | using UnityEngine; |
| | | |
| | |
| | | |
| | | currentWindow = targetPopup; |
| | | popupWindowQueue.RemoveAt(targetIndex); |
| | | UIManager.Instance.OpenWindow(currentWindow.window, currentWindow.functionId).Forget(); |
| | | UIManager.Instance.OpenWindowAsync(currentWindow.window, currentWindow.functionId).Forget(); |
| | | Debug.LogFormat("推送窗口 " + currentWindow.window); |
| | | |
| | | lastTime = Time.realtimeSinceStartup; |
| | |
| | | instance = find.gameObject; |
| | | return; |
| | | } |
| | | instance = await UIUtility.CreateWidget(prefabName, prefabName); |
| | | if (this == null || instance == null) |
| | | var inst = await UIUtility.CreateWidget(prefabName, prefabName); |
| | | if (this == null || inst == null) |
| | | { |
| | | if (null != instance) |
| | | { |
| | | DestroyImmediate(instance); |
| | | } |
| | | if (null != inst) DestroyImmediate(inst); |
| | | return; |
| | | } |
| | | if (instance != null) |
| | | { |
| | | DestroyImmediate(inst); |
| | | return; |
| | | } |
| | | instance = inst; |
| | | instance.transform.SetParentEx(this.transform, Vector3.zero, Quaternion.identity, Vector3.one); |
| | | } |
| | | |
| | |
| | | this.SetSprite(m_IconKey); |
| | | } |
| | | } |
| | | |
| | | protected override void OnEnable() |
| | | { |
| | | base.OnEnable(); |
| | | |
| | | #if UNITY_EDITOR |
| | | if (material != null) |
| | | { |
| | | material.shader = Shader.Find(material.shader.name); |
| | | } |
| | | #endif |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | public override string text |
| | | { |
| | | get { return base.text; } |
| | | set |
| | | { |
| | | if (value != base.text) |
| | | { |
| | | base.text = value; |
| | | |
| | | #if UNITY_EDITOR |
| | | if (material != null) |
| | | { |
| | | material.shader = Shader.Find(material.shader.name); |
| | | } |
| | | #endif |
| | | } |
| | | } |
| | | } |
| | | |
| | | [SerializeField] |
| | | private BackGroundColorType m_BGColorType = BackGroundColorType.Dark; |
| | | public BackGroundColorType bgColorType |
| | |
| | | |
| | | private void OnAlphaChanged() |
| | | { |
| | | if (spineComp != null) |
| | | if (spineComp != null && spineComp.Skeleton != null) |
| | | { |
| | | var skeleton = spineComp.Skeleton; |
| | | skeleton.A = Alpha; |
| | |
| | | } |
| | | } |
| | | |
| | | public virtual async void Play(bool showLog = true) |
| | | public virtual async UniTask Play(bool showLog = true) |
| | | { |
| | | if (!isInit) |
| | | { |
| | |
| | | // { |
| | | // spineComp.material = null; |
| | | // } |
| | | ResManager.Instance.LoadAssetAsync<Material>("Materials", "SkeletonGraphicDefault-Straight").ContinueWith(material => |
| | | var material = await ResManager.Instance.LoadAssetAsync<Material>("Materials", "SkeletonGraphicDefault-Straight"); |
| | | if (material != null) |
| | | { |
| | | if (material != null) |
| | | { |
| | | spineComp.material = material; |
| | | } |
| | | else |
| | | { |
| | | Debug.LogError("Failed to load material for Spine effect: " + effectConfig.fxName); |
| | | } |
| | | }).Forget(); |
| | | spineComp.material = material; |
| | | #if UNITY_WEBGL && !UNITY_EDITOR |
| | | Debug.Log($"[SpineEffect][WebGL] effectId={effectConfig.id} fxName={effectConfig.fxName}" + |
| | | $" mat={material.name} shader={material.shader.name}" + |
| | | $" straightAlpha={material.IsKeywordEnabled("_STRAIGHT_ALPHA_INPUT")}" + |
| | | $" canvasGroup={material.IsKeywordEnabled("_CANVAS_GROUP_COMPATIBLE")}" + |
| | | $" pmaVert={spineComp.MeshGenerator.settings.pmaVertexColors}"); |
| | | #endif |
| | | } |
| | | else |
| | | { |
| | | Debug.LogError("Failed to load material for Spine effect: " + effectConfig.fxName); |
| | | } |
| | | |
| | | spineAnimationState = spineComp.AnimationState; |
| | | spineAnimationState.TimeScale = speedRate; |
| | |
| | | spineComp.enabled = true; |
| | | PlayerTheSpineAnim(); |
| | | SoundPlayer.Instance.PlayUIAudioDelay(effectConfig.audio).Forget(); |
| | | |
| | | #if UNITY_EDITOR |
| | | // 编辑器模式下强制刷新材质球,解决部分特效不显示问题 |
| | | await UniTask.Delay(100); |
| | | if (spineComp != null && this != null && spineComp.material != null) |
| | | { |
| | | spineComp.material.shader = Shader.Find(spineComp.material.shader.name); |
| | | } |
| | | #endif |
| | | } |
| | | |
| | | // 播放指定动画 |
| | |
| | | /// </summary> |
| | | private void CreateMaskMaterial() |
| | | { |
| | | #if !UNITY_EDITOR |
| | | if (m_MaskMaterial == null) |
| | | { |
| | | ResManager.Instance.LoadAssetAsync<Shader>("Shader", "GUI_EllipseMask").ContinueWith(ellipseShader => |
| | |
| | | } |
| | | }).Forget(); |
| | | } |
| | | #else |
| | | if (m_MaskMaterial == null) |
| | | { |
| | | m_MaskMaterial = new Material(Shader.Find("GUI/EllipseMask")); |
| | | } |
| | | #endif |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | { |
| | | if (graphic.material == null || !graphic.material.shader.name.Contains("EllipseMaskedContent")) |
| | | { |
| | | |
| | | #if !UNITY_EDITOR |
| | | // Shader maskedShader = Shader.Find("GUI/EllipseMaskedContent"); |
| | | ResManager.Instance.LoadAssetAsync<Shader>("Shader", "GUI_EllipseMaskedContent").ContinueWith(maskedShader => |
| | | { |
| | |
| | | graphic.material = maskedMaterial; |
| | | } |
| | | }).Forget(); |
| | | |
| | | #else |
| | | Shader maskedShader = Shader.Find("GUI/EllipseMaskedContent"); |
| | | if (maskedShader != null) |
| | | { |
| | | Material maskedMaterial = new Material(maskedShader); |
| | | maskedMaterial.SetInt("_Stencil", m_StencilID); |
| | | maskedMaterial.SetInt("_StencilComp", 3); // Equal |
| | | graphic.material = maskedMaterial; |
| | | } |
| | | #endif |
| | | } |
| | | else |
| | | { |
| | |
| | | int iterator = 0;
|
| | | int totalConfigs = configTypes.Count;
|
| | |
|
| | | #if UNITY_WEBGL && !UNITY_EDITOR
|
| | | // ============================================================
|
| | | // WebGL 优化:两阶段加载
|
| | | // 阶段1: 一次性并发发起所有 TextAsset 加载(同 bundle 只下载一次)
|
| | | // 阶段2: 从内存中分批解析,每批 Yield 防止浏览器卡死
|
| | | // ============================================================
|
| | |
|
| | | // 阶段1: 并发加载所有配置文本到内存
|
| | | Debug.Log("[ConfigManager] WebGL 阶段1: 批量加载配置文件...");
|
| | | var configList = configTypes.ToList();
|
| | | var configDataMap = new Dictionary<Type, string[]>(totalConfigs);
|
| | | var loadTasks = new List<UniTask>(totalConfigs);
|
| | |
|
| | | foreach (var configType in configList)
|
| | | {
|
| | | var ct = configType; // closure capture
|
| | | loadTasks.Add(LoadConfigTextAsync(ct).ContinueWith(texts =>
|
| | | {
|
| | | if (texts != null)
|
| | | configDataMap[ct] = texts;
|
| | | else
|
| | | Debug.LogError($"找不到配置文件: {ct.Name}");
|
| | | }));
|
| | | }
|
| | | await UniTask.WhenAll(loadTasks);
|
| | | loadingProgress = 0.5f; // 网络加载完成 50%
|
| | | Debug.Log($"[ConfigManager] WebGL 阶段1完成: {configDataMap.Count}/{totalConfigs} 个配置已加载到内存");
|
| | |
|
| | | // 阶段2: 从内存中分批解析初始化
|
| | | const int parseBatchSize = 10;
|
| | | int parsed = 0;
|
| | | foreach (var configType in configList)
|
| | | {
|
| | | if (configDataMap.TryGetValue(configType, out var texts))
|
| | | {
|
| | | InitConfigFromTexts(configType, texts);
|
| | | }
|
| | | parsed++;
|
| | | loadingProgress = 0.5f + 0.5f * parsed / totalConfigs;
|
| | |
|
| | | // 每 parseBatchSize 个让出主线程
|
| | | if (parsed % parseBatchSize == 0)
|
| | | await UniTask.Yield();
|
| | | }
|
| | | #else
|
| | | List<UniTask> loadTasks = new List<UniTask>();
|
| | |
|
| | | // 逐个加载配置并更新进度
|
| | |
| | | sw.Stop();
|
| | | #endif
|
| | |
|
| | | loadingProgress = (float)(iterator++ + 1) / totalConfigs;
|
| | | loadingProgress = (float)(++iterator) / totalConfigs;
|
| | | });
|
| | |
|
| | | loadTasks.Add(uniTask);
|
| | |
| | | }
|
| | |
|
| | | await UniTask.WhenAll(loadTasks);
|
| | | #endif
|
| | |
|
| | | // 加载完成后设置isLoadFinished为true
|
| | | loadingProgress = 1f;
|
| | |
| | | ClearConfigDictionary<ZhanlingConfig>();
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 只加载配置文本,不做解析。用于 WebGL 批量预加载。
|
| | | /// </summary>
|
| | | private async UniTask<string[]> LoadConfigTextAsync(Type configType)
|
| | | {
|
| | | string configName = configType.Name;
|
| | | if (configName.EndsWith("Config"))
|
| | | configName = configName.Substring(0, configName.Length - 6);
|
| | | return await ResManager.Instance.LoadConfigAsync(configName);
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 从已加载的文本初始化配置(纯内存操作,无网络)。
|
| | | /// </summary>
|
| | | private void InitConfigFromTexts(Type configType, string[] texts)
|
| | | {
|
| | | var methodInfo = configType.GetMethod("Init",
|
| | | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.FlattenHierarchy);
|
| | | if (methodInfo != null)
|
| | | {
|
| | | methodInfo.Invoke(null, new object[] { texts });
|
| | | var isInitField = configType.GetField("isInit",
|
| | | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static);
|
| | | if (isInitField != null)
|
| | | isInitField.SetValue(null, true);
|
| | | }
|
| | | else
|
| | | {
|
| | | Debug.LogError($"配置类 {configType.Name} 没有静态Init方法");
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Text.RegularExpressions; |
| | | using Cysharp.Threading.Tasks; |
| | | using UnityEngine; |
| | | using System.Threading; |
| | | |
| | | public partial class DirtyNameConfig : ConfigBase<int, DirtyNameConfig> |
| | | { |
| | |
| | | } |
| | | |
| | | dirtyNameInited = true; |
| | | DirtyNameInitAsync().Forget(); |
| | | } |
| | | |
| | | ThreadPool.QueueUserWorkItem((object aaa) => |
| | | private static async UniTaskVoid DirtyNameInitAsync() |
| | | { |
| | | memoryList.Sort((string x, string y) => |
| | | { |
| | | memoryList.Sort((string x, string y) => |
| | | { |
| | | return x.CompareTo(y); |
| | | }); |
| | | for (int i = memoryList.Count - 1; i > 0; i--) |
| | | { |
| | | if (memoryList[i].ToString() == memoryList[i - 1].ToString()) |
| | | { |
| | | memoryList.RemoveAt(i); |
| | | } |
| | | } |
| | | foreach (string word in memoryList) |
| | | { |
| | | WordGroup group = DIRTYWORLD[(int)word[0]]; |
| | | if (group == null) |
| | | { |
| | | group = new WordGroup(); |
| | | DIRTYWORLD[(int)word[0]] = group; |
| | | } |
| | | group.Add(word.Substring(1)); |
| | | } |
| | | return x.CompareTo(y); |
| | | }); |
| | | await UniTask.Yield(); |
| | | for (int i = memoryList.Count - 1; i > 0; i--) |
| | | { |
| | | if (memoryList[i].ToString() == memoryList[i - 1].ToString()) |
| | | { |
| | | memoryList.RemoveAt(i); |
| | | } |
| | | } |
| | | await UniTask.Yield(); |
| | | int count = 0; |
| | | foreach (string word in memoryList) |
| | | { |
| | | WordGroup group = DIRTYWORLD[(int)word[0]]; |
| | | if (group == null) |
| | | { |
| | | group = new WordGroup(); |
| | | DIRTYWORLD[(int)word[0]] = group; |
| | | } |
| | | group.Add(word.Substring(1)); |
| | | count++; |
| | | if (count % 100 == 0) |
| | | await UniTask.Yield(); |
| | | } |
| | | } |
| | | |
| | | public static bool IsCHS(char character) |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Text.RegularExpressions; |
| | | using Cysharp.Threading.Tasks; |
| | | using UnityEngine; |
| | | using System.Threading; |
| | | |
| | | public partial class DirtyWordConfig : ConfigBase<int, DirtyWordConfig> |
| | | { |
| | |
| | | } |
| | | |
| | | dirtyWordInited = true; |
| | | DirtyWordInitAsync().Forget(); |
| | | } |
| | | |
| | | ThreadPool.QueueUserWorkItem((object aaa) => |
| | | private static async UniTaskVoid DirtyWordInitAsync() |
| | | { |
| | | memoryList.Sort((string x, string y) => |
| | | { |
| | | memoryList.Sort((string x, string y) => |
| | | { |
| | | return x.CompareTo(y); |
| | | }); |
| | | for (int i = memoryList.Count - 1; i > 0; i--) |
| | | { |
| | | if (memoryList[i].ToString() == memoryList[i - 1].ToString()) |
| | | { |
| | | memoryList.RemoveAt(i); |
| | | } |
| | | } |
| | | foreach (string word in memoryList) |
| | | { |
| | | WordGroup group = DIRTYWORLD[(int)word[0]]; |
| | | if (group == null) |
| | | { |
| | | group = new WordGroup(); |
| | | DIRTYWORLD[(int)word[0]] = group; |
| | | } |
| | | group.Add(word.Substring(1)); |
| | | } |
| | | return x.CompareTo(y); |
| | | }); |
| | | await UniTask.Yield(); |
| | | for (int i = memoryList.Count - 1; i > 0; i--) |
| | | { |
| | | if (memoryList[i].ToString() == memoryList[i - 1].ToString()) |
| | | { |
| | | memoryList.RemoveAt(i); |
| | | } |
| | | } |
| | | await UniTask.Yield(); |
| | | int count = 0; |
| | | foreach (string word in memoryList) |
| | | { |
| | | WordGroup group = DIRTYWORLD[(int)word[0]]; |
| | | if (group == null) |
| | | { |
| | | group = new WordGroup(); |
| | | DIRTYWORLD[(int)word[0]] = group; |
| | | } |
| | | group.Add(word.Substring(1)); |
| | | count++; |
| | | if (count % 100 == 0) |
| | | await UniTask.Yield(); |
| | | } |
| | | } |
| | | |
| | | public static bool IsCHS(char character) |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using Cysharp.Threading.Tasks; |
| | | using UnityEngine; |
| | | |
| | | |
| | |
| | | |
| | | private void AndroidCopyAsset() |
| | | { |
| | | switch (VersionConfig.Get().assetAccess) |
| | | VersionConfig.GetAsync().ContinueWith(config => |
| | | { |
| | | case InstalledAsset.FullAsset: |
| | | case InstalledAsset.HalfAsset: |
| | | case InstalledAsset.IngoreDownLoad: |
| | | if (!SDKUtils.Instance.AssetCopyFinished) |
| | | { |
| | | SDKUtils.Instance.CopyAsset(); |
| | | done = false; |
| | | progress = 0f; |
| | | } |
| | | else |
| | | { |
| | | done = true; |
| | | } |
| | | break; |
| | | case InstalledAsset.NullAsset: |
| | | done = true; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | private void IOSCopyAsset() |
| | | { |
| | | if (VersionUtility.Instance.versionInfo != null && VersionUtility.Instance.versionInfo.downAsset == 1) |
| | | { |
| | | switch (VersionConfig.Get().assetAccess) |
| | | switch (config.assetAccess) |
| | | { |
| | | case InstalledAsset.FullAsset: |
| | | case InstalledAsset.HalfAsset: |
| | | case InstalledAsset.IngoreDownLoad: |
| | | if (!SDKUtils.Instance.AssetCopyFinished) |
| | | { |
| | | SDKUtils.Instance.CopyAsset(); |
| | | done = false; |
| | | progress = 0f; |
| | | } |
| | | else |
| | | { |
| | | done = true; |
| | | } |
| | | break; |
| | | case InstalledAsset.NullAsset: |
| | | done = true; |
| | | break; |
| | | } |
| | | }).Forget(); |
| | | } |
| | | |
| | | private void IOSCopyAsset() |
| | | { |
| | | if (VersionUtility.Instance.versionInfo != null && VersionUtility.Instance.versionInfo.downAsset == 1) |
| | | { |
| | | VersionConfig.GetAsync().ContinueWith(config => |
| | | { |
| | | switch (config.assetAccess) |
| | | { |
| | | case InstalledAsset.FullAsset: |
| | | case InstalledAsset.HalfAsset: |
| | | case InstalledAsset.IngoreDownLoad: |
| | | if (!SDKUtils.Instance.AssetCopyFinished) |
| | | { |
| | | copyTasks = new List<FileInfo>(); |
| | | FileExtersion.GetAllDirectoryFileInfos(ResourcesPath.Instance.StreamingAssetPath, copyTasks); |
| | | |
| | | for (var i = copyTasks.Count - 1; i >= 0; i--) |
| | | { |
| | | var fileInfo = copyTasks[i]; |
| | | var destPath = fileInfo.FullName.Replace(ResourcesPath.Instance.StreamingAssetPath, ResourcesPath.Instance.ExternalStorePath); |
| | | if (File.Exists(destPath)) |
| | | { |
| | | copyTasks.RemoveAt(i); |
| | | } |
| | | } |
| | | |
| | | completedCount = 0; |
| | | totalCount = copyTasks.Count; |
| | | } |
| | | |
| | | if (totalCount > 0) |
| | | { |
| | | done = false; |
| | | progress = 0f; |
| | | } |
| | | else |
| | | { |
| | | done = true; |
| | | } |
| | | break; |
| | | case InstalledAsset.NullAsset: |
| | | done = true; |
| | | break; |
| | | } |
| | | }).Forget(); |
| | | |
| | | } |
| | | else |
| | | { |
| | | done = true; |
| | | } |
| | | } |
| | | |
| | | private void StandaloneCopyAsset() |
| | | { |
| | | if (VersionUtility.Instance.versionInfo != null && VersionUtility.Instance.versionInfo.downAsset == 1) |
| | | { |
| | | VersionConfig.GetAsync().ContinueWith(config => |
| | | { |
| | | switch (config.assetAccess) |
| | | { |
| | | case InstalledAsset.FullAsset: |
| | | case InstalledAsset.HalfAsset: |
| | | case InstalledAsset.IngoreDownLoad: |
| | | copyTasks = new List<FileInfo>(); |
| | | FileExtersion.GetAllDirectoryFileInfos(ResourcesPath.Instance.StreamingAssetPath, copyTasks); |
| | | |
| | |
| | | |
| | | completedCount = 0; |
| | | totalCount = copyTasks.Count; |
| | | } |
| | | |
| | | if (totalCount > 0) |
| | | { |
| | | done = false; |
| | | progress = 0f; |
| | | } |
| | | else |
| | | { |
| | | done = true; |
| | | } |
| | | break; |
| | | case InstalledAsset.NullAsset: |
| | | done = true; |
| | | break; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | done = true; |
| | | } |
| | | } |
| | | |
| | | private void StandaloneCopyAsset() |
| | | { |
| | | if (VersionUtility.Instance.versionInfo != null && VersionUtility.Instance.versionInfo.downAsset == 1) |
| | | { |
| | | switch (VersionConfig.Get().assetAccess) |
| | | { |
| | | case InstalledAsset.FullAsset: |
| | | case InstalledAsset.HalfAsset: |
| | | case InstalledAsset.IngoreDownLoad: |
| | | copyTasks = new List<FileInfo>(); |
| | | FileExtersion.GetAllDirectoryFileInfos(ResourcesPath.Instance.StreamingAssetPath, copyTasks); |
| | | |
| | | for (var i = copyTasks.Count - 1; i >= 0; i--) |
| | | { |
| | | var fileInfo = copyTasks[i]; |
| | | var destPath = fileInfo.FullName.Replace(ResourcesPath.Instance.StreamingAssetPath, ResourcesPath.Instance.ExternalStorePath); |
| | | if (File.Exists(destPath)) |
| | | if (totalCount > 0) |
| | | { |
| | | copyTasks.RemoveAt(i); |
| | | done = false; |
| | | progress = 0f; |
| | | } |
| | | } |
| | | |
| | | completedCount = 0; |
| | | totalCount = copyTasks.Count; |
| | | |
| | | if (totalCount > 0) |
| | | { |
| | | done = false; |
| | | progress = 0f; |
| | | } |
| | | else |
| | | { |
| | | else |
| | | { |
| | | done = true; |
| | | } |
| | | break; |
| | | case InstalledAsset.NullAsset: |
| | | done = true; |
| | | } |
| | | break; |
| | | case InstalledAsset.NullAsset: |
| | | done = true; |
| | | break; |
| | | } |
| | | break; |
| | | } |
| | | }).Forget(); |
| | | |
| | | } |
| | | else |
| | | { |
| | |
| | | |
| | | private void IOSProcessCopyComplete() |
| | | { |
| | | LocalSave.SetString("AssetCopyCompleted_IOSorStandalone", VersionConfig.Get().version); |
| | | VersionConfig.GetAsync().ContinueWith(config => |
| | | { |
| | | LocalSave.SetString("AssetCopyCompleted_IOSorStandalone", config.version); |
| | | }).Forget(); |
| | | } |
| | | |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | public static bool assetDeCompressCompleted |
| | | { |
| | | get |
| | | { |
| | | if (string.IsNullOrEmpty(assetDeCompressVersion)) |
| | | { |
| | | return false; |
| | | } |
| | | else |
| | | { |
| | | return assetDeCompressVersion == VersionConfig.Get().version; |
| | | } |
| | | } |
| | | } |
| | | // public static bool assetDeCompressCompleted |
| | | // { |
| | | // get |
| | | // { |
| | | // if (string.IsNullOrEmpty(assetDeCompressVersion)) |
| | | // { |
| | | // return false; |
| | | // } |
| | | // else |
| | | // { |
| | | // return assetDeCompressVersion == VersionConfig.Get().version; |
| | | // } |
| | | // } |
| | | // } |
| | | |
| | | |
| | | |
| | |
| | | |
| | | |
| | | |
| | | public class AssetDecompressTask : LaunchTask |
| | | { |
| | | public override float expectTime |
| | | { |
| | | get { return LocalSave.GetFloat("AssetDecompressTask_ExpectTime", 5f); } |
| | | protected set { LocalSave.SetFloat("AssetDecompressTask_ExpectTime", value); } |
| | | } |
| | | // public class AssetDecompressTask : LaunchTask |
| | | // { |
| | | // public override float expectTime |
| | | // { |
| | | // get { return LocalSave.GetFloat("AssetDecompressTask_ExpectTime", 5f); } |
| | | // protected set { LocalSave.SetFloat("AssetDecompressTask_ExpectTime", value); } |
| | | // } |
| | | |
| | | AssetDeCompressTask.DecompressProgress deCompressProgress = null; |
| | | float waitTimer = 0f; |
| | | // AssetDeCompressTask.DecompressProgress deCompressProgress = null; |
| | | // float waitTimer = 0f; |
| | | |
| | | public override void Begin() |
| | | { |
| | | LaunchInHot.m_CurrentStage = LaunchStage.AssetDecompress; |
| | | duration = Mathf.Max(0.5f, expectTime); |
| | | // public override void Begin() |
| | | // { |
| | | // LaunchInHot.m_CurrentStage = LaunchStage.AssetDecompress; |
| | | // duration = Mathf.Max(0.5f, expectTime); |
| | | |
| | | if (!AssetDeCompressTask.assetDeCompressCompleted) |
| | | { |
| | | deCompressProgress = AssetDeCompressTask.DecompressAync(ResourcesPath.Instance.ExternalStorePath); |
| | | done = false; |
| | | } |
| | | else |
| | | { |
| | | done = true; |
| | | } |
| | | } |
| | | // if (!AssetDeCompressTask.assetDeCompressCompleted) |
| | | // { |
| | | // deCompressProgress = AssetDeCompressTask.DecompressAync(ResourcesPath.Instance.ExternalStorePath); |
| | | // done = false; |
| | | // } |
| | | // else |
| | | // { |
| | | // done = true; |
| | | // } |
| | | // } |
| | | |
| | | public override void End() |
| | | { |
| | | AssetDeCompressTask.assetDeCompressVersion = VersionConfig.Get().version; |
| | | } |
| | | // public override void End() |
| | | // { |
| | | // AssetDeCompressTask.assetDeCompressVersion = VersionConfig.Get().version; |
| | | // } |
| | | |
| | | public override void Update() |
| | | { |
| | | if (done) |
| | | { |
| | | return; |
| | | } |
| | | // public override void Update() |
| | | // { |
| | | // if (done) |
| | | // { |
| | | // return; |
| | | // } |
| | | |
| | | timer += Time.deltaTime; |
| | | progress = timer / duration; |
| | | if (deCompressProgress == null || deCompressProgress.done) |
| | | { |
| | | waitTimer += Time.deltaTime; |
| | | if (waitTimer > 2f) |
| | | { |
| | | done = true; |
| | | } |
| | | } |
| | | } |
| | | // timer += Time.deltaTime; |
| | | // progress = timer / duration; |
| | | // if (deCompressProgress == null || deCompressProgress.done) |
| | | // { |
| | | // waitTimer += Time.deltaTime; |
| | | // if (waitTimer > 2f) |
| | | // { |
| | | // done = true; |
| | | // } |
| | | // } |
| | | // } |
| | | |
| | | } |
| | | // } |
| | |
| | | // done = true; |
| | | //} |
| | | |
| | | public override void End() |
| | | public override async void End() |
| | | { |
| | | if (AssetSource.isUseAssetBundle) |
| | | { |
| | | // YooAsset 已在 Launch 阶段初始化内置资源,不再需要 AssetBundleUtility.InitBuiltInAsset() |
| | | // YooAssetInitializer.Instance.DefaultPackage 已包含内置资源 |
| | | |
| | | LaunchInHot.Instance.InitSystemMgr(); |
| | | await LaunchInHot.Instance.InitSystemMgr(); |
| | | |
| | | // 这里还没开始加载配置 但是提前加载了供LaunchWin使用 |
| | | |
| | |
| | | return; |
| | | } |
| | | |
| | | if (!PriorLanguageConfig.isInit || !InitialFunctionConfig.isInit) |
| | | if (!(PriorLanguageConfig.isInit && InitialFunctionConfig.isInit)) |
| | | { |
| | | return; |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | private void IosCopyAsset() |
| | | private async void IosCopyAsset() |
| | | { |
| | | if (!VersionUtility.Instance.InIosAuditTime()) |
| | | if (!await VersionUtility.Instance.InIosAuditTime()) |
| | | { |
| | | if (!SDKUtils.builtinAssetCopyFinished) |
| | | { |
| | |
| | | File.Copy(fromPath, toPath, true); |
| | | } |
| | | |
| | | LocalSave.SetString("BuiltInAssetCopyCompleted_IOSorStandalone", VersionConfig.Get().version); |
| | | VersionConfig.GetAsync().ContinueWith(config => |
| | | { |
| | | LocalSave.SetString("BuiltInAssetCopyCompleted_IOSorStandalone", config.version); |
| | | }).Forget(); |
| | | } |
| | | } |
| | | } |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using Cysharp.Threading.Tasks; |
| | | using UnityEngine; |
| | | |
| | | public class CheckAssetValidTask : LaunchTask |
| | |
| | | LaunchInHot.m_CurrentStage = LaunchStage.CheckAsset; |
| | | duration = Mathf.Max(0.5f, expectTime); |
| | | |
| | | ServerListCenter.Instance.RequestJumpUrl(); |
| | | ServerListCenter.Instance.RequestJumpUrl().Forget(); |
| | | |
| | | // TODO YYL |
| | | // OperationLogCollect.Instance.RecordLauchEvent(2); |
| | | // OperationLogCollect.Instance.RecordEvent(2); |
| | | |
| | | if (VersionUtility.Instance.NeedDownAsset()) |
| | | VersionConfig.GetAsync().ContinueWith(config => |
| | | { |
| | | var remoteURL = StringUtility.Concat(VersionUtility.Instance.versionInfo.GetResourcesURL(VersionConfig.Get().branch), Language.fixPath, "/config/PriorBundle.txt"); |
| | | var localURL = StringUtility.Concat(ResourcesPath.Instance.ExternalStorePath, "config/PriorBundle.txt"); |
| | | var downloadTask = new DownloadHotTask(remoteURL, localURL); |
| | | downloadTask.BeginDownload(AssetVersionUtility.OnDownLoadPriorBundle); |
| | | if (VersionUtility.Instance.NeedDownAsset()) |
| | | { |
| | | var remoteURL = StringUtility.Concat(VersionUtility.Instance.versionInfo.GetResourcesURL(config.branch), Language.fixPath, "/config/PriorBundle.txt"); |
| | | var localURL = StringUtility.Concat(ResourcesPath.Instance.ExternalStorePath, "config/PriorBundle.txt"); |
| | | var downloadTask = new DownloadHotTask(remoteURL, localURL); |
| | | downloadTask.BeginDownload(AssetVersionUtility.OnDownLoadPriorBundle); |
| | | |
| | | |
| | | remoteURL = StringUtility.Concat(VersionUtility.Instance.versionInfo.GetResourcesURL(VersionConfig.Get().branch), Language.fixPath, $"/config/{VersionConfig.Get().appId}OPConfig.txt"); |
| | | localURL = StringUtility.Concat(ResourcesPath.Instance.ExternalStorePath, "config/OPConfig.txt"); |
| | | var downloadTask2 = new DownloadHotTask(remoteURL, localURL); |
| | | downloadTask2.BeginDownload(AssetVersionUtility.OnDownLoadOPConfig); |
| | | //AssetVersionUtility.GetAssetVersionFile(); |
| | | done = false; |
| | | progress = 0f; |
| | | } |
| | | else |
| | | { |
| | | //if (Application.isEditor) |
| | | // PatchLoader.InitLocalPatchAsset(); |
| | | done = true; |
| | | } |
| | | remoteURL = StringUtility.Concat(VersionUtility.Instance.versionInfo.GetResourcesURL(config.branch), Language.fixPath, $"/config/{config.appId}OPConfig.txt"); |
| | | localURL = StringUtility.Concat(ResourcesPath.Instance.ExternalStorePath, "config/OPConfig.txt"); |
| | | var downloadTask2 = new DownloadHotTask(remoteURL, localURL); |
| | | downloadTask2.BeginDownload(AssetVersionUtility.OnDownLoadOPConfig); |
| | | //AssetVersionUtility.GetAssetVersionFile(); |
| | | done = false; |
| | | progress = 0f; |
| | | } |
| | | else |
| | | { |
| | | //if (Application.isEditor) |
| | | // PatchLoader.InitLocalPatchAsset(); |
| | | done = true; |
| | | } |
| | | |
| | | |
| | | }).Forget(); |
| | | |
| | | |
| | | } |
| | | |
| | | public override void End() |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | public class GetVersionInfoTask : LaunchTask |
| | | { |
| | |
| | | } |
| | | else |
| | | { |
| | | if (!VersionUtility.Instance.InIosAuditTime()) |
| | | VersionUtility.Instance.InIosAuditTime().ContinueWith(isInAuditTime => |
| | | { |
| | | VersionUtility.Instance.RequestVersionCheck(); |
| | | done = false; |
| | | progress = 0f; |
| | | } |
| | | else |
| | | { |
| | | done = true; |
| | | } |
| | | if (!isInAuditTime) |
| | | { |
| | | VersionUtility.Instance.RequestVersionCheck(); |
| | | done = false; |
| | | progress = 0f; |
| | | } |
| | | else |
| | | { |
| | | done = true; |
| | | } |
| | | }).Forget(); |
| | | |
| | | } |
| | | |
| | | } |
| | |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using UnityEngine; |
| | | using Cysharp.Threading.Tasks; |
| | | public class LaunchFadeOutTask : LaunchTask |
| | | { |
| | | public override float expectTime |
| | |
| | | LaunchInHot.m_CurrentStage = LaunchStage.Complete; |
| | | duration = 0.5f; |
| | | |
| | | ShaderUtility.WarmUpAll(); |
| | | ShaderUtility.WarmUpAllAsync().ContinueWith(() => |
| | | { |
| | | Debug.LogError("warm up shader complete"); |
| | | done = true; |
| | | }).Forget(); |
| | | //SpeechTranslate.Instance.RequestGetToken(); |
| | | |
| | | |
| | |
| | | |
| | | if (timer >= 0.5f)//&& ILLauncherProxy.Instance.started) |
| | | { |
| | | done = true; |
| | | // done = true; |
| | | } |
| | | else |
| | | { |
| | | done = false; |
| | | // done = false; |
| | | progress = Mathf.Clamp01(timer / expectTime); |
| | | } |
| | | |
| | |
| | | using UnityEngine; |
| | | using UnityEngine; |
| | | using System.Collections; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | public class LaunchInHot : SingletonMonobehaviour<LaunchInHot> |
| | | { |
| | |
| | | float surplusProgress = 0f; |
| | | float surplusTime = 0f; |
| | | |
| | | bool launchStartFinish = false; |
| | | |
| | | public Action OnApplicationOut = null; |
| | | |
| | | |
| | | void Start() |
| | | async void Start() |
| | | { |
| | | launchStartFinish = false; |
| | | try |
| | | { |
| | | await StartAsync(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Debug.LogError($"[LaunchInHot] Start 初始化异常,游戏无法继续: {ex}"); |
| | | return; // launchStartFinish 保持 false,Update 会一直等待(不会进入 Main.Init) |
| | | } |
| | | launchStartFinish = true; |
| | | } |
| | | |
| | | async UniTask StartAsync() |
| | | { |
| | | System.Net.ServicePointManager.DefaultConnectionLimit = 100;//设置http最大连接数 |
| | | Application.backgroundLoadingPriority = ThreadPriority.High; |
| | | Screen.sleepTimeout = SleepTimeout.NeverSleep; |
| | | |
| | | await VersionConfig.GetAsync(); // 确保 VersionConfig.config 在 SDKUtils.Init() 前已加载 |
| | | |
| | | SDKUtils.Instance.Init(); //原sdk接口 |
| | | if (!AssetSource.isUseAssetBundle) |
| | | { |
| | | InitSystemMgr(); |
| | | await InitSystemMgr(); |
| | | |
| | | UIManager.Instance.OpenWindowAsync<LaunchWin>().Forget(); |
| | | |
| | |
| | | var yooAssetInitTask = new YooAssetInitTask(); |
| | | tasks.Enqueue(yooAssetInitTask); |
| | | // AssetBundleInitTask removed — YooAssetInitTask handles all resource system initialization |
| | | #if !UNITY_WEBGL |
| | | #if UNITY_WEBGL |
| | | // WebGL 不使用 BuiltInAssetCopyTask(无需拷贝内置资源), |
| | | // 但仍需在 YooAsset 初始化后调用 InitSystemMgr 初始化 UIManager 等。 |
| | | var webGLSystemInitTask = new WebGLSystemInitTask(); |
| | | tasks.Enqueue(webGLSystemInitTask); |
| | | #else |
| | | var builtInAssetCopyTask = new BuiltInAssetCopyTask(); |
| | | tasks.Enqueue(builtInAssetCopyTask); |
| | | #endif |
| | |
| | | //tasks.Enqueue(assetCopyTask); |
| | | tasks.Enqueue(getVersionInfoTask); |
| | | break; |
| | | case RuntimePlatform.WebGLPlayer: |
| | | tasks.Enqueue(getVersionInfoTask); |
| | | break; |
| | | } |
| | | |
| | | tasks.Enqueue(checkAssetValidTask); |
| | |
| | | tasks.Enqueue(launchFadeOutTask); |
| | | |
| | | CalculateExpectTotalTime(); |
| | | |
| | | } |
| | | |
| | | public void InitSystemMgr() |
| | | public async UniTask InitSystemMgr() |
| | | { |
| | | SpriteAtlasHandler.Register(); |
| | | ResManager.Instance.Init(); |
| | | UIManager.Instance.Init(); |
| | | StageManager.Instance.Init(); |
| | | LoginManager.Instance.Init(); |
| | | await UIManager.Instance.Init(); |
| | | await StageManager.Instance.Init(); |
| | | await LoginManager.Instance.Init(); |
| | | } |
| | | |
| | | void Update() |
| | | { |
| | | if (!launchStartFinish) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | if (!launchComplete) |
| | | { |
| | | if (currentTask == null) |
| | |
| | | if (tasks.Count > 0) |
| | | { |
| | | currentTask = tasks.Dequeue(); |
| | | Debug.LogError("start currentTask is " + currentTask.GetType().Name); |
| | | currentTask.Begin(); |
| | | } |
| | | else |
| | | { |
| | | Debug.LogError("launchComplete = true"); |
| | | launchComplete = true; |
| | | } |
| | | } |
| | |
| | | |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | //同意隐私权限后才可以申请权限 |
| | | public class RequestPermissionStart : LaunchTask |
| | | { |
| New file |
| | |
| | | using Cysharp.Threading.Tasks; |
| | | using UnityEngine; |
| | | |
| | | /// <summary> |
| | | /// WebGL 平台专用系统初始化任务。 |
| | | /// 因为 BuiltInAssetCopyTask 被 #if !UNITY_WEBGL 排除, |
| | | /// 所以 WebGL 需要一个独立任务在 YooAsset 初始化完成后 |
| | | /// 调用 InitSystemMgr() 初始化 UIManager、StageManager 等,并显示 LaunchWin。 |
| | | /// </summary> |
| | | public class WebGLSystemInitTask : LaunchTask |
| | | { |
| | | public override float expectTime |
| | | { |
| | | get { return LocalSave.GetFloat("WebGLSystemInitTask_ExpectTime", 0.5f); } |
| | | protected set { LocalSave.SetFloat("WebGLSystemInitTask_ExpectTime", value); } |
| | | } |
| | | |
| | | public override void Begin() |
| | | { |
| | | duration = 0.5f; |
| | | done = true; |
| | | } |
| | | |
| | | public override async void End() |
| | | { |
| | | expectTime = timer; |
| | | Debug.LogFormat("{0}执行时长:{1};", GetType().Name, timer); |
| | | |
| | | await LaunchInHot.Instance.InitSystemMgr(); |
| | | |
| | | UIManager.Instance.OpenWindowAsync<LaunchWin>().Forget(); |
| | | |
| | | UIManager.Instance.CloseWindow<DownLoadWin>(); |
| | | UIManager.Instance.CloseWindow<VersionUpdateWin>(); |
| | | } |
| | | |
| | | public override void Update() |
| | | { |
| | | if (done) return; |
| | | } |
| | | } |
| New file |
| | |
| | | fileFormatVersion: 2 |
| | | guid: 19bb1b490eaec714882b825f8dfe89ef |
| | | MonoImporter: |
| | | externalObjects: {} |
| | | serializedVersion: 2 |
| | | defaultReferences: [] |
| | | executionOrder: 0 |
| | | icon: {instanceID: 0} |
| | | userData: |
| | | assetBundleName: |
| | | assetBundleVariant: |
| | |
| | | using UnityEngine;
|
| | | using System.Collections;
|
| | | using System;
|
| | | using Cysharp.Threading.Tasks;
|
| | |
|
| | | //01 04 断线#tagServerDisconnect
|
| | |
|
| | |
| | |
|
| | | ServerForceExitHintWin.reason = vNetData.Reason;
|
| | | LoginManager.Instance.busy = false;
|
| | | if (VersionConfig.Get().versionAuthority == VersionAuthority.Release)
|
| | | VersionConfig.GetAsync().ContinueWith(config =>
|
| | | {
|
| | | if (vNetData.Reason == 1 || vNetData.Reason == 110)
|
| | | if (config.versionAuthority == VersionAuthority.Release)
|
| | | {
|
| | | SDKUtils.Instance.FreePlatformLoginout();
|
| | | LoginManager.Instance.sdkLogined = false;
|
| | | if (vNetData.Reason == 1 || vNetData.Reason == 110)
|
| | | {
|
| | | SDKUtils.Instance.FreePlatformLoginout();
|
| | | LoginManager.Instance.sdkLogined = false;
|
| | | }
|
| | | else |
| | | GameNetSystem.Instance.LoginOut();
|
| | | }
|
| | | else
|
| | | GameNetSystem.Instance.LoginOut();
|
| | | }
|
| | | else |
| | | GameNetSystem.Instance.LoginOut();
|
| | | NetLinkWin.Hide();
|
| | | NetLinkWin.Hide();
|
| | | }).Forget();
|
| | |
|
| | |
|
| | | }
|
| | | catch (Exception ex)
|
| | |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | | using System; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | public class ConnectedState : NetState |
| | | { |
| | |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | public class RoleLoginState : NetState |
| | | { |
| | |
| | | Action<bool> onConnected = null; |
| | | Queue<byte[]> sendQueue = new Queue<byte[]>(); |
| | | static byte[] vCmdBytes = new byte[2]; |
| | | #if UNITY_WEBGL |
| | | string webSocketUrl; |
| | | bool webSocketOpened; |
| | | #endif |
| | | |
| | | public ClientSocket(ServerType type) |
| | | { |
| | |
| | | ip = _ip; |
| | | port = _port; |
| | | onConnected = _onConnected; |
| | | |
| | | string url = $"ws://{_ip}:{_port}"; |
| | | Debug.Log($"[ClientSocket-WebSocket] 开始连接: {url}"); |
| | | |
| | | var scheme = Application.absoluteURL.StartsWith("https://", StringComparison.OrdinalIgnoreCase) ? "wss" : "ws"; |
| | | webSocketUrl = $"{scheme}://{_ip}:{_port}"; |
| | | webSocketOpened = false; |
| | | Debug.Log($"[ClientSocket-WebSocket] 开始连接: {webSocketUrl}, pageUrl={Application.absoluteURL}"); |
| | | |
| | | try |
| | | { |
| | | webSocket = new WebSocket(url); |
| | | webSocket = new WebSocket(webSocketUrl); |
| | | |
| | | // 注册WebSocket回调 |
| | | webSocket.OnOpen += OnWebSocketOpen; |
| | |
| | | |
| | | private void OnWebSocketOpen() |
| | | { |
| | | Debug.Log("[ClientSocket-WebSocket] 连接成功"); |
| | | webSocketOpened = true; |
| | | Debug.Log($"[ClientSocket-WebSocket] 连接成功: {webSocketUrl}"); |
| | | m_LastPackageTime = DateTime.Now; |
| | | |
| | | if (onConnected != null) |
| | |
| | | private void OnWebSocketError(string error) |
| | | { |
| | | Debug.LogError($"[ClientSocket-WebSocket] 错误: {error}"); |
| | | if (!webSocketOpened && onConnected != null) |
| | | { |
| | | onConnected(false); |
| | | onConnected = null; |
| | | } |
| | | } |
| | | |
| | | private void OnWebSocketClose(WebSocketCloseCode code) |
| | | { |
| | | Debug.Log($"[ClientSocket-WebSocket] 连接关闭: {code}"); |
| | | Debug.LogError($"[ClientSocket-WebSocket] 连接关闭: code={code}, url={webSocketUrl}, opened={webSocketOpened}"); |
| | | if (!webSocketOpened && onConnected != null) |
| | | { |
| | | onConnected(false); |
| | | onConnected = null; |
| | | } |
| | | OnDisconnected?.Invoke(); |
| | | } |
| | | |
| | |
| | | using System; |
| | | using System.Runtime.InteropServices; |
| | | using Cysharp.Threading.Tasks; |
| | | using UnityEngine; |
| | | // using System; |
| | | // using System.Runtime.InteropServices; |
| | | // using Cysharp.Threading.Tasks; |
| | | // using UnityEngine; |
| | | |
| | | /// <summary> |
| | | /// 抖音小游戏平台实现 |
| | | /// </summary> |
| | | public class DouyinPlatform : IPlatformService |
| | | { |
| | | #if UNITY_WEBGL && !UNITY_EDITOR |
| | | // JavaScript 插件方法声明 |
| | | [DllImport("__Internal")] |
| | | private static extern bool TT_Init(); |
| | | // /// <summary> |
| | | // /// 抖音小游戏平台实现 |
| | | // /// </summary> |
| | | // public class DouyinPlatform : IPlatformService |
| | | // { |
| | | // #if UNITY_WEBGL && !UNITY_EDITOR |
| | | // // JavaScript 插件方法声明 |
| | | // [DllImport("__Internal")] |
| | | // private static extern bool TT_Init(); |
| | | |
| | | [DllImport("__Internal")] |
| | | private static extern void TT_Login(string callbackObjectName, string callbackMethodName); |
| | | // [DllImport("__Internal")] |
| | | // private static extern void TT_Login(string callbackObjectName, string callbackMethodName); |
| | | |
| | | [DllImport("__Internal")] |
| | | private static extern string TT_GetSystemInfo(); |
| | | // [DllImport("__Internal")] |
| | | // private static extern string TT_GetSystemInfo(); |
| | | |
| | | [DllImport("__Internal")] |
| | | private static extern void TT_ShareAppMessage(string title, string imageUrl); |
| | | // [DllImport("__Internal")] |
| | | // private static extern void TT_ShareAppMessage(string title, string imageUrl); |
| | | |
| | | [DllImport("__Internal")] |
| | | private static extern void TT_CreateRewardedVideoAd(string adUnitId, string callbackObjectName, string callbackMethodName); |
| | | // [DllImport("__Internal")] |
| | | // private static extern void TT_CreateRewardedVideoAd(string adUnitId, string callbackObjectName, string callbackMethodName); |
| | | |
| | | [DllImport("__Internal")] |
| | | private static extern void TT_SetStorageSync(string key, string value); |
| | | // [DllImport("__Internal")] |
| | | // private static extern void TT_SetStorageSync(string key, string value); |
| | | |
| | | [DllImport("__Internal")] |
| | | private static extern string TT_GetStorageSync(string key); |
| | | // [DllImport("__Internal")] |
| | | // private static extern string TT_GetStorageSync(string key); |
| | | |
| | | [DllImport("__Internal")] |
| | | private static extern void TT_VibrateShort(); |
| | | // [DllImport("__Internal")] |
| | | // private static extern void TT_VibrateShort(); |
| | | |
| | | [DllImport("__Internal")] |
| | | private static extern void TT_VibrateLong(); |
| | | #endif |
| | | // [DllImport("__Internal")] |
| | | // private static extern void TT_VibrateLong(); |
| | | // #endif |
| | | |
| | | private SystemInfo _cachedSystemInfo; |
| | | private bool _isInitialized = false; |
| | | // private SystemInfo _cachedSystemInfo; |
| | | // private bool _isInitialized = false; |
| | | |
| | | public async UniTask<bool> InitAsync() |
| | | { |
| | | Debug.Log("[DouyinPlatform] 初始化抖音小游戏平台"); |
| | | // public async UniTask<bool> InitAsync() |
| | | // { |
| | | // Debug.Log("[DouyinPlatform] 初始化抖音小游戏平台"); |
| | | |
| | | #if UNITY_WEBGL && !UNITY_EDITOR |
| | | try |
| | | { |
| | | _isInitialized = TT_Init(); |
| | | if (_isInitialized) |
| | | { |
| | | _cachedSystemInfo = GetSystemInfo(); |
| | | Debug.Log("[DouyinPlatform] 初始化成功"); |
| | | } |
| | | return _isInitialized; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | Debug.LogError($"[DouyinPlatform] 初始化失败: {e.Message}"); |
| | | return false; |
| | | } |
| | | #else |
| | | await UniTask.Delay(100); |
| | | _isInitialized = true; |
| | | _cachedSystemInfo = CreateMockSystemInfo(); |
| | | return true; |
| | | #endif |
| | | } |
| | | // #if UNITY_WEBGL && !UNITY_EDITOR |
| | | // try |
| | | // { |
| | | // _isInitialized = TT_Init(); |
| | | // if (_isInitialized) |
| | | // { |
| | | // _cachedSystemInfo = GetSystemInfo(); |
| | | // Debug.Log("[DouyinPlatform] 初始化成功"); |
| | | // } |
| | | // return _isInitialized; |
| | | // } |
| | | // catch (Exception e) |
| | | // { |
| | | // Debug.LogError($"[DouyinPlatform] 初始化失败: {e.Message}"); |
| | | // return false; |
| | | // } |
| | | // #else |
| | | // await UniTask.Delay(100); |
| | | // _isInitialized = true; |
| | | // _cachedSystemInfo = CreateMockSystemInfo(); |
| | | // return true; |
| | | // #endif |
| | | // } |
| | | |
| | | public PlatformType GetPlatformType() |
| | | { |
| | | return PlatformType.Douyin; |
| | | } |
| | | // public PlatformType GetPlatformType() |
| | | // { |
| | | // return PlatformType.Douyin; |
| | | // } |
| | | |
| | | public async UniTask<LoginResult> LoginAsync() |
| | | { |
| | | Debug.Log("[DouyinPlatform] 开始登录"); |
| | | // public async UniTask<LoginResult> LoginAsync() |
| | | // { |
| | | // Debug.Log("[DouyinPlatform] 开始登录"); |
| | | |
| | | #if UNITY_WEBGL && !UNITY_EDITOR |
| | | // TODO: 实现抖音登录逻辑 |
| | | await UniTask.Delay(500); |
| | | return new LoginResult { Success = true, UserId = "douyin_user" }; |
| | | #else |
| | | await UniTask.Delay(500); |
| | | return new LoginResult { Success = true, UserId = "douyin_test_user" }; |
| | | #endif |
| | | } |
| | | // #if UNITY_WEBGL && !UNITY_EDITOR |
| | | // // TODO: 实现抖音登录逻辑 |
| | | // await UniTask.Delay(500); |
| | | // return new LoginResult { Success = true, UserId = "douyin_user" }; |
| | | // #else |
| | | // await UniTask.Delay(500); |
| | | // return new LoginResult { Success = true, UserId = "douyin_test_user" }; |
| | | // #endif |
| | | // } |
| | | |
| | | public async UniTask<bool> ShareAsync(ShareData shareData) |
| | | { |
| | | Debug.Log($"[DouyinPlatform] 分享: {shareData.Title}"); |
| | | // public async UniTask<bool> ShareAsync(ShareData shareData) |
| | | // { |
| | | // Debug.Log($"[DouyinPlatform] 分享: {shareData.Title}"); |
| | | |
| | | #if UNITY_WEBGL && !UNITY_EDITOR |
| | | TT_ShareAppMessage(shareData.Title, shareData.ImageUrl); |
| | | #endif |
| | | // #if UNITY_WEBGL && !UNITY_EDITOR |
| | | // TT_ShareAppMessage(shareData.Title, shareData.ImageUrl); |
| | | // #endif |
| | | |
| | | await UniTask.Delay(300); |
| | | return true; |
| | | } |
| | | // await UniTask.Delay(300); |
| | | // return true; |
| | | // } |
| | | |
| | | public async UniTask<AdResult> ShowAdAsync(AdType adType) |
| | | { |
| | | Debug.Log($"[DouyinPlatform] 显示广告: {adType}"); |
| | | // public async UniTask<AdResult> ShowAdAsync(AdType adType) |
| | | // { |
| | | // Debug.Log($"[DouyinPlatform] 显示广告: {adType}"); |
| | | |
| | | #if UNITY_WEBGL && !UNITY_EDITOR |
| | | // TODO: 实现抖音广告逻辑 |
| | | #endif |
| | | // #if UNITY_WEBGL && !UNITY_EDITOR |
| | | // // TODO: 实现抖音广告逻辑 |
| | | // #endif |
| | | |
| | | await UniTask.Delay(1000); |
| | | return new AdResult { Success = true, Completed = true }; |
| | | } |
| | | // await UniTask.Delay(1000); |
| | | // return new AdResult { Success = true, Completed = true }; |
| | | // } |
| | | |
| | | public async UniTask<bool> SaveDataAsync(string key, string value) |
| | | { |
| | | #if UNITY_WEBGL && !UNITY_EDITOR |
| | | TT_SetStorageSync(key, value); |
| | | #endif |
| | | await UniTask.Yield(); |
| | | return true; |
| | | } |
| | | // public async UniTask<bool> SaveDataAsync(string key, string value) |
| | | // { |
| | | // #if UNITY_WEBGL && !UNITY_EDITOR |
| | | // TT_SetStorageSync(key, value); |
| | | // #endif |
| | | // await UniTask.Yield(); |
| | | // return true; |
| | | // } |
| | | |
| | | public async UniTask<string> LoadDataAsync(string key) |
| | | { |
| | | #if UNITY_WEBGL && !UNITY_EDITOR |
| | | string value = TT_GetStorageSync(key); |
| | | await UniTask.Yield(); |
| | | return value; |
| | | #else |
| | | await UniTask.Yield(); |
| | | return null; |
| | | #endif |
| | | } |
| | | // public async UniTask<string> LoadDataAsync(string key) |
| | | // { |
| | | // #if UNITY_WEBGL && !UNITY_EDITOR |
| | | // string value = TT_GetStorageSync(key); |
| | | // await UniTask.Yield(); |
| | | // return value; |
| | | // #else |
| | | // await UniTask.Yield(); |
| | | // return null; |
| | | // #endif |
| | | // } |
| | | |
| | | public async UniTask<string> DownloadFileAsync(string url, string localPath, Action<float> onProgress = null) |
| | | { |
| | | Debug.Log($"[DouyinPlatform] 下载文件: {url}"); |
| | | await UniTask.Delay(500); |
| | | return localPath; |
| | | } |
| | | // public async UniTask<string> DownloadFileAsync(string url, string localPath, Action<float> onProgress = null) |
| | | // { |
| | | // Debug.Log($"[DouyinPlatform] 下载文件: {url}"); |
| | | // await UniTask.Delay(500); |
| | | // return localPath; |
| | | // } |
| | | |
| | | public SystemInfo GetSystemInfo() |
| | | { |
| | | if (_cachedSystemInfo != null) |
| | | return _cachedSystemInfo; |
| | | // public SystemInfo GetSystemInfo() |
| | | // { |
| | | // if (_cachedSystemInfo != null) |
| | | // return _cachedSystemInfo; |
| | | |
| | | #if UNITY_WEBGL && !UNITY_EDITOR |
| | | try |
| | | { |
| | | string jsonInfo = TT_GetSystemInfo(); |
| | | _cachedSystemInfo = JsonUtility.FromJson<SystemInfo>(jsonInfo); |
| | | return _cachedSystemInfo; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | Debug.LogError($"[DouyinPlatform] 获取系统信息失败: {e.Message}"); |
| | | return CreateMockSystemInfo(); |
| | | } |
| | | #else |
| | | return CreateMockSystemInfo(); |
| | | #endif |
| | | } |
| | | // #if UNITY_WEBGL && !UNITY_EDITOR |
| | | // try |
| | | // { |
| | | // string jsonInfo = TT_GetSystemInfo(); |
| | | // _cachedSystemInfo = JsonUtility.FromJson<SystemInfo>(jsonInfo); |
| | | // return _cachedSystemInfo; |
| | | // } |
| | | // catch (Exception e) |
| | | // { |
| | | // Debug.LogError($"[DouyinPlatform] 获取系统信息失败: {e.Message}"); |
| | | // return CreateMockSystemInfo(); |
| | | // } |
| | | // #else |
| | | // return CreateMockSystemInfo(); |
| | | // #endif |
| | | // } |
| | | |
| | | public void Vibrate(VibrationType vibrationType) |
| | | { |
| | | #if UNITY_WEBGL && !UNITY_EDITOR |
| | | switch (vibrationType) |
| | | { |
| | | case VibrationType.Light: |
| | | case VibrationType.Medium: |
| | | TT_VibrateShort(); |
| | | break; |
| | | case VibrationType.Heavy: |
| | | TT_VibrateLong(); |
| | | break; |
| | | } |
| | | #endif |
| | | } |
| | | // public void Vibrate(VibrationType vibrationType) |
| | | // { |
| | | // #if UNITY_WEBGL && !UNITY_EDITOR |
| | | // switch (vibrationType) |
| | | // { |
| | | // case VibrationType.Light: |
| | | // case VibrationType.Medium: |
| | | // TT_VibrateShort(); |
| | | // break; |
| | | // case VibrationType.Heavy: |
| | | // TT_VibrateLong(); |
| | | // break; |
| | | // } |
| | | // #endif |
| | | // } |
| | | |
| | | private SystemInfo CreateMockSystemInfo() |
| | | { |
| | | return new SystemInfo |
| | | { |
| | | DeviceModel = UnityEngine.SystemInfo.deviceModel, |
| | | PlatformVersion = "Douyin 1.0.0", |
| | | ScreenWidth = Screen.width, |
| | | ScreenHeight = Screen.height, |
| | | SafeArea = SafeAreaData.FromRect(Screen.safeArea), |
| | | PixelRatio = Screen.dpi / 160f |
| | | }; |
| | | } |
| | | } |
| | | // private SystemInfo CreateMockSystemInfo() |
| | | // { |
| | | // return new SystemInfo |
| | | // { |
| | | // DeviceModel = UnityEngine.SystemInfo.deviceModel, |
| | | // PlatformVersion = "Douyin 1.0.0", |
| | | // ScreenWidth = Screen.width, |
| | | // ScreenHeight = Screen.height, |
| | | // SafeArea = SafeAreaData.FromRect(Screen.safeArea), |
| | | // PixelRatio = Screen.dpi / 160f |
| | | // }; |
| | | // } |
| | | // } |
| | |
| | | using UnityEngine; |
| | | // using UnityEngine; |
| | | |
| | | /// <summary> |
| | | /// 平台工厂类,用于创建对应平台的实现 |
| | | /// </summary> |
| | | public static class PlatformFactory |
| | | { |
| | | private static IPlatformService _currentPlatform; |
| | | private static PlatformType? _forcedPlatformType; |
| | | // /// <summary> |
| | | // /// 平台工厂类,用于创建对应平台的实现 |
| | | // /// </summary> |
| | | // public static class PlatformFactory |
| | | // { |
| | | // private static IPlatformService _currentPlatform; |
| | | // private static PlatformType? _forcedPlatformType; |
| | | |
| | | /// <summary> |
| | | /// 获取当前平台实例 |
| | | /// </summary> |
| | | public static IPlatformService GetCurrent() |
| | | { |
| | | if (_currentPlatform == null) |
| | | { |
| | | _currentPlatform = CreatePlatform(); |
| | | } |
| | | return _currentPlatform; |
| | | } |
| | | // /// <summary> |
| | | // /// 获取当前平台实例 |
| | | // /// </summary> |
| | | // public static IPlatformService GetCurrent() |
| | | // { |
| | | // if (_currentPlatform == null) |
| | | // { |
| | | // _currentPlatform = CreatePlatform(); |
| | | // } |
| | | // return _currentPlatform; |
| | | // } |
| | | |
| | | /// <summary> |
| | | /// 强制指定平台类型(用于测试) |
| | | /// </summary> |
| | | public static void ForcePlatform(PlatformType platformType) |
| | | { |
| | | _forcedPlatformType = platformType; |
| | | _currentPlatform = null; // 重置当前平台 |
| | | } |
| | | // /// <summary> |
| | | // /// 强制指定平台类型(用于测试) |
| | | // /// </summary> |
| | | // public static void ForcePlatform(PlatformType platformType) |
| | | // { |
| | | // _forcedPlatformType = platformType; |
| | | // _currentPlatform = null; // 重置当前平台 |
| | | // } |
| | | |
| | | /// <summary> |
| | | /// 创建平台实例 |
| | | /// </summary> |
| | | private static IPlatformService CreatePlatform() |
| | | { |
| | | PlatformType platformType = DetectPlatformType(); |
| | | // /// <summary> |
| | | // /// 创建平台实例 |
| | | // /// </summary> |
| | | // private static IPlatformService CreatePlatform() |
| | | // { |
| | | // PlatformType platformType = DetectPlatformType(); |
| | | |
| | | switch (platformType) |
| | | { |
| | | case PlatformType.WeChat: |
| | | Debug.Log("[PlatformFactory] 创建微信小游戏平台实例"); |
| | | return new WeChatPlatform(); |
| | | // switch (platformType) |
| | | // { |
| | | // case PlatformType.WeChat: |
| | | // Debug.Log("[PlatformFactory] 创建微信小游戏平台实例"); |
| | | // return new WeChatPlatform(); |
| | | |
| | | case PlatformType.Douyin: |
| | | Debug.Log("[PlatformFactory] 创建抖音小游戏平台实例"); |
| | | return new DouyinPlatform(); |
| | | // case PlatformType.Douyin: |
| | | // Debug.Log("[PlatformFactory] 创建抖音小游戏平台实例"); |
| | | // return new DouyinPlatform(); |
| | | |
| | | case PlatformType.Vivo: |
| | | Debug.Log("[PlatformFactory] 创建vivo小游戏平台实例"); |
| | | return new VivoPlatform(); |
| | | // case PlatformType.Vivo: |
| | | // Debug.Log("[PlatformFactory] 创建vivo小游戏平台实例"); |
| | | // return new VivoPlatform(); |
| | | |
| | | case PlatformType.Standalone: |
| | | default: |
| | | Debug.Log("[PlatformFactory] 创建编辑器测试平台实例"); |
| | | return new StandalonePlatform(); |
| | | } |
| | | } |
| | | // case PlatformType.Standalone: |
| | | // default: |
| | | // Debug.Log("[PlatformFactory] 创建编辑器测试平台实例"); |
| | | // return new StandalonePlatform(); |
| | | // } |
| | | // } |
| | | |
| | | /// <summary> |
| | | /// 检测当前平台类型 |
| | | /// </summary> |
| | | private static PlatformType DetectPlatformType() |
| | | { |
| | | // 如果强制指定了平台类型,使用强制类型 |
| | | if (_forcedPlatformType.HasValue) |
| | | { |
| | | Debug.Log($"[PlatformFactory] 使用强制指定的平台类型: {_forcedPlatformType.Value}"); |
| | | return _forcedPlatformType.Value; |
| | | } |
| | | // /// <summary> |
| | | // /// 检测当前平台类型 |
| | | // /// </summary> |
| | | // private static PlatformType DetectPlatformType() |
| | | // { |
| | | // // 如果强制指定了平台类型,使用强制类型 |
| | | // if (_forcedPlatformType.HasValue) |
| | | // { |
| | | // Debug.Log($"[PlatformFactory] 使用强制指定的平台类型: {_forcedPlatformType.Value}"); |
| | | // return _forcedPlatformType.Value; |
| | | // } |
| | | |
| | | #if UNITY_EDITOR |
| | | // Unity 编辑器环境 |
| | | return PlatformType.Standalone; |
| | | #elif UNITY_WEBGL |
| | | // WebGL 平台,需要通过 JavaScript 检测具体平台 |
| | | // TODO: 通过 Application.ExternalEval 检测微信、抖音等平台 |
| | | // 暂时默认返回微信 |
| | | return PlatformType.WeChat; |
| | | #else |
| | | // 其他平台默认为 Standalone |
| | | return PlatformType.Standalone; |
| | | #endif |
| | | } |
| | | } |
| | | // #if UNITY_EDITOR |
| | | // // Unity 编辑器环境 |
| | | // return PlatformType.Standalone; |
| | | // #elif UNITY_WEBGL |
| | | // // WebGL 平台,需要通过 JavaScript 检测具体平台 |
| | | // // TODO: 通过 Application.ExternalEval 检测微信、抖音等平台 |
| | | // // 暂时默认返回微信 |
| | | // return PlatformType.WeChat; |
| | | // #else |
| | | // // 其他平台默认为 Standalone |
| | | // return PlatformType.Standalone; |
| | | // #endif |
| | | // } |
| | | // } |
| | |
| | | using System; |
| | | using Cysharp.Threading.Tasks; |
| | | using UnityEngine; |
| | | // using System; |
| | | // using Cysharp.Threading.Tasks; |
| | | // using UnityEngine; |
| | | |
| | | /// <summary> |
| | | /// 编辑器测试平台实现(模拟平台行为) |
| | | /// </summary> |
| | | public class StandalonePlatform : IPlatformService |
| | | { |
| | | private SystemInfo _cachedSystemInfo; |
| | | // /// <summary> |
| | | // /// 编辑器测试平台实现(模拟平台行为) |
| | | // /// </summary> |
| | | // public class StandalonePlatform : IPlatformService |
| | | // { |
| | | // private SystemInfo _cachedSystemInfo; |
| | | |
| | | public async UniTask<bool> InitAsync() |
| | | { |
| | | Debug.Log("[StandalonePlatform] 初始化编辑器测试平台"); |
| | | await UniTask.Delay(100); // 模拟初始化延迟 |
| | | _cachedSystemInfo = CreateMockSystemInfo(); |
| | | return true; |
| | | } |
| | | // public async UniTask<bool> InitAsync() |
| | | // { |
| | | // Debug.Log("[StandalonePlatform] 初始化编辑器测试平台"); |
| | | // await UniTask.Delay(100); // 模拟初始化延迟 |
| | | // _cachedSystemInfo = CreateMockSystemInfo(); |
| | | // return true; |
| | | // } |
| | | |
| | | public PlatformType GetPlatformType() |
| | | { |
| | | return PlatformType.Standalone; |
| | | } |
| | | // public PlatformType GetPlatformType() |
| | | // { |
| | | // return PlatformType.Standalone; |
| | | // } |
| | | |
| | | public async UniTask<LoginResult> LoginAsync() |
| | | { |
| | | Debug.Log("[StandalonePlatform] 模拟登录成功"); |
| | | await UniTask.Delay(500); // 模拟网络延迟 |
| | | // public async UniTask<LoginResult> LoginAsync() |
| | | // { |
| | | // Debug.Log("[StandalonePlatform] 模拟登录成功"); |
| | | // await UniTask.Delay(500); // 模拟网络延迟 |
| | | |
| | | return new LoginResult |
| | | { |
| | | Success = true, |
| | | UserId = "test_user_12345", |
| | | Nickname = "测试用户", |
| | | AvatarUrl = "https://example.com/avatar.jpg", |
| | | ErrorMessage = null |
| | | }; |
| | | } |
| | | // return new LoginResult |
| | | // { |
| | | // Success = true, |
| | | // UserId = "test_user_12345", |
| | | // Nickname = "测试用户", |
| | | // AvatarUrl = "https://example.com/avatar.jpg", |
| | | // ErrorMessage = null |
| | | // }; |
| | | // } |
| | | |
| | | public async UniTask<bool> ShareAsync(ShareData shareData) |
| | | { |
| | | Debug.Log($"[StandalonePlatform] 模拟分享: {shareData.Title}"); |
| | | await UniTask.Delay(300); |
| | | return true; |
| | | } |
| | | // public async UniTask<bool> ShareAsync(ShareData shareData) |
| | | // { |
| | | // Debug.Log($"[StandalonePlatform] 模拟分享: {shareData.Title}"); |
| | | // await UniTask.Delay(300); |
| | | // return true; |
| | | // } |
| | | |
| | | public async UniTask<AdResult> ShowAdAsync(AdType adType) |
| | | { |
| | | Debug.Log($"[StandalonePlatform] 模拟显示广告: {adType}"); |
| | | await UniTask.Delay(2000); // 模拟广告播放时间 |
| | | // public async UniTask<AdResult> ShowAdAsync(AdType adType) |
| | | // { |
| | | // Debug.Log($"[StandalonePlatform] 模拟显示广告: {adType}"); |
| | | // await UniTask.Delay(2000); // 模拟广告播放时间 |
| | | |
| | | return new AdResult |
| | | { |
| | | Success = true, |
| | | Completed = true, // 模拟用户看完广告 |
| | | ErrorMessage = null |
| | | }; |
| | | } |
| | | // return new AdResult |
| | | // { |
| | | // Success = true, |
| | | // Completed = true, // 模拟用户看完广告 |
| | | // ErrorMessage = null |
| | | // }; |
| | | // } |
| | | |
| | | public async UniTask<bool> SaveDataAsync(string key, string value) |
| | | { |
| | | Debug.Log($"[StandalonePlatform] 保存数据: {key} = {value}"); |
| | | await UniTask.Delay(50); |
| | | PlayerPrefs.SetString(key, value); |
| | | PlayerPrefs.Save(); |
| | | return true; |
| | | } |
| | | // public async UniTask<bool> SaveDataAsync(string key, string value) |
| | | // { |
| | | // Debug.Log($"[StandalonePlatform] 保存数据: {key} = {value}"); |
| | | // await UniTask.Delay(50); |
| | | // PlayerPrefs.SetString(key, value); |
| | | // PlayerPrefs.Save(); |
| | | // return true; |
| | | // } |
| | | |
| | | public async UniTask<string> LoadDataAsync(string key) |
| | | { |
| | | Debug.Log($"[StandalonePlatform] 加载数据: {key}"); |
| | | await UniTask.Delay(50); |
| | | return PlayerPrefs.GetString(key, null); |
| | | } |
| | | // public async UniTask<string> LoadDataAsync(string key) |
| | | // { |
| | | // Debug.Log($"[StandalonePlatform] 加载数据: {key}"); |
| | | // await UniTask.Delay(50); |
| | | // return PlayerPrefs.GetString(key, null); |
| | | // } |
| | | |
| | | public async UniTask<string> DownloadFileAsync(string url, string localPath, Action<float> onProgress = null) |
| | | { |
| | | Debug.Log($"[StandalonePlatform] 模拟下载文件: {url} -> {localPath}"); |
| | | // public async UniTask<string> DownloadFileAsync(string url, string localPath, Action<float> onProgress = null) |
| | | // { |
| | | // Debug.Log($"[StandalonePlatform] 模拟下载文件: {url} -> {localPath}"); |
| | | |
| | | // 模拟下载进度 |
| | | for (int i = 0; i <= 10; i++) |
| | | { |
| | | await UniTask.Delay(100); |
| | | onProgress?.Invoke(i / 10f); |
| | | } |
| | | // // 模拟下载进度 |
| | | // for (int i = 0; i <= 10; i++) |
| | | // { |
| | | // await UniTask.Delay(100); |
| | | // onProgress?.Invoke(i / 10f); |
| | | // } |
| | | |
| | | return localPath; |
| | | } |
| | | // return localPath; |
| | | // } |
| | | |
| | | public SystemInfo GetSystemInfo() |
| | | { |
| | | return _cachedSystemInfo ?? (_cachedSystemInfo = CreateMockSystemInfo()); |
| | | } |
| | | // public SystemInfo GetSystemInfo() |
| | | // { |
| | | // return _cachedSystemInfo ?? (_cachedSystemInfo = CreateMockSystemInfo()); |
| | | // } |
| | | |
| | | public void Vibrate(VibrationType vibrationType) |
| | | { |
| | | Debug.Log($"[StandalonePlatform] 模拟震动: {vibrationType}"); |
| | | // 编辑器中无法实际震动 |
| | | } |
| | | // public void Vibrate(VibrationType vibrationType) |
| | | // { |
| | | // Debug.Log($"[StandalonePlatform] 模拟震动: {vibrationType}"); |
| | | // // 编辑器中无法实际震动 |
| | | // } |
| | | |
| | | private SystemInfo CreateMockSystemInfo() |
| | | { |
| | | return new SystemInfo |
| | | { |
| | | DeviceModel = UnityEngine.SystemInfo.deviceModel, |
| | | SystemVersion = UnityEngine.SystemInfo.operatingSystem, |
| | | PlatformVersion = "Standalone 1.0.0", |
| | | ScreenWidth = Screen.width, |
| | | ScreenHeight = Screen.height, |
| | | SafeArea = SafeAreaData.FromRect(Screen.safeArea), |
| | | PixelRatio = Screen.dpi / 160f |
| | | }; |
| | | } |
| | | } |
| | | // private SystemInfo CreateMockSystemInfo() |
| | | // { |
| | | // return new SystemInfo |
| | | // { |
| | | // DeviceModel = UnityEngine.SystemInfo.deviceModel, |
| | | // SystemVersion = UnityEngine.SystemInfo.operatingSystem, |
| | | // PlatformVersion = "Standalone 1.0.0", |
| | | // ScreenWidth = Screen.width, |
| | | // ScreenHeight = Screen.height, |
| | | // SafeArea = SafeAreaData.FromRect(Screen.safeArea), |
| | | // PixelRatio = Screen.dpi / 160f |
| | | // }; |
| | | // } |
| | | // } |
| | |
| | | using System; |
| | | using System.Runtime.InteropServices; |
| | | using Cysharp.Threading.Tasks; |
| | | using UnityEngine; |
| | | // using System; |
| | | // using System.Runtime.InteropServices; |
| | | // using Cysharp.Threading.Tasks; |
| | | // using UnityEngine; |
| | | |
| | | /// <summary> |
| | | /// vivo小游戏平台实现 |
| | | /// </summary> |
| | | public class VivoPlatform : IPlatformService |
| | | { |
| | | #if UNITY_WEBGL && !UNITY_EDITOR |
| | | // JavaScript 插件方法声明 |
| | | [DllImport("__Internal")] |
| | | private static extern bool QG_Init(); |
| | | // /// <summary> |
| | | // /// vivo小游戏平台实现 |
| | | // /// </summary> |
| | | // public class VivoPlatform : IPlatformService |
| | | // { |
| | | // #if UNITY_WEBGL && !UNITY_EDITOR |
| | | // // JavaScript 插件方法声明 |
| | | // [DllImport("__Internal")] |
| | | // private static extern bool QG_Init(); |
| | | |
| | | [DllImport("__Internal")] |
| | | private static extern void QG_Login(string callbackObjectName, string callbackMethodName); |
| | | // [DllImport("__Internal")] |
| | | // private static extern void QG_Login(string callbackObjectName, string callbackMethodName); |
| | | |
| | | [DllImport("__Internal")] |
| | | private static extern string QG_GetSystemInfo(); |
| | | // [DllImport("__Internal")] |
| | | // private static extern string QG_GetSystemInfo(); |
| | | |
| | | [DllImport("__Internal")] |
| | | private static extern void QG_Share(string title, string imageUrl); |
| | | // [DllImport("__Internal")] |
| | | // private static extern void QG_Share(string title, string imageUrl); |
| | | |
| | | [DllImport("__Internal")] |
| | | private static extern void QG_CreateRewardedVideoAd(string adUnitId, string callbackObjectName, string callbackMethodName); |
| | | // [DllImport("__Internal")] |
| | | // private static extern void QG_CreateRewardedVideoAd(string adUnitId, string callbackObjectName, string callbackMethodName); |
| | | |
| | | [DllImport("__Internal")] |
| | | private static extern void QG_SetStorageSync(string key, string value); |
| | | // [DllImport("__Internal")] |
| | | // private static extern void QG_SetStorageSync(string key, string value); |
| | | |
| | | [DllImport("__Internal")] |
| | | private static extern string QG_GetStorageSync(string key); |
| | | // [DllImport("__Internal")] |
| | | // private static extern string QG_GetStorageSync(string key); |
| | | |
| | | [DllImport("__Internal")] |
| | | private static extern void QG_VibrateShort(); |
| | | // [DllImport("__Internal")] |
| | | // private static extern void QG_VibrateShort(); |
| | | |
| | | [DllImport("__Internal")] |
| | | private static extern void QG_VibrateLong(); |
| | | #endif |
| | | // [DllImport("__Internal")] |
| | | // private static extern void QG_VibrateLong(); |
| | | // #endif |
| | | |
| | | private SystemInfo _cachedSystemInfo; |
| | | private bool _isInitialized = false; |
| | | // private SystemInfo _cachedSystemInfo; |
| | | // private bool _isInitialized = false; |
| | | |
| | | public async UniTask<bool> InitAsync() |
| | | { |
| | | Debug.Log("[VivoPlatform] 初始化vivo小游戏平台"); |
| | | // public async UniTask<bool> InitAsync() |
| | | // { |
| | | // Debug.Log("[VivoPlatform] 初始化vivo小游戏平台"); |
| | | |
| | | #if UNITY_WEBGL && !UNITY_EDITOR |
| | | try |
| | | { |
| | | _isInitialized = QG_Init(); |
| | | if (_isInitialized) |
| | | { |
| | | _cachedSystemInfo = GetSystemInfo(); |
| | | Debug.Log("[VivoPlatform] 初始化成功"); |
| | | } |
| | | return _isInitialized; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | Debug.LogError($"[VivoPlatform] 初始化失败: {e.Message}"); |
| | | return false; |
| | | } |
| | | #else |
| | | await UniTask.Delay(100); |
| | | _isInitialized = true; |
| | | _cachedSystemInfo = CreateMockSystemInfo(); |
| | | return true; |
| | | #endif |
| | | } |
| | | // #if UNITY_WEBGL && !UNITY_EDITOR |
| | | // try |
| | | // { |
| | | // _isInitialized = QG_Init(); |
| | | // if (_isInitialized) |
| | | // { |
| | | // _cachedSystemInfo = GetSystemInfo(); |
| | | // Debug.Log("[VivoPlatform] 初始化成功"); |
| | | // } |
| | | // return _isInitialized; |
| | | // } |
| | | // catch (Exception e) |
| | | // { |
| | | // Debug.LogError($"[VivoPlatform] 初始化失败: {e.Message}"); |
| | | // return false; |
| | | // } |
| | | // #else |
| | | // await UniTask.Delay(100); |
| | | // _isInitialized = true; |
| | | // _cachedSystemInfo = CreateMockSystemInfo(); |
| | | // return true; |
| | | // #endif |
| | | // } |
| | | |
| | | public PlatformType GetPlatformType() |
| | | { |
| | | return PlatformType.Vivo; |
| | | } |
| | | // public PlatformType GetPlatformType() |
| | | // { |
| | | // return PlatformType.Vivo; |
| | | // } |
| | | |
| | | public async UniTask<LoginResult> LoginAsync() |
| | | { |
| | | Debug.Log("[VivoPlatform] 开始登录"); |
| | | // public async UniTask<LoginResult> LoginAsync() |
| | | // { |
| | | // Debug.Log("[VivoPlatform] 开始登录"); |
| | | |
| | | #if UNITY_WEBGL && !UNITY_EDITOR |
| | | // TODO: 实现vivo登录逻辑 |
| | | await UniTask.Delay(500); |
| | | return new LoginResult { Success = true, UserId = "vivo_user" }; |
| | | #else |
| | | await UniTask.Delay(500); |
| | | return new LoginResult { Success = true, UserId = "vivo_test_user" }; |
| | | #endif |
| | | } |
| | | // #if UNITY_WEBGL && !UNITY_EDITOR |
| | | // // TODO: 实现vivo登录逻辑 |
| | | // await UniTask.Delay(500); |
| | | // return new LoginResult { Success = true, UserId = "vivo_user" }; |
| | | // #else |
| | | // await UniTask.Delay(500); |
| | | // return new LoginResult { Success = true, UserId = "vivo_test_user" }; |
| | | // #endif |
| | | // } |
| | | |
| | | public async UniTask<bool> ShareAsync(ShareData shareData) |
| | | { |
| | | Debug.Log($"[VivoPlatform] 分享: {shareData.Title}"); |
| | | // public async UniTask<bool> ShareAsync(ShareData shareData) |
| | | // { |
| | | // Debug.Log($"[VivoPlatform] 分享: {shareData.Title}"); |
| | | |
| | | #if UNITY_WEBGL && !UNITY_EDITOR |
| | | QG_Share(shareData.Title, shareData.ImageUrl); |
| | | #endif |
| | | // #if UNITY_WEBGL && !UNITY_EDITOR |
| | | // QG_Share(shareData.Title, shareData.ImageUrl); |
| | | // #endif |
| | | |
| | | await UniTask.Delay(300); |
| | | return true; |
| | | } |
| | | // await UniTask.Delay(300); |
| | | // return true; |
| | | // } |
| | | |
| | | public async UniTask<AdResult> ShowAdAsync(AdType adType) |
| | | { |
| | | Debug.Log($"[VivoPlatform] 显示广告: {adType}"); |
| | | // public async UniTask<AdResult> ShowAdAsync(AdType adType) |
| | | // { |
| | | // Debug.Log($"[VivoPlatform] 显示广告: {adType}"); |
| | | |
| | | #if UNITY_WEBGL && !UNITY_EDITOR |
| | | // TODO: 实现vivo广告逻辑 |
| | | #endif |
| | | // #if UNITY_WEBGL && !UNITY_EDITOR |
| | | // // TODO: 实现vivo广告逻辑 |
| | | // #endif |
| | | |
| | | await UniTask.Delay(1000); |
| | | return new AdResult { Success = true, Completed = true }; |
| | | } |
| | | // await UniTask.Delay(1000); |
| | | // return new AdResult { Success = true, Completed = true }; |
| | | // } |
| | | |
| | | public async UniTask<bool> SaveDataAsync(string key, string value) |
| | | { |
| | | #if UNITY_WEBGL && !UNITY_EDITOR |
| | | QG_SetStorageSync(key, value); |
| | | #endif |
| | | await UniTask.Yield(); |
| | | return true; |
| | | } |
| | | // public async UniTask<bool> SaveDataAsync(string key, string value) |
| | | // { |
| | | // #if UNITY_WEBGL && !UNITY_EDITOR |
| | | // QG_SetStorageSync(key, value); |
| | | // #endif |
| | | // await UniTask.Yield(); |
| | | // return true; |
| | | // } |
| | | |
| | | public async UniTask<string> LoadDataAsync(string key) |
| | | { |
| | | #if UNITY_WEBGL && !UNITY_EDITOR |
| | | string value = QG_GetStorageSync(key); |
| | | await UniTask.Yield(); |
| | | return value; |
| | | #else |
| | | await UniTask.Yield(); |
| | | return null; |
| | | #endif |
| | | } |
| | | // public async UniTask<string> LoadDataAsync(string key) |
| | | // { |
| | | // #if UNITY_WEBGL && !UNITY_EDITOR |
| | | // string value = QG_GetStorageSync(key); |
| | | // await UniTask.Yield(); |
| | | // return value; |
| | | // #else |
| | | // await UniTask.Yield(); |
| | | // return null; |
| | | // #endif |
| | | // } |
| | | |
| | | public async UniTask<string> DownloadFileAsync(string url, string localPath, Action<float> onProgress = null) |
| | | { |
| | | Debug.Log($"[VivoPlatform] 下载文件: {url}"); |
| | | await UniTask.Delay(500); |
| | | return localPath; |
| | | } |
| | | // public async UniTask<string> DownloadFileAsync(string url, string localPath, Action<float> onProgress = null) |
| | | // { |
| | | // Debug.Log($"[VivoPlatform] 下载文件: {url}"); |
| | | // await UniTask.Delay(500); |
| | | // return localPath; |
| | | // } |
| | | |
| | | public SystemInfo GetSystemInfo() |
| | | { |
| | | if (_cachedSystemInfo != null) |
| | | return _cachedSystemInfo; |
| | | // public SystemInfo GetSystemInfo() |
| | | // { |
| | | // if (_cachedSystemInfo != null) |
| | | // return _cachedSystemInfo; |
| | | |
| | | #if UNITY_WEBGL && !UNITY_EDITOR |
| | | try |
| | | { |
| | | string jsonInfo = QG_GetSystemInfo(); |
| | | _cachedSystemInfo = JsonUtility.FromJson<SystemInfo>(jsonInfo); |
| | | return _cachedSystemInfo; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | Debug.LogError($"[VivoPlatform] 获取系统信息失败: {e.Message}"); |
| | | return CreateMockSystemInfo(); |
| | | } |
| | | #else |
| | | return CreateMockSystemInfo(); |
| | | #endif |
| | | } |
| | | // #if UNITY_WEBGL && !UNITY_EDITOR |
| | | // try |
| | | // { |
| | | // string jsonInfo = QG_GetSystemInfo(); |
| | | // _cachedSystemInfo = JsonUtility.FromJson<SystemInfo>(jsonInfo); |
| | | // return _cachedSystemInfo; |
| | | // } |
| | | // catch (Exception e) |
| | | // { |
| | | // Debug.LogError($"[VivoPlatform] 获取系统信息失败: {e.Message}"); |
| | | // return CreateMockSystemInfo(); |
| | | // } |
| | | // #else |
| | | // return CreateMockSystemInfo(); |
| | | // #endif |
| | | // } |
| | | |
| | | public void Vibrate(VibrationType vibrationType) |
| | | { |
| | | #if UNITY_WEBGL && !UNITY_EDITOR |
| | | switch (vibrationType) |
| | | { |
| | | case VibrationType.Light: |
| | | case VibrationType.Medium: |
| | | QG_VibrateShort(); |
| | | break; |
| | | case VibrationType.Heavy: |
| | | QG_VibrateLong(); |
| | | break; |
| | | } |
| | | #endif |
| | | } |
| | | // public void Vibrate(VibrationType vibrationType) |
| | | // { |
| | | // #if UNITY_WEBGL && !UNITY_EDITOR |
| | | // switch (vibrationType) |
| | | // { |
| | | // case VibrationType.Light: |
| | | // case VibrationType.Medium: |
| | | // QG_VibrateShort(); |
| | | // break; |
| | | // case VibrationType.Heavy: |
| | | // QG_VibrateLong(); |
| | | // break; |
| | | // } |
| | | // #endif |
| | | // } |
| | | |
| | | private SystemInfo CreateMockSystemInfo() |
| | | { |
| | | return new SystemInfo |
| | | { |
| | | DeviceModel = UnityEngine.SystemInfo.deviceModel, |
| | | PlatformVersion = "Vivo 1.0.0", |
| | | ScreenWidth = Screen.width, |
| | | ScreenHeight = Screen.height, |
| | | SafeArea = SafeAreaData.FromRect(Screen.safeArea), |
| | | PixelRatio = Screen.dpi / 160f |
| | | }; |
| | | } |
| | | } |
| | | // private SystemInfo CreateMockSystemInfo() |
| | | // { |
| | | // return new SystemInfo |
| | | // { |
| | | // DeviceModel = UnityEngine.SystemInfo.deviceModel, |
| | | // PlatformVersion = "Vivo 1.0.0", |
| | | // ScreenWidth = Screen.width, |
| | | // ScreenHeight = Screen.height, |
| | | // SafeArea = SafeAreaData.FromRect(Screen.safeArea), |
| | | // PixelRatio = Screen.dpi / 160f |
| | | // }; |
| | | // } |
| | | // } |
| | |
| | | using System; |
| | | using System.Runtime.InteropServices; |
| | | using Cysharp.Threading.Tasks; |
| | | using UnityEngine; |
| | | // using System; |
| | | // using System.Runtime.InteropServices; |
| | | // using Cysharp.Threading.Tasks; |
| | | // using UnityEngine; |
| | | |
| | | /// <summary> |
| | | /// 微信小游戏平台实现 |
| | | /// </summary> |
| | | public class WeChatPlatform : IPlatformService |
| | | { |
| | | #if UNITY_WEBGL && !UNITY_EDITOR |
| | | // JavaScript 插件方法声明 |
| | | [DllImport("__Internal")] |
| | | private static extern void WX_Init(); |
| | | // /// <summary> |
| | | // /// 微信小游戏平台实现 |
| | | // /// </summary> |
| | | // public class WeChatPlatform : IPlatformService |
| | | // { |
| | | // #if UNITY_WEBGL && !UNITY_EDITOR |
| | | // // JavaScript 插件方法声明 |
| | | // [DllImport("__Internal")] |
| | | // private static extern void WX_Init(); |
| | | |
| | | [DllImport("__Internal")] |
| | | private static extern void WX_Login(string callbackObjectName, string callbackMethodName); |
| | | // [DllImport("__Internal")] |
| | | // private static extern void WX_Login(string callbackObjectName, string callbackMethodName); |
| | | |
| | | [DllImport("__Internal")] |
| | | private static extern void WX_GetSystemInfo(string callbackObjectName, string callbackMethodName); |
| | | // [DllImport("__Internal")] |
| | | // private static extern void WX_GetSystemInfo(string callbackObjectName, string callbackMethodName); |
| | | |
| | | [DllImport("__Internal")] |
| | | private static extern void WX_ShareAppMessage(string title, string imageUrl); |
| | | // [DllImport("__Internal")] |
| | | // private static extern void WX_ShareAppMessage(string title, string imageUrl); |
| | | |
| | | [DllImport("__Internal")] |
| | | private static extern void WX_CreateRewardedVideoAd(string adUnitId, string callbackObjectName, string callbackMethodName); |
| | | // [DllImport("__Internal")] |
| | | // private static extern void WX_CreateRewardedVideoAd(string adUnitId, string callbackObjectName, string callbackMethodName); |
| | | |
| | | [DllImport("__Internal")] |
| | | private static extern void WX_SetStorageSync(string key, string value); |
| | | // [DllImport("__Internal")] |
| | | // private static extern void WX_SetStorageSync(string key, string value); |
| | | |
| | | [DllImport("__Internal")] |
| | | private static extern string WX_GetStorageSync(string key); |
| | | // [DllImport("__Internal")] |
| | | // private static extern string WX_GetStorageSync(string key); |
| | | |
| | | [DllImport("__Internal")] |
| | | private static extern void WX_VibrateShort(); |
| | | // [DllImport("__Internal")] |
| | | // private static extern void WX_VibrateShort(); |
| | | |
| | | [DllImport("__Internal")] |
| | | private static extern void WX_VibrateLong(); |
| | | #endif |
| | | // [DllImport("__Internal")] |
| | | // private static extern void WX_VibrateLong(); |
| | | // #endif |
| | | |
| | | private SystemInfo _cachedSystemInfo; |
| | | private bool _isInitialized = false; |
| | | // private SystemInfo _cachedSystemInfo; |
| | | // private bool _isInitialized = false; |
| | | |
| | | public async UniTask<bool> InitAsync() |
| | | { |
| | | Debug.Log("[WeChatPlatform] 初始化微信小游戏平台"); |
| | | // public async UniTask<bool> InitAsync() |
| | | // { |
| | | // Debug.Log("[WeChatPlatform] 初始化微信小游戏平台"); |
| | | |
| | | #if UNITY_WEBGL && !UNITY_EDITOR |
| | | try |
| | | { |
| | | WX_Init(); |
| | | _isInitialized = true; |
| | | Debug.Log("[WeChatPlatform] 微信SDK初始化成功"); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | Debug.LogError($"[WeChatPlatform] 微信SDK初始化失败: {e.Message}"); |
| | | return false; |
| | | } |
| | | #else |
| | | Debug.LogWarning("[WeChatPlatform] 非WebGL平台,使用模拟模式"); |
| | | _isInitialized = true; |
| | | #endif |
| | | // #if UNITY_WEBGL && !UNITY_EDITOR |
| | | // try |
| | | // { |
| | | // WX_Init(); |
| | | // _isInitialized = true; |
| | | // Debug.Log("[WeChatPlatform] 微信SDK初始化成功"); |
| | | // } |
| | | // catch (Exception e) |
| | | // { |
| | | // Debug.LogError($"[WeChatPlatform] 微信SDK初始化失败: {e.Message}"); |
| | | // return false; |
| | | // } |
| | | // #else |
| | | // Debug.LogWarning("[WeChatPlatform] 非WebGL平台,使用模拟模式"); |
| | | // _isInitialized = true; |
| | | // #endif |
| | | |
| | | await UniTask.Delay(100); |
| | | return true; |
| | | } |
| | | // await UniTask.Delay(100); |
| | | // return true; |
| | | // } |
| | | |
| | | public PlatformType GetPlatformType() |
| | | { |
| | | return PlatformType.WeChat; |
| | | } |
| | | // public PlatformType GetPlatformType() |
| | | // { |
| | | // return PlatformType.WeChat; |
| | | // } |
| | | |
| | | public async UniTask<LoginResult> LoginAsync() |
| | | { |
| | | Debug.Log("[WeChatPlatform] 微信登录"); |
| | | // public async UniTask<LoginResult> LoginAsync() |
| | | // { |
| | | // Debug.Log("[WeChatPlatform] 微信登录"); |
| | | |
| | | #if UNITY_WEBGL && !UNITY_EDITOR |
| | | // TODO: 实现回调机制 |
| | | // WX_Login("WeChatPlatform", "OnLoginCallback"); |
| | | await UniTask.Delay(1000); // 等待回调 |
| | | #else |
| | | await UniTask.Delay(500); |
| | | #endif |
| | | // #if UNITY_WEBGL && !UNITY_EDITOR |
| | | // // TODO: 实现回调机制 |
| | | // // WX_Login("WeChatPlatform", "OnLoginCallback"); |
| | | // await UniTask.Delay(1000); // 等待回调 |
| | | // #else |
| | | // await UniTask.Delay(500); |
| | | // #endif |
| | | |
| | | // 模拟登录成功(实际需要通过回调获取) |
| | | return new LoginResult |
| | | { |
| | | Success = true, |
| | | UserId = "wx_user_mock", |
| | | Nickname = "微信用户", |
| | | AvatarUrl = "https://example.com/avatar.jpg", |
| | | ErrorMessage = null |
| | | }; |
| | | } |
| | | // // 模拟登录成功(实际需要通过回调获取) |
| | | // return new LoginResult |
| | | // { |
| | | // Success = true, |
| | | // UserId = "wx_user_mock", |
| | | // Nickname = "微信用户", |
| | | // AvatarUrl = "https://example.com/avatar.jpg", |
| | | // ErrorMessage = null |
| | | // }; |
| | | // } |
| | | |
| | | public async UniTask<bool> ShareAsync(ShareData shareData) |
| | | { |
| | | Debug.Log($"[WeChatPlatform] 分享到微信: {shareData.Title}"); |
| | | // public async UniTask<bool> ShareAsync(ShareData shareData) |
| | | // { |
| | | // Debug.Log($"[WeChatPlatform] 分享到微信: {shareData.Title}"); |
| | | |
| | | #if UNITY_WEBGL && !UNITY_EDITOR |
| | | try |
| | | { |
| | | WX_ShareAppMessage(shareData.Title, shareData.ImageUrl); |
| | | await UniTask.Delay(300); |
| | | return true; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | Debug.LogError($"[WeChatPlatform] 分享失败: {e.Message}"); |
| | | return false; |
| | | } |
| | | #else |
| | | await UniTask.Delay(300); |
| | | return true; |
| | | #endif |
| | | } |
| | | // #if UNITY_WEBGL && !UNITY_EDITOR |
| | | // try |
| | | // { |
| | | // WX_ShareAppMessage(shareData.Title, shareData.ImageUrl); |
| | | // await UniTask.Delay(300); |
| | | // return true; |
| | | // } |
| | | // catch (Exception e) |
| | | // { |
| | | // Debug.LogError($"[WeChatPlatform] 分享失败: {e.Message}"); |
| | | // return false; |
| | | // } |
| | | // #else |
| | | // await UniTask.Delay(300); |
| | | // return true; |
| | | // #endif |
| | | // } |
| | | |
| | | public async UniTask<AdResult> ShowAdAsync(AdType adType) |
| | | { |
| | | Debug.Log($"[WeChatPlatform] 显示微信广告: {adType}"); |
| | | // public async UniTask<AdResult> ShowAdAsync(AdType adType) |
| | | // { |
| | | // Debug.Log($"[WeChatPlatform] 显示微信广告: {adType}"); |
| | | |
| | | #if UNITY_WEBGL && !UNITY_EDITOR |
| | | // TODO: 实现广告回调 |
| | | string adUnitId = GetAdUnitId(adType); |
| | | // WX_CreateRewardedVideoAd(adUnitId, "WeChatPlatform", "OnAdCallback"); |
| | | await UniTask.Delay(3000); |
| | | #else |
| | | await UniTask.Delay(2000); |
| | | #endif |
| | | // #if UNITY_WEBGL && !UNITY_EDITOR |
| | | // // TODO: 实现广告回调 |
| | | // string adUnitId = GetAdUnitId(adType); |
| | | // // WX_CreateRewardedVideoAd(adUnitId, "WeChatPlatform", "OnAdCallback"); |
| | | // await UniTask.Delay(3000); |
| | | // #else |
| | | // await UniTask.Delay(2000); |
| | | // #endif |
| | | |
| | | return new AdResult |
| | | { |
| | | Success = true, |
| | | Completed = true, |
| | | ErrorMessage = null |
| | | }; |
| | | } |
| | | // return new AdResult |
| | | // { |
| | | // Success = true, |
| | | // Completed = true, |
| | | // ErrorMessage = null |
| | | // }; |
| | | // } |
| | | |
| | | public async UniTask<bool> SaveDataAsync(string key, string value) |
| | | { |
| | | Debug.Log($"[WeChatPlatform] 保存数据到微信存储: {key}"); |
| | | // public async UniTask<bool> SaveDataAsync(string key, string value) |
| | | // { |
| | | // Debug.Log($"[WeChatPlatform] 保存数据到微信存储: {key}"); |
| | | |
| | | #if UNITY_WEBGL && !UNITY_EDITOR |
| | | try |
| | | { |
| | | WX_SetStorageSync(key, value); |
| | | await UniTask.Delay(50); |
| | | return true; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | Debug.LogError($"[WeChatPlatform] 保存数据失败: {e.Message}"); |
| | | return false; |
| | | } |
| | | #else |
| | | await UniTask.Delay(50); |
| | | PlayerPrefs.SetString(key, value); |
| | | PlayerPrefs.Save(); |
| | | return true; |
| | | #endif |
| | | } |
| | | // #if UNITY_WEBGL && !UNITY_EDITOR |
| | | // try |
| | | // { |
| | | // WX_SetStorageSync(key, value); |
| | | // await UniTask.Delay(50); |
| | | // return true; |
| | | // } |
| | | // catch (Exception e) |
| | | // { |
| | | // Debug.LogError($"[WeChatPlatform] 保存数据失败: {e.Message}"); |
| | | // return false; |
| | | // } |
| | | // #else |
| | | // await UniTask.Delay(50); |
| | | // PlayerPrefs.SetString(key, value); |
| | | // PlayerPrefs.Save(); |
| | | // return true; |
| | | // #endif |
| | | // } |
| | | |
| | | public async UniTask<string> LoadDataAsync(string key) |
| | | { |
| | | Debug.Log($"[WeChatPlatform] 从微信存储加载数据: {key}"); |
| | | // public async UniTask<string> LoadDataAsync(string key) |
| | | // { |
| | | // Debug.Log($"[WeChatPlatform] 从微信存储加载数据: {key}"); |
| | | |
| | | #if UNITY_WEBGL && !UNITY_EDITOR |
| | | try |
| | | { |
| | | await UniTask.Delay(50); |
| | | return WX_GetStorageSync(key); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | Debug.LogError($"[WeChatPlatform] 加载数据失败: {e.Message}"); |
| | | return null; |
| | | } |
| | | #else |
| | | await UniTask.Delay(50); |
| | | return PlayerPrefs.GetString(key, null); |
| | | #endif |
| | | } |
| | | // #if UNITY_WEBGL && !UNITY_EDITOR |
| | | // try |
| | | // { |
| | | // await UniTask.Delay(50); |
| | | // return WX_GetStorageSync(key); |
| | | // } |
| | | // catch (Exception e) |
| | | // { |
| | | // Debug.LogError($"[WeChatPlatform] 加载数据失败: {e.Message}"); |
| | | // return null; |
| | | // } |
| | | // #else |
| | | // await UniTask.Delay(50); |
| | | // return PlayerPrefs.GetString(key, null); |
| | | // #endif |
| | | // } |
| | | |
| | | public async UniTask<string> DownloadFileAsync(string url, string localPath, Action<float> onProgress = null) |
| | | { |
| | | Debug.Log($"[WeChatPlatform] 下载文件: {url}"); |
| | | // public async UniTask<string> DownloadFileAsync(string url, string localPath, Action<float> onProgress = null) |
| | | // { |
| | | // Debug.Log($"[WeChatPlatform] 下载文件: {url}"); |
| | | |
| | | // TODO: 实现微信文件下载API |
| | | // wx.downloadFile({ url, success, fail }) |
| | | // // TODO: 实现微信文件下载API |
| | | // // wx.downloadFile({ url, success, fail }) |
| | | |
| | | // 模拟下载 |
| | | for (int i = 0; i <= 10; i++) |
| | | { |
| | | await UniTask.Delay(100); |
| | | onProgress?.Invoke(i / 10f); |
| | | } |
| | | // // 模拟下载 |
| | | // for (int i = 0; i <= 10; i++) |
| | | // { |
| | | // await UniTask.Delay(100); |
| | | // onProgress?.Invoke(i / 10f); |
| | | // } |
| | | |
| | | return localPath; |
| | | } |
| | | // return localPath; |
| | | // } |
| | | |
| | | public SystemInfo GetSystemInfo() |
| | | { |
| | | if (_cachedSystemInfo == null) |
| | | { |
| | | #if UNITY_WEBGL && !UNITY_EDITOR |
| | | // TODO: 从微信API获取系统信息 |
| | | // WX_GetSystemInfo("WeChatPlatform", "OnSystemInfoCallback"); |
| | | #endif |
| | | // public SystemInfo GetSystemInfo() |
| | | // { |
| | | // if (_cachedSystemInfo == null) |
| | | // { |
| | | // #if UNITY_WEBGL && !UNITY_EDITOR |
| | | // // TODO: 从微信API获取系统信息 |
| | | // // WX_GetSystemInfo("WeChatPlatform", "OnSystemInfoCallback"); |
| | | // #endif |
| | | |
| | | _cachedSystemInfo = new SystemInfo |
| | | { |
| | | DeviceModel = UnityEngine.SystemInfo.deviceModel, |
| | | SystemVersion = UnityEngine.SystemInfo.operatingSystem, |
| | | PlatformVersion = "WeChat 8.0.0", |
| | | ScreenWidth = Screen.width, |
| | | ScreenHeight = Screen.height, |
| | | SafeArea = SafeAreaData.FromRect(Screen.safeArea), |
| | | PixelRatio = Screen.dpi / 160f |
| | | }; |
| | | } |
| | | // _cachedSystemInfo = new SystemInfo |
| | | // { |
| | | // DeviceModel = UnityEngine.SystemInfo.deviceModel, |
| | | // SystemVersion = UnityEngine.SystemInfo.operatingSystem, |
| | | // PlatformVersion = "WeChat 8.0.0", |
| | | // ScreenWidth = Screen.width, |
| | | // ScreenHeight = Screen.height, |
| | | // SafeArea = SafeAreaData.FromRect(Screen.safeArea), |
| | | // PixelRatio = Screen.dpi / 160f |
| | | // }; |
| | | // } |
| | | |
| | | return _cachedSystemInfo; |
| | | } |
| | | // return _cachedSystemInfo; |
| | | // } |
| | | |
| | | public void Vibrate(VibrationType vibrationType) |
| | | { |
| | | Debug.Log($"[WeChatPlatform] 震动: {vibrationType}"); |
| | | // public void Vibrate(VibrationType vibrationType) |
| | | // { |
| | | // Debug.Log($"[WeChatPlatform] 震动: {vibrationType}"); |
| | | |
| | | #if UNITY_WEBGL && !UNITY_EDITOR |
| | | try |
| | | { |
| | | if (vibrationType == VibrationType.Heavy) |
| | | WX_VibrateLong(); |
| | | else |
| | | WX_VibrateShort(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | Debug.LogError($"[WeChatPlatform] 震动失败: {e.Message}"); |
| | | } |
| | | #endif |
| | | } |
| | | // #if UNITY_WEBGL && !UNITY_EDITOR |
| | | // try |
| | | // { |
| | | // if (vibrationType == VibrationType.Heavy) |
| | | // WX_VibrateLong(); |
| | | // else |
| | | // WX_VibrateShort(); |
| | | // } |
| | | // catch (Exception e) |
| | | // { |
| | | // Debug.LogError($"[WeChatPlatform] 震动失败: {e.Message}"); |
| | | // } |
| | | // #endif |
| | | // } |
| | | |
| | | private string GetAdUnitId(AdType adType) |
| | | { |
| | | // TODO: 从配置文件读取广告位ID |
| | | return adType switch |
| | | { |
| | | AdType.Video => "adunit-xxxxxx", |
| | | AdType.Banner => "adunit-yyyyyy", |
| | | AdType.Interstitial => "adunit-zzzzzz", |
| | | _ => "" |
| | | }; |
| | | } |
| | | } |
| | | // private string GetAdUnitId(AdType adType) |
| | | // { |
| | | // // TODO: 从配置文件读取广告位ID |
| | | // return adType switch |
| | | // { |
| | | // AdType.Video => "adunit-xxxxxx", |
| | | // AdType.Banner => "adunit-yyyyyy", |
| | | // AdType.Interstitial => "adunit-zzzzzz", |
| | | // _ => "" |
| | | // }; |
| | | // } |
| | | // } |
| | |
| | | {
|
| | | launchWin.FadeOut();
|
| | | }
|
| | | SwitchToLoginScene();
|
| | | SwitchToLoginScene().Forget();
|
| | | }
|
| | |
|
| | | private static async void SwitchToLoginScene()
|
| | | private static async UniTask SwitchToLoginScene()
|
| | | {
|
| | | // Debug.Log("打开登录界面");
|
| | | // UIManager.Instance.OpenWindowAsync<LoginWin>().Forget();
|
| | |
| | | LoadingWin loadingWin = await UIManager.Instance.OpenWindowAsync<LoadingWin>();
|
| | | InitLoadingWinData(loadingWin);
|
| | |
|
| | | // Phase 1 (0% ~ 30%): YooAsset resource preload
|
| | | if (AssetSource.isUseAssetBundle)
|
| | | {
|
| | | loadingWin.SetProgress(0.05f);
|
| | | await YooAssetService.Instance.LoadAllAssetsAsync<UnityEngine.Object>("Assets/ResourcesOut/Scenes/Login");
|
| | | loadingWin.SetProgress(0.3f);
|
| | | }
|
| | |
|
| | | // Phase 2 (30% ~ 60%): Scene loading
|
| | | // Phase 1 (0% ~ 60%): Scene loading
|
| | | AsyncOperation asyncOperation = SceneManager.LoadSceneAsync("Login");
|
| | | asyncOperation.allowSceneActivation = false;
|
| | |
|
| | |
| | | {
|
| | | asyncOperation.allowSceneActivation = true;
|
| | | }
|
| | | loadingWin.SetProgress(0.3f + asyncOperation.progress * 0.3f);
|
| | | loadingWin.SetProgress(asyncOperation.progress * 0.5f);
|
| | | await UniTask.Yield();
|
| | | }
|
| | |
|
| | | // Phase 3 (60% ~ 100%): Manager initialization
|
| | | await WaitForManagerProgress(loadingWin, 0.6f, 1.0f,
|
| | | // Phase 2 (50% ~ 100%): Manager initialization
|
| | | await WaitForManagerProgress(loadingWin, 0.5f, 1.0f,
|
| | | ConfigManager.Instance.GetLoadingProgress, Main.InitManagers);
|
| | |
|
| | | loadingWin.SetProgress(1f, true);
|
| | |
| | |
|
| | | currentStage = StageName.Login;
|
| | |
|
| | | UIManager.Instance.OpenWindowAsync<LaunchBackGroundWin>().Forget();
|
| | | UIManager.Instance.OpenWindowAsync<LoginWin>().Forget();
|
| | | UIManager.Instance.OpenWindowAsync<LaunchBackGroundWin>().ContinueWith(s => {
|
| | | UIManager.Instance.OpenWindowAsync<LoginWin>().Forget();
|
| | | DumpLoginSceneDiagnostics("ToLoginScene open triggered").ContinueWith(() => {
|
| | | if (VersionUtility.Instance.NeedDownAsset() && !AssetVersionUtility.hasDownLoadFullAsset)
|
| | | {
|
| | | DownloadHotMgr.Instance.ClearDownloadCache();
|
| | | InGameDownLoad.Instance.inGameDownLoadAllow = true;
|
| | | InGameDownLoad.Instance.TryDownLoad(InGameDownLoad.Dominant.None);
|
| | | }
|
| | | }).Forget();
|
| | | }).Forget();
|
| | |
|
| | | if (VersionUtility.Instance.NeedDownAsset() && !AssetVersionUtility.hasDownLoadFullAsset)
|
| | | {
|
| | | DownloadHotMgr.Instance.ClearDownloadCache();
|
| | | InGameDownLoad.Instance.inGameDownLoadAllow = true;
|
| | | InGameDownLoad.Instance.TryDownLoad(InGameDownLoad.Dominant.None);
|
| | | }
|
| | |
|
| | |
|
| | | }
|
| | |
|
| | | // 返回登录界面 如断线
|
| | | public void ReturnToLoginScene()
|
| | | public async UniTaskVoid ReturnToLoginScene()
|
| | | {
|
| | | UIManager.Instance.DestroyAllUI();
|
| | |
|
| | | SceneManager.LoadSceneAsync("Login");
|
| | | await SceneManager.LoadSceneAsync("Login");
|
| | |
|
| | | Main.OnSwitchToLoginScene();
|
| | | currentStage = StageName.Login;
|
| | | UIManager.Instance.OpenWindowAsync<LaunchBackGroundWin>().Forget();
|
| | | UIManager.Instance.OpenWindowAsync<LoginWin>().Forget();
|
| | |
|
| | | if (ServerForceExitHintWin.reason != 0)
|
| | | {
|
| | | UIManager.Instance.OpenWindowAsync<ServerForceExitHintWin>().Forget();
|
| | | }
|
| | | // SoundPlayer.Instance.StopBackGroundMusic();
|
| | | SoundPlayer.Instance.PlayLoginMusic();
|
| | | UIManager.Instance.OpenWindowAsync<LaunchBackGroundWin>().ContinueWith(s => {
|
| | | UIManager.Instance.OpenWindowAsync<LoginWin>().Forget();
|
| | | DumpLoginSceneDiagnostics("ToLoginScene open triggered").ContinueWith(() => {
|
| | | if (ServerForceExitHintWin.reason != 0)
|
| | | {
|
| | | UIManager.Instance.OpenWindowAsync<ServerForceExitHintWin>().Forget();
|
| | | }
|
| | | // SoundPlayer.Instance.StopBackGroundMusic();
|
| | | SoundPlayer.Instance.PlayLoginMusic();
|
| | | }).Forget();
|
| | | }).Forget();
|
| | | }
|
| | |
|
| | | private async UniTask DumpLoginSceneDiagnostics(string context)
|
| | | {
|
| | | await UniTask.DelayFrame(2);
|
| | | UIManager.Instance.DumpUIDiagnostics(context + " after 2 frames");
|
| | | await UniTask.DelayFrame(30);
|
| | | UIManager.Instance.DumpUIDiagnostics(context + " after 32 frames");
|
| | | }
|
| | |
|
| | | protected float GetManagerRequestDataProgress()
|
| | |
| | | LoadingWin loadingWin = await UIManager.Instance.OpenWindowAsync<LoadingWin>();
|
| | | InitLoadingWinData(loadingWin);
|
| | |
|
| | | // Phase 1 (0% ~ 30%): YooAsset resource preload
|
| | | if (AssetSource.isUseAssetBundle)
|
| | | {
|
| | | loadingWin.SetProgress(0.05f);
|
| | | await YooAssetService.Instance.LoadAllAssetsAsync<UnityEngine.Object>("Assets/ResourcesOut/Scenes/Game");
|
| | | loadingWin.SetProgress(0.3f);
|
| | | }
|
| | |
|
| | | SoundPlayer.Instance.StopBackGroundMusic();
|
| | |
|
| | | // Phase 2 (30% ~ 60%): Scene loading
|
| | | // Phase 1 (0% ~ 60%): Scene loading
|
| | | AsyncOperation asyncOperation = SceneManager.LoadSceneAsync("Game");
|
| | | asyncOperation.allowSceneActivation = false;
|
| | |
|
| | |
| | | {
|
| | | asyncOperation.allowSceneActivation = true;
|
| | | }
|
| | | loadingWin.SetProgress(0.3f + asyncOperation.progress * 0.3f);
|
| | | loadingWin.SetProgress(asyncOperation.progress * 0.5f);
|
| | | await UniTask.Yield();
|
| | | }
|
| | |
|
| | | // Phase 3 (60% ~ 100%): Manager data ready
|
| | | await WaitForManagerProgress(loadingWin, 0.6f, 1.0f,
|
| | | // Phase 2 (50% ~ 100%): Manager data ready
|
| | | await WaitForManagerProgress(loadingWin, 0.5f, 1.0f,
|
| | | () => (DTC0403_tagPlayerLoginLoadOK.finishedLogin ? .5f : 0f) + GetManagerRequestDataProgress() * .5f);
|
| | |
|
| | | loadingWin.SetProgress(1f, true);
|
| | |
| | | using System.Linq; |
| | | using DG.Tweening; |
| | | using Cysharp.Threading.Tasks; |
| | | using UnityEngine.EventSystems; |
| | | |
| | | /// <summary> |
| | | /// UI管理器 - 负责管理所有UI界面的显示、隐藏和层级 |
| | |
| | | Debug.LogError("无法找到UI根节点"); |
| | | return; |
| | | } |
| | | GameObject.DontDestroyOnLoad(root); |
| | | } |
| | | |
| | | // 无论是从场景找到还是新实例化的,都确保跨场景不被销毁 |
| | | GameObject.DontDestroyOnLoad(root); |
| | | |
| | | uiRoot = root.transform; |
| | | uiRoot.position = Vector3.zero; |
| | |
| | | layerTransformCache.Add(UILayer.Mid, midTrans); |
| | | layerTransformCache.Add(UILayer.System, systemTrans); |
| | | layerTransformCache.Add(UILayer.Loading, loadingTrans); |
| | | |
| | | LogUIRootEventSystemState("InitUIRoot"); |
| | | } |
| | | |
| | | public Transform GetUIRoot() |
| | |
| | | Debug.LogError("无法加载UI根节点"); |
| | | return; |
| | | } |
| | | GameObject.DontDestroyOnLoad(root); |
| | | } |
| | | |
| | | // 无论是从场景找到还是新实例化的,都确保跨场景不被销毁 |
| | | GameObject.DontDestroyOnLoad(root); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | } |
| | | } |
| | | |
| | | public void DumpUIDiagnostics(string context) |
| | | { |
| | | var eventSystem = EventSystem.current; |
| | | Debug.Log($"[UIManager][Diag] {context} EventSystem={(eventSystem != null ? eventSystem.name : "<null>")} selected={(eventSystem != null && eventSystem.currentSelectedGameObject != null ? eventSystem.currentSelectedGameObject.name : "<null>")} loadingIndicatorActive={(_loadingIndicatorGO != null && _loadingIndicatorGO.activeSelf)} loadingRefCount={_loadingRefCount} uiStackCount={uiStack.Count}"); |
| | | LogUIRootEventSystemState(context); |
| | | |
| | | var uiArray = new UIBase[uiStack.Count]; |
| | | uiStack.CopyTo(uiArray, 0); |
| | | foreach (var ui in uiArray) |
| | | { |
| | | if (ui == null) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | var uiCanvas = ui.GetComponent<Canvas>(); |
| | | var uiCanvasGroup = ui.GetComponent<CanvasGroup>(); |
| | | Debug.Log($"[UIManager][Diag] {context} ui={ui.GetType().Name} active={ui.gameObject.activeInHierarchy} layer={ui.uiLayer} sortingOrder={(uiCanvas != null ? uiCanvas.sortingOrder : -1)} siblingIndex={ui.transform.GetSiblingIndex()} canvasGroup.blocksRaycasts={(uiCanvasGroup != null ? uiCanvasGroup.blocksRaycasts : false)} canvasGroup.interactable={(uiCanvasGroup != null ? uiCanvasGroup.interactable : false)}"); |
| | | } |
| | | } |
| | | |
| | | private void LogUIRootEventSystemState(string context) |
| | | { |
| | | if (uiRoot == null) |
| | | { |
| | | Debug.Log($"[UIManager][Diag] {context} uiRoot=<null>"); |
| | | return; |
| | | } |
| | | |
| | | var eventSystemTransform = uiRoot.Find("EventSystem"); |
| | | if (eventSystemTransform == null) |
| | | { |
| | | Debug.Log($"[UIManager][Diag] {context} uiRoot.EventSystem child=<null>"); |
| | | return; |
| | | } |
| | | |
| | | var eventSystemComponent = eventSystemTransform.GetComponent<EventSystem>(); |
| | | var standaloneInputModule = eventSystemTransform.GetComponent<StandaloneInputModule>(); |
| | | var baseInputModule = eventSystemTransform.GetComponent<BaseInputModule>(); |
| | | Debug.Log($"[UIManager][Diag] {context} uiRoot.EventSystem childExists=true activeSelf={eventSystemTransform.gameObject.activeSelf} activeInHierarchy={eventSystemTransform.gameObject.activeInHierarchy} eventSystemComponent={(eventSystemComponent != null)} standaloneInputModule={(standaloneInputModule != null)} baseInputModuleType={(baseInputModule != null ? baseInputModule.GetType().Name : "<null>")} currentMatchesChild={(EventSystem.current == eventSystemComponent)}"); |
| | | } |
| | | |
| | | private void EnsureLoadingIndicator() |
| | | { |
| | | if (_loadingIndicatorGO != null) return; |
| | |
| | | // 遍历UI栈,设置排序顺序 |
| | | UIBase[] uiArray = new UIBase[uiStack.Count]; |
| | | uiStack.CopyTo(uiArray, 0); |
| | | |
| | | // WebGL/IL2CPP 下被 Destroy 的对象访问任何属性都会 NullReferenceException, |
| | | // 必须在使用前过滤掉(Unity 伪 null:C# 引用非 null 但 == null 为 true) |
| | | uiArray = System.Array.FindAll(uiArray, ui => ui != null); |
| | | |
| | | // 先按照UILayer进行排序,然后再按照栈顺序排序 |
| | | Dictionary<UIBase, int> uiOrderDict = new Dictionary<UIBase, int>(); |
| | |
| | | |
| | | Array.Sort(uiArray, (a, b) => |
| | | { |
| | | if (a == null || b == null) return 0; |
| | | int layerCompare = a.uiLayer.CompareTo(b.uiLayer); |
| | | if (layerCompare != 0) |
| | | return layerCompare; |
| | |
| | | // 遍历排序后的UI数组,设置排序顺序 |
| | | foreach (var ui in uiArray) |
| | | { |
| | | if (ui == null) continue; |
| | | // 获取基础排序顺序 |
| | | int baseSortingOrder = GetBaseSortingOrderForLayer(ui.uiLayer); |
| | | // 计算当前UI的排序顺序 |
| | |
| | | public static async UniTask<Sprite> LoadSpriteAsync(string name, CancellationToken ct = default) |
| | | { |
| | | var path = StringUtility.Concat("Assets/ResourcesOut/BuiltIn/Sprites/", name, SPRITE_EXTENSION); |
| | | return await YooAssetService.Instance.LoadAssetAsync<Sprite>(path, ct: ct); |
| | | var sprite = await YooAssetService.Instance.LoadAssetAsync<Sprite>(path, ct: ct); |
| | | #if UNITY_WEBGL |
| | | if (sprite == null) |
| | | Debug.LogWarning($"[BuiltInLoader][WebGL-Diag] Sprite load returned NULL: path={path}"); |
| | | #endif |
| | | return sprite; |
| | | } |
| | | |
| | | public static async UniTask<GameObject> LoadPrefabAsync(string name, CancellationToken ct = default) |
| | |
| | | /// </summary> |
| | | public static int GetCacheSizeLimitMB() |
| | | { |
| | | var platform = PlatformFactory.GetCurrent(); |
| | | switch (platform.GetPlatformType()) |
| | | { |
| | | case PlatformType.WeChat: |
| | | return 200; // 微信小游戏用户数据上限约 200MB |
| | | case PlatformType.Douyin: |
| | | return 200; // 抖音小游戏类似限制 |
| | | case PlatformType.Vivo: |
| | | return 100; // Vivo 限制较小 |
| | | default: |
| | | return 1024; // Standalone 无严格限制 |
| | | } |
| | | return 1024; |
| | | // var platform = PlatformFactory.GetCurrent(); |
| | | // switch (platform.GetPlatformType()) |
| | | // { |
| | | // case PlatformType.WeChat: |
| | | // return 200; // 微信小游戏用户数据上限约 200MB |
| | | // case PlatformType.Douyin: |
| | | // return 200; // 抖音小游戏类似限制 |
| | | // case PlatformType.Vivo: |
| | | // return 100; // Vivo 限制较小 |
| | | // default: |
| | | // return 1024; // Standalone 无严格限制 |
| | | // } |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <param name="baseCdnUrl">基础 CDN 地址(如 https://cdn.example.com)</param> |
| | | /// <param name="fallbackCdnUrl">备用 CDN 地址(可选,默认同 baseCdnUrl)</param> |
| | | /// <returns>平台对应的 RemoteServicesImpl 实例</returns> |
| | | public static RemoteServicesImpl CreateForCurrentPlatform(string baseCdnUrl, string fallbackCdnUrl = null) |
| | | { |
| | | fallbackCdnUrl = fallbackCdnUrl ?? baseCdnUrl; |
| | | // public static RemoteServicesImpl CreateForCurrentPlatform(string baseCdnUrl, string fallbackCdnUrl = null) |
| | | // { |
| | | // fallbackCdnUrl = fallbackCdnUrl ?? baseCdnUrl; |
| | | |
| | | var platform = PlatformFactory.GetCurrent(); |
| | | var platformType = platform.GetPlatformType(); |
| | | // var platform = PlatformFactory.GetCurrent(); |
| | | // var platformType = platform.GetPlatformType(); |
| | | |
| | | // 按平台类型路由子路径 |
| | | string platformPath = GetPlatformCdnPath(platformType); |
| | | // // 按平台类型路由子路径 |
| | | // string platformPath = GetPlatformCdnPath(platformType); |
| | | |
| | | string mainUrl = $"{baseCdnUrl}/{platformPath}"; |
| | | string fallbackUrl = $"{fallbackCdnUrl}/{platformPath}"; |
| | | // string mainUrl = $"{baseCdnUrl}/{platformPath}"; |
| | | // string fallbackUrl = $"{fallbackCdnUrl}/{platformPath}"; |
| | | |
| | | UnityEngine.Debug.Log($"[RemoteServicesImpl] Platform={platformType}, CDN={mainUrl}"); |
| | | return new RemoteServicesImpl(mainUrl, fallbackUrl); |
| | | } |
| | | // UnityEngine.Debug.Log($"[RemoteServicesImpl] Platform={platformType}, CDN={mainUrl}"); |
| | | // return new RemoteServicesImpl(mainUrl, fallbackUrl); |
| | | // } |
| | | |
| | | /// <summary> |
| | | /// 获取平台对应的 CDN 子路径。 |
| | |
| | | |
| | | public async UniTask<T> LoadAssetAsync<T>(string directory, string name, bool needExt = true) where T : UnityEngine.Object |
| | | { |
| | | // 新版直接走 YooAsset/异步加载 |
| | | // 这里假设有 YooAssetService.Instance.LoadAssetAsync<T>(...) 可用 |
| | | string path = directory.EndsWith("/") ? directory + name : directory + "/" + name; |
| | | return await YooAssetService.Instance.LoadAssetAsync<T>(path); |
| | | return await LoadAssetAsync<T>(directory, name, needExt, CancellationToken.None); |
| | | } |
| | | |
| | | private void LoadSpriteAsync<T>(string atlasName, string spriteName, Action<bool, UnityEngine.Object> callBack) where T : UnityEngine.Object |
| | |
| | | |
| | | public void UnloadAsset(string directory, string assetName) |
| | | { |
| | | string path = directory.EndsWith("/") ? directory + assetName : directory + "/" + assetName; |
| | | directory = directory.Replace("\\", "/").TrimEnd('/'); |
| | | assetName = assetName.Replace("\\", "/"); |
| | | string path = ($"Assets/ResourcesOut/{directory}/{assetName}").Replace("//", "/"); |
| | | YooAssetService.Instance.UnloadAsset(path); |
| | | } |
| | | |
| | |
| | | |
| | | var path = ($"Assets/ResourcesOut/{directory}/{name}" + (needExt ? GetExtension(typeof(T)) : "")) |
| | | .Replace("//", "/").Trim().Replace("\\", "/"); |
| | | |
| | | // 音频文件扩展名统一转小写,避免 .WAV/.MP3 大小写不匹配 |
| | | if (typeof(T) == typeof(AudioClip)) |
| | | { |
| | | var pathExt = System.IO.Path.GetExtension(path); |
| | | if (!string.IsNullOrEmpty(pathExt) && pathExt != pathExt.ToLower()) |
| | | path = path.Substring(0, path.Length - pathExt.Length) + pathExt.ToLower(); |
| | | } |
| | | if (!AssetSource.isUseAssetBundle) |
| | | { |
| | | #if UNITY_EDITOR |
| | |
| | | |
| | | var path = ($"Assets/ResourcesOut/{directory}/{name}" + (needExt ? GetExtension(typeof(T)) : "")) |
| | | .Replace("//", "/").Trim().Replace("\\", "/"); |
| | | |
| | | // 音频文件扩展名统一转小写,避免 .WAV/.MP3 大小写不匹配 |
| | | if (typeof(T) == typeof(AudioClip)) |
| | | { |
| | | var pathExt2 = System.IO.Path.GetExtension(path); |
| | | if (!string.IsNullOrEmpty(pathExt2) && pathExt2 != pathExt2.ToLower()) |
| | | path = path.Substring(0, path.Length - pathExt2.Length) + pathExt2.ToLower(); |
| | | } |
| | | if (!AssetSource.isUseAssetBundle) |
| | | { |
| | | #if UNITY_EDITOR |
| | |
| | | { |
| | | var path = $"Assets/ResourcesOut/{atlasName}/{spriteName}.png" |
| | | .Replace("//", "/").Trim().Replace("\\", "/"); |
| | | return await YooAssetService.Instance.LoadAssetAsync<Sprite>(path, ct: ct); |
| | | var sprite = await YooAssetService.Instance.LoadAssetAsync<Sprite>(path, ct: ct); |
| | | #if UNITY_WEBGL |
| | | if (sprite == null) |
| | | Debug.LogWarning($"[ResManager][WebGL-Diag] Sprite load returned NULL: path={path}"); |
| | | #endif |
| | | return sprite; |
| | | } |
| | | } |
| | | |
| | |
| | | /// 异步加载配置文件(UniTask 版本)。 |
| | | /// AB 模式使用 YooAsset RawFile 异步加载,非 AB 模式直接读文件。 |
| | | /// </summary> |
| | | public async UniTask<string[]> LoadConfigAsync(string name, CancellationToken ct = default) |
| | | public async UniTask<string[]> LoadConfigAsync(string name, bool needExt = true, CancellationToken ct = default) |
| | | { |
| | | // AB 模式(含 WebGL): 使用 YooAsset 加载配置文件 |
| | | if (AssetSource.isUseAssetBundle) |
| | | { |
| | | var location = $"Assets/ResourcesOut/Config/{name}.txt"; |
| | | // 判断一下是否原来已经包含.txt 配合 needExt 做兼容,避免调用方传入重复后缀导致路径错误 |
| | | if (name.EndsWith(".txt") && needExt) |
| | | { |
| | | name = name.Substring(0, name.Length - 4); |
| | | } |
| | | var location = $"Assets/ResourcesOut/Config/{name}" + (needExt ? ".txt" : ""); |
| | | try |
| | | { |
| | | #if UNITY_WEBGL |
| | |
| | | if (asset != null && !string.IsNullOrEmpty(asset.text)) |
| | | return asset.text.Split(new[] { "\r\n", "\n" }, System.StringSplitOptions.None); |
| | | #else |
| | | var text = await ProjSG.Resource.YooAssetService.Instance.LoadRawFileTextAsync(location, ct); |
| | | if (!string.IsNullOrEmpty(text)) |
| | | return text.Split(new[] { "\r\n", "\n" }, System.StringSplitOptions.None); |
| | | var textAsset = await ProjSG.Resource.YooAssetService.Instance.LoadAssetAsync<TextAsset>(location, 0, ct); |
| | | if (textAsset != null && !string.IsNullOrEmpty(textAsset.text)) |
| | | return textAsset.text.Split(new[] { "\r\n", "\n" }, System.StringSplitOptions.None); |
| | | #endif |
| | | } |
| | | catch (System.Exception ex) |
| | |
| | | |
| | | // 非 AB 模式: 直接读文件(Editor 开发模式) |
| | | #if UNITY_EDITOR |
| | | string path = ResourcesPath.CONFIG_FODLER + "/" + name + ".txt"; |
| | | string path = ResourcesPath.CONFIG_FODLER + "/" + name + (needExt ? ".txt" : ""); |
| | | return await UniTask.RunOnThreadPool(() => File.ReadAllLines(path)); |
| | | #else |
| | | return System.Array.Empty<string>(); |
| New file |
| | |
| | | using Cysharp.Threading.Tasks; |
| | | using UnityEngine; |
| | | using UnityEngine.U2D; |
| | | using ProjSG.Resource; |
| | | |
| | | /// <summary> |
| | | /// 注册 SpriteAtlasManager.atlasRequested 回调, |
| | | /// 当 Unity 运行时需要 SpriteAtlas (V2) 时通过 YooAsset 异步加载图集。 |
| | | /// |
| | | /// 根本原因:项目使用 63+ 个 SpriteAtlas V2 (.spriteatlasv2) 文件, |
| | | /// Prefab 中静态引用的 Sprite 在 AssetBundle 运行时需要通过此回调 |
| | | /// 加载对应的 SpriteAtlas 才能正确显示。 |
| | | /// 编辑器下 Unity 自动处理,但构建后(尤其 WebGL)必须手动处理。 |
| | | /// </summary> |
| | | public static class SpriteAtlasHandler |
| | | { |
| | | private static bool _registered; |
| | | |
| | | /// <summary> |
| | | /// 注册 atlasRequested 回调。应在 YooAsset 初始化完成后、UI 加载前调用。 |
| | | /// </summary> |
| | | public static void Register() |
| | | { |
| | | if (_registered) return; |
| | | _registered = true; |
| | | |
| | | SpriteAtlasManager.atlasRequested += OnAtlasRequested; |
| | | Debug.Log("[SpriteAtlasHandler] atlasRequested callback registered."); |
| | | } |
| | | |
| | | private static void OnAtlasRequested(string tag, System.Action<SpriteAtlas> callback) |
| | | { |
| | | Debug.Log($"[SpriteAtlasHandler] Atlas requested: tag='{tag}'"); |
| | | LoadAtlasAsync(tag, callback).Forget(); |
| | | } |
| | | |
| | | private static async UniTaskVoid LoadAtlasAsync(string tag, System.Action<SpriteAtlas> callback) |
| | | { |
| | | // 主目录: Assets/ResourcesOut/Sprite/{tag}.spriteatlasv2 (UI 包) |
| | | string location = $"Assets/ResourcesOut/Sprite/{tag}.spriteatlasv2"; |
| | | try |
| | | { |
| | | var atlas = await YooAssetService.Instance.LoadAssetAsync<SpriteAtlas>(location); |
| | | if (atlas != null) |
| | | { |
| | | Debug.Log($"[SpriteAtlasHandler] Loaded atlas '{tag}' from '{location}'"); |
| | | callback(atlas); |
| | | return; |
| | | } |
| | | } |
| | | catch (System.Exception ex) |
| | | { |
| | | Debug.LogWarning($"[SpriteAtlasHandler] Failed to load atlas from '{location}': {ex.Message}"); |
| | | } |
| | | |
| | | // 回退: Assets/ResourcesOut/BuiltIn/Sprites/{tag}.spriteatlasv2 (Builtin 包) |
| | | string builtinLocation = $"Assets/ResourcesOut/BuiltIn/Sprites/{tag}.spriteatlasv2"; |
| | | try |
| | | { |
| | | var atlas = await YooAssetService.Instance.LoadAssetAsync<SpriteAtlas>(builtinLocation); |
| | | if (atlas != null) |
| | | { |
| | | Debug.Log($"[SpriteAtlasHandler] Loaded atlas '{tag}' from '{builtinLocation}'"); |
| | | callback(atlas); |
| | | return; |
| | | } |
| | | } |
| | | catch (System.Exception ex) |
| | | { |
| | | Debug.LogWarning($"[SpriteAtlasHandler] Failed to load atlas from '{builtinLocation}': {ex.Message}"); |
| | | } |
| | | |
| | | Debug.LogError($"[SpriteAtlasHandler] Could not load SpriteAtlas for tag '{tag}'. " + |
| | | $"Searched: '{location}', '{builtinLocation}'"); |
| | | } |
| | | } |
| New file |
| | |
| | | fileFormatVersion: 2 |
| | | guid: 4cf80bc251fa65d4f89c015496c56db8 |
| | | MonoImporter: |
| | | externalObjects: {} |
| | | serializedVersion: 2 |
| | | defaultReferences: [] |
| | | executionOrder: 0 |
| | | icon: {instanceID: 0} |
| | | userData: |
| | | assetBundleName: |
| | | assetBundleVariant: |
| | |
| | | // ============================================================================ |
| | | // ============================================================================ |
| | | // YooAssetService.cs — YooAsset 封装服务 |
| | | // 实现 IYooAssetService 和 IYooAssetBridge,替代 AssetBundleUtility |
| | | // ============================================================================ |
| | |
| | | } |
| | | Debug.Log($"[YooAssetService] Initialized {_packages.Count}/{allPkgs.Length} packages with PlayMode={playMode}. " + |
| | | $"Active: [{string.Join(", ", _packages.Keys)}]"); |
| | | |
| | | #if UNITY_WEBGL |
| | | // WebGL 诊断:输出每个包的 Manifest 和 Bundle 详情 |
| | | DiagDumpPackageStatus(); |
| | | #endif |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | |
| | | var package = FindPackageForAsset(location); |
| | | |
| | | Debug.LogError($"[YooAssetService] LoadAssetAsync: Loading asset '{location}' of package '{package.PackageName}'."); |
| | | // Debug.LogError($"[YooAssetService] LoadAssetAsync: Loading asset '{location}' of package '{package.PackageName}'."); |
| | | |
| | | return await ExecuteWithRetryAsync(async () => |
| | | { |
| | |
| | | throw new InvalidOperationException($"LoadRawFileTextAsync failed for '{location}': {handle.LastError}"); |
| | | } |
| | | |
| | | #if UNITY_ANDROID && !UNITY_EDITOR |
| | | // 真机:StreamingAssets在apk内,需用UnityWebRequest读取 |
| | | string filePath = handle.GetRawFilePath(); |
| | | using var uwr = UnityEngine.Networking.UnityWebRequest.Get(filePath); |
| | | await uwr.SendWebRequest().ToUniTask(cancellationToken: ct); |
| | | if (uwr.result != UnityEngine.Networking.UnityWebRequest.Result.Success) |
| | | throw new InvalidOperationException($"LoadRawFileTextAsync UWR failed for '{location}': {uwr.error}"); |
| | | return uwr.downloadHandler.text; |
| | | #else |
| | | return handle.GetRawFileText(); |
| | | #endif |
| | | }, $"LoadRawFileTextAsync('{location}')", ct); |
| | | } |
| | | |
| | |
| | | throw new InvalidOperationException($"LoadRawFileBytesAsync failed for '{location}': {handle.LastError}"); |
| | | } |
| | | |
| | | #if UNITY_ANDROID && !UNITY_EDITOR |
| | | // 真机:StreamingAssets在apk内,需用UnityWebRequest读取 |
| | | string filePath = handle.GetRawFilePath(); |
| | | using var uwr = UnityEngine.Networking.UnityWebRequest.Get(filePath); |
| | | await uwr.SendWebRequest().ToUniTask(cancellationToken: ct); |
| | | if (uwr.result != UnityEngine.Networking.UnityWebRequest.Result.Success) |
| | | throw new InvalidOperationException($"LoadRawFileBytesAsync UWR failed for '{location}': {uwr.error}"); |
| | | return uwr.downloadHandler.data; |
| | | #else |
| | | return handle.GetRawFileData(); |
| | | #endif |
| | | }, $"LoadRawFileBytesAsync('{location}')", ct); |
| | | } |
| | | |
| | |
| | | var package = FindPackageForAsset(location); |
| | | return package.LoadAllAssetsSync<T>(location); |
| | | } |
| | | |
| | | #if UNITY_WEBGL |
| | | /// <summary> |
| | | /// WebGL 诊断:输出每个 YooAsset 包的初始化状态和资源数量。 |
| | | /// </summary> |
| | | private void DiagDumpPackageStatus() |
| | | { |
| | | var sb = new System.Text.StringBuilder(); |
| | | sb.AppendLine("[YooAssetService][WebGL-Diag] Package status dump:"); |
| | | foreach (var kv in _packages) |
| | | { |
| | | var pkg = kv.Value; |
| | | var status = pkg.InitializeStatus; |
| | | // 尝试获取清单中的资源信息数量 |
| | | int assetCount = 0; |
| | | try |
| | | { |
| | | // GetAssetInfos 返回该包所有资源信息 |
| | | var infos = pkg.GetAssetInfos(string.Empty); |
| | | assetCount = infos != null ? infos.Length : -1; |
| | | } |
| | | catch |
| | | { |
| | | assetCount = -1; |
| | | } |
| | | sb.AppendLine($" [{kv.Key}] status={status}, assetInfoCount={assetCount}"); |
| | | } |
| | | Debug.Log(sb.ToString()); |
| | | } |
| | | #endif |
| | | } |
| | | } |
| | |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | |
| | | public class SDKUtils : SingletonMonobehaviour<SDKUtils> |
| | |
| | | } |
| | | else |
| | | { |
| | | builtinAssetCopyFinished = VersionConfig.Get().version == builtinAssetsCopyFinishVersion; |
| | | builtinAssetCopyFinished = VersionConfig.config.version == builtinAssetsCopyFinishVersion; |
| | | } |
| | | #endif |
| | | #if UNITY_IOS || UNITY_STANDALONE |
| | |
| | | } |
| | | else |
| | | { |
| | | builtinAssetCopyFinished = VersionConfig.Get().version == builtinAssetsCopyFinishVersion; |
| | | builtinAssetCopyFinished = VersionConfig.config.version == builtinAssetsCopyFinishVersion; |
| | | } |
| | | |
| | | var assetsCopyFinishVersion = LocalSave.GetString("AssetCopyCompleted_IOSorStandalone"); |
| | |
| | | } |
| | | else |
| | | { |
| | | AssetCopyFinished = VersionConfig.Get().version == assetsCopyFinishVersion; |
| | | AssetCopyFinished = VersionConfig.config.version == assetsCopyFinishVersion; |
| | | } |
| | | |
| | | #elif UNITY_ANDROID |
| | | SyncClientPackageID(); |
| | | #endif |
| | | |
| | | InitFinished = false; |
| | | m_Json.Clear(); |
| | | m_Json["code"] = CodeU2A.Init; |
| | | m_Json["appID"] = VersionConfig.Get().appId; |
| | | m_Json["gameID"] = VersionConfig.Get().gameId; |
| | | SendMessageToSDK(m_Json); |
| | | if (Application.platform == RuntimePlatform.WebGLPlayer) |
| | | { |
| | | // WebGL 无原生 SDK 回调,直接标记完成 |
| | | InitFinished = true; |
| | | } |
| | | else |
| | | { |
| | | InitFinished = false; |
| | | m_Json.Clear(); |
| | | m_Json["code"] = CodeU2A.Init; |
| | | m_Json["appID"] = VersionConfig.config.appId; |
| | | m_Json["gameID"] = VersionConfig.config.gameId; |
| | | SendMessageToSDK(m_Json); |
| | | } |
| | | #endif |
| | | StartCoroutine("ProcessNetworkStatus"); |
| | | } |
| | |
| | | public void SyncClientPackageID() |
| | | { |
| | | #if UNITY_ANDROID |
| | | m_Json.Clear(); |
| | | m_Json["code"] = CodeU2A.ClientPackage; |
| | | m_Json["clientPkgID"] = VersionConfig.Get().clientPackageFlag; |
| | | SendMessageToSDK(m_Json); |
| | | VersionConfig.GetAsync().ContinueWith(config => |
| | | { |
| | | m_Json.Clear(); |
| | | m_Json["code"] = CodeU2A.ClientPackage; |
| | | m_Json["clientPkgID"] = config.clientPackageFlag; |
| | | SendMessageToSDK(m_Json); |
| | | }).Forget(); |
| | | #endif |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | if (!isBuyGameCash && gameCash >= money * 100) |
| | | { |
| | | VersionConfig.GetAsync().ContinueWith(config => |
| | | { |
| | | UIManager.Instance.CloseWindow<GotoChargeWin>(); |
| | | |
| | | UIManager.Instance.CloseWindow<GotoChargeWin>(); |
| | | if (DayRemind.Instance.GetDayRemind(DayRemind.DJQTip)) |
| | | { |
| | | var pack = new CA125_tagCMCoinBuyOrderInfo(); |
| | | pack.AppID = VersionConfig.Get().appId; |
| | | pack.AppIDLen = (byte)pack.AppID.Length; |
| | | pack.OrderInfo = cpInfo; |
| | | pack.OrderInfoLen = (byte)pack.OrderInfo.Length; |
| | | GameNetSystem.Instance.SendInfo(pack); |
| | | } |
| | | else |
| | | { |
| | | ConfirmCancel.ShowPopConfirm( |
| | | Language.Get("Mail101"), |
| | | Language.Get("GameCashRule1", money, title), |
| | | (bool isOk) => |
| | | { |
| | | if (isOk) |
| | | |
| | | if (DayRemind.Instance.GetDayRemind(DayRemind.DJQTip)) |
| | | { |
| | | var pack = new CA125_tagCMCoinBuyOrderInfo(); |
| | | pack.AppID = config.appId; |
| | | pack.AppIDLen = (byte)pack.AppID.Length; |
| | | pack.OrderInfo = cpInfo; |
| | | pack.OrderInfoLen = (byte)pack.OrderInfo.Length; |
| | | GameNetSystem.Instance.SendInfo(pack); |
| | | } |
| | | else |
| | | { |
| | | ConfirmCancel.ShowPopConfirm( |
| | | Language.Get("Mail101"), |
| | | Language.Get("GameCashRule1", money, title), |
| | | (bool isOk) => |
| | | { |
| | | var pack = new CA125_tagCMCoinBuyOrderInfo(); |
| | | pack.AppID = VersionConfig.Get().appId; |
| | | pack.AppIDLen = (byte)pack.AppID.Length; |
| | | pack.OrderInfo = cpInfo; |
| | | pack.OrderInfoLen = (byte)pack.OrderInfo.Length; |
| | | GameNetSystem.Instance.SendInfo(pack); |
| | | } |
| | | if (isOk) |
| | | { |
| | | var pack = new CA125_tagCMCoinBuyOrderInfo(); |
| | | pack.AppID = config.appId; |
| | | pack.AppIDLen = (byte)pack.AppID.Length; |
| | | pack.OrderInfo = cpInfo; |
| | | pack.OrderInfoLen = (byte)pack.OrderInfo.Length; |
| | | GameNetSystem.Instance.SendInfo(pack); |
| | | } |
| | | |
| | | }); |
| | | } |
| | | }); |
| | | } |
| | | }).Forget(); |
| | | |
| | | } |
| | | else |
| | | { |
| | |
| | | // string storeOrderInfo = orderInfo.StoreOrderInfo2; |
| | | //#endif |
| | | |
| | | #if UNITY_EDITOR |
| | | Debug.LogFormat("充值: {0}-{1}-{2}", title, money, cpInfo); |
| | | return; |
| | | #endif |
| | | VersionConfig.GetAsync().ContinueWith(config => |
| | | { |
| | | #if UNITY_EDITOR |
| | | Debug.LogFormat("充值: {0}-{1}-{2}", title, money, cpInfo); |
| | | return; |
| | | #endif |
| | | |
| | | m_Json.Clear(); |
| | | m_Json["code"] = CodeU2A.FreePlatformPay; |
| | | m_Json["orderId"] = DateTime.Now.ToString("yyyyMMddHHmmss") + UnityEngine.Random.Range(100000, 999999).ToString(); |
| | | m_Json["mount"] = money.ToString(); |
| | | m_Json["cpInfo"] = cpInfo; |
| | | //m_Json["storeOrderInfo"] = storeOrderInfo; |
| | | m_Json["title"] = title; |
| | | m_Json["roleID"] = PlayerDatas.Instance.baseData.PlayerID; |
| | | m_Json["roleName"] = PlayerDatas.Instance.baseData.PlayerName; |
| | | m_Json["level"] = PlayerDatas.Instance.baseData.LV.ToString(); |
| | | m_Json["sid"] = ServerListCenter.Instance.currentServer.region_flag; |
| | | m_Json["serverName"] = ServerListCenter.Instance.currentServer.name; |
| | | m_Json["familyName"] = PlayerDatas.Instance.baseData.FamilyName; |
| | | m_Json["job"] = PlayerDatas.Instance.baseData.Job.ToString(); |
| | | m_Json["money"] = PlayerDatas.Instance.baseData.diamond.ToString(); |
| | | m_Json["gameName"] = VersionConfig.Get().productName; |
| | | m_Json["vipLevel"] = PlayerDatas.Instance.baseData.VIPLv.ToString(); |
| | | m_Json["createTime"] = TimeUtility.CreateSeconds.ToString(); |
| | | m_Json["familyID"] = PlayerDatas.Instance.baseData.FamilyId.ToString(); |
| | | m_Json["fightPower"] = PlayerDatas.Instance.baseData.FightPower.ToString(); |
| | | m_Json.Clear(); |
| | | m_Json["code"] = CodeU2A.FreePlatformPay; |
| | | m_Json["orderId"] = DateTime.Now.ToString("yyyyMMddHHmmss") + UnityEngine.Random.Range(100000, 999999).ToString(); |
| | | m_Json["mount"] = money.ToString(); |
| | | m_Json["cpInfo"] = cpInfo; |
| | | //m_Json["storeOrderInfo"] = storeOrderInfo; |
| | | m_Json["title"] = title; |
| | | m_Json["roleID"] = PlayerDatas.Instance.baseData.PlayerID; |
| | | m_Json["roleName"] = PlayerDatas.Instance.baseData.PlayerName; |
| | | m_Json["level"] = PlayerDatas.Instance.baseData.LV.ToString(); |
| | | m_Json["sid"] = ServerListCenter.Instance.currentServer.region_flag; |
| | | m_Json["serverName"] = ServerListCenter.Instance.currentServer.name; |
| | | m_Json["familyName"] = PlayerDatas.Instance.baseData.FamilyName; |
| | | m_Json["job"] = PlayerDatas.Instance.baseData.Job.ToString(); |
| | | m_Json["money"] = PlayerDatas.Instance.baseData.diamond.ToString(); |
| | | m_Json["gameName"] = config.productName; |
| | | m_Json["vipLevel"] = PlayerDatas.Instance.baseData.VIPLv.ToString(); |
| | | m_Json["createTime"] = TimeUtility.CreateSeconds.ToString(); |
| | | m_Json["familyID"] = PlayerDatas.Instance.baseData.FamilyId.ToString(); |
| | | m_Json["fightPower"] = PlayerDatas.Instance.baseData.FightPower.ToString(); |
| | | |
| | | #if UNITY_IOS |
| | | m_Json["identifier"] = VersionConfig.Get().bundleIdentifier; |
| | | #endif |
| | | SendMessageToSDK(m_Json); |
| | | #if UNITY_IOS |
| | | m_Json["identifier"] = config.bundleIdentifier; |
| | | #endif |
| | | SendMessageToSDK(m_Json); |
| | | }).Forget(); |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | public void CreateRoleOk(string roleID, string roleName, string time) |
| | | { |
| | | m_Json.Clear(); |
| | | m_Json["code"] = CodeU2A.CreateRole; |
| | | VersionConfig.GetAsync().ContinueWith(config => |
| | | { |
| | | m_Json.Clear(); |
| | | m_Json["code"] = CodeU2A.CreateRole; |
| | | |
| | | m_Json["roleID"] = roleID; |
| | | m_Json["roleName"] = roleName; |
| | | m_Json["sid"] = ServerListCenter.Instance.currentServer.region_flag; |
| | | m_Json["serverName"] = ServerListCenter.Instance.currentServer.name; |
| | | m_Json["familyName"] = PlayerDatas.Instance.baseData.FamilyName; |
| | | m_Json["level"] = "1"; |
| | | m_Json["job"] = PlayerDatas.Instance.baseData.Job.ToString(); |
| | | m_Json["money"] = PlayerDatas.Instance.baseData.diamond.ToString(); |
| | | m_Json["gameName"] = VersionConfig.Get().productName; |
| | | m_Json["vipLevel"] = PlayerDatas.Instance.baseData.VIPLv.ToString(); |
| | | m_Json["createTime"] = time; |
| | | m_Json["familyID"] = PlayerDatas.Instance.baseData.FamilyId.ToString(); |
| | | m_Json["fightPower"] = PlayerDatas.Instance.baseData.FightPower.ToString(); |
| | | SendMessageToSDK(m_Json); |
| | | m_Json["roleID"] = roleID; |
| | | m_Json["roleName"] = roleName; |
| | | m_Json["sid"] = ServerListCenter.Instance.currentServer.region_flag; |
| | | m_Json["serverName"] = ServerListCenter.Instance.currentServer.name; |
| | | m_Json["familyName"] = PlayerDatas.Instance.baseData.FamilyName; |
| | | m_Json["level"] = "1"; |
| | | m_Json["job"] = PlayerDatas.Instance.baseData.Job.ToString(); |
| | | m_Json["money"] = PlayerDatas.Instance.baseData.diamond.ToString(); |
| | | m_Json["gameName"] = config.productName; |
| | | m_Json["vipLevel"] = PlayerDatas.Instance.baseData.VIPLv.ToString(); |
| | | m_Json["createTime"] = time; |
| | | m_Json["familyID"] = PlayerDatas.Instance.baseData.FamilyId.ToString(); |
| | | m_Json["fightPower"] = PlayerDatas.Instance.baseData.FightPower.ToString(); |
| | | SendMessageToSDK(m_Json); |
| | | }).Forget(); |
| | | } |
| | | |
| | | public void DownloadStart() |
| | |
| | | |
| | | public void RoleLogin() |
| | | { |
| | | m_Json.Clear(); |
| | | m_Json["code"] = CodeU2A.RoleLogin; |
| | | VersionConfig.GetAsync().ContinueWith(config => |
| | | { |
| | | m_Json.Clear(); |
| | | m_Json["code"] = CodeU2A.RoleLogin; |
| | | |
| | | m_Json["roleID"] = PlayerDatas.Instance.baseData.PlayerID.ToString(); |
| | | m_Json["roleName"] = PlayerDatas.Instance.baseData.PlayerName; |
| | | m_Json["sid"] = ServerListCenter.Instance.currentServer.region_flag; |
| | | m_Json["serverName"] = ServerListCenter.Instance.currentServer.name; |
| | | m_Json["familyName"] = PlayerDatas.Instance.baseData.FamilyName; |
| | | m_Json["level"] = PlayerDatas.Instance.baseData.LV; |
| | | m_Json["job"] = PlayerDatas.Instance.baseData.Job.ToString(); |
| | | m_Json["money"] = PlayerDatas.Instance.baseData.diamond.ToString(); |
| | | m_Json["gameName"] = VersionConfig.Get().productName; |
| | | m_Json["vipLevel"] = PlayerDatas.Instance.baseData.VIPLv.ToString(); |
| | | m_Json["createTime"] = TimeUtility.CreateSeconds.ToString(); |
| | | m_Json["familyID"] = PlayerDatas.Instance.baseData.FamilyId.ToString(); |
| | | m_Json["fightPower"] = PlayerDatas.Instance.baseData.FightPower.ToString(); |
| | | SendMessageToSDK(m_Json); |
| | | m_Json["roleID"] = PlayerDatas.Instance.baseData.PlayerID.ToString(); |
| | | m_Json["roleName"] = PlayerDatas.Instance.baseData.PlayerName; |
| | | m_Json["sid"] = ServerListCenter.Instance.currentServer.region_flag; |
| | | m_Json["serverName"] = ServerListCenter.Instance.currentServer.name; |
| | | m_Json["familyName"] = PlayerDatas.Instance.baseData.FamilyName; |
| | | m_Json["level"] = PlayerDatas.Instance.baseData.LV; |
| | | m_Json["job"] = PlayerDatas.Instance.baseData.Job.ToString(); |
| | | m_Json["money"] = PlayerDatas.Instance.baseData.diamond.ToString(); |
| | | m_Json["gameName"] = config.productName; |
| | | m_Json["vipLevel"] = PlayerDatas.Instance.baseData.VIPLv.ToString(); |
| | | m_Json["createTime"] = TimeUtility.CreateSeconds.ToString(); |
| | | m_Json["familyID"] = PlayerDatas.Instance.baseData.FamilyId.ToString(); |
| | | m_Json["fightPower"] = PlayerDatas.Instance.baseData.FightPower.ToString(); |
| | | SendMessageToSDK(m_Json); |
| | | }).Forget(); |
| | | } |
| | | |
| | | public void RoleLevelUp() |
| | | { |
| | | m_Json.Clear(); |
| | | m_Json["code"] = CodeU2A.RoleLevelUp; |
| | | VersionConfig.GetAsync().ContinueWith(config => |
| | | { |
| | | m_Json.Clear(); |
| | | m_Json["code"] = CodeU2A.RoleLevelUp; |
| | | |
| | | m_Json["roleID"] = PlayerDatas.Instance.PlayerId.ToString(); |
| | | m_Json["roleName"] = PlayerDatas.Instance.baseData.PlayerName; |
| | | m_Json["sid"] = ServerListCenter.Instance.currentServer.region_flag; |
| | | m_Json["serverName"] = ServerListCenter.Instance.currentServer.name; |
| | | m_Json["familyName"] = PlayerDatas.Instance.baseData.FamilyName; |
| | | m_Json["level"] = PlayerDatas.Instance.baseData.LV; |
| | | m_Json["job"] = PlayerDatas.Instance.baseData.Job.ToString(); |
| | | m_Json["money"] = PlayerDatas.Instance.baseData.diamond.ToString(); |
| | | m_Json["gameName"] = VersionConfig.Get().productName; |
| | | m_Json["vipLevel"] = PlayerDatas.Instance.baseData.VIPLv.ToString(); |
| | | m_Json["levelUpTime"] = TimeUtility.AllSeconds.ToString(); |
| | | m_Json["createTime"] = TimeUtility.CreateSeconds.ToString(); |
| | | m_Json["familyID"] = PlayerDatas.Instance.baseData.FamilyId.ToString(); |
| | | m_Json["fightPower"] = PlayerDatas.Instance.baseData.FightPower.ToString(); |
| | | SendMessageToSDK(m_Json); |
| | | m_Json["roleID"] = PlayerDatas.Instance.PlayerId.ToString(); |
| | | m_Json["roleName"] = PlayerDatas.Instance.baseData.PlayerName; |
| | | m_Json["sid"] = ServerListCenter.Instance.currentServer.region_flag; |
| | | m_Json["serverName"] = ServerListCenter.Instance.currentServer.name; |
| | | m_Json["familyName"] = PlayerDatas.Instance.baseData.FamilyName; |
| | | m_Json["level"] = PlayerDatas.Instance.baseData.LV; |
| | | m_Json["job"] = PlayerDatas.Instance.baseData.Job.ToString(); |
| | | m_Json["money"] = PlayerDatas.Instance.baseData.diamond.ToString(); |
| | | m_Json["gameName"] = config.productName; |
| | | m_Json["vipLevel"] = PlayerDatas.Instance.baseData.VIPLv.ToString(); |
| | | m_Json["levelUpTime"] = TimeUtility.AllSeconds.ToString(); |
| | | m_Json["createTime"] = TimeUtility.CreateSeconds.ToString(); |
| | | m_Json["familyID"] = PlayerDatas.Instance.baseData.FamilyId.ToString(); |
| | | m_Json["fightPower"] = PlayerDatas.Instance.baseData.FightPower.ToString(); |
| | | SendMessageToSDK(m_Json); |
| | | }).Forget(); |
| | | } |
| | | |
| | | |
| | |
| | | if (!DTC0403_tagPlayerLoginLoadOK.finishedLogin) |
| | | return; |
| | | |
| | | m_Json.Clear(); |
| | | m_Json["code"] = CodeU2A.RoleLoginOut; |
| | | VersionConfig.GetAsync().ContinueWith(config => |
| | | { |
| | | m_Json.Clear(); |
| | | m_Json["code"] = CodeU2A.RoleLoginOut; |
| | | |
| | | m_Json["roleID"] = PlayerDatas.Instance.PlayerId.ToString(); |
| | | m_Json["roleName"] = PlayerDatas.Instance.baseData.PlayerName; |
| | | m_Json["sid"] = ServerListCenter.Instance.currentServer.region_flag; |
| | | m_Json["serverName"] = ServerListCenter.Instance.currentServer.name; |
| | | m_Json["familyName"] = PlayerDatas.Instance.baseData.FamilyName; |
| | | m_Json["level"] = PlayerDatas.Instance.baseData.LV; |
| | | m_Json["job"] = PlayerDatas.Instance.baseData.Job.ToString(); |
| | | m_Json["money"] = PlayerDatas.Instance.baseData.diamond.ToString(); |
| | | m_Json["gameName"] = VersionConfig.Get().productName; |
| | | m_Json["vipLevel"] = PlayerDatas.Instance.baseData.VIPLv.ToString(); |
| | | m_Json["levelUpTime"] = TimeUtility.AllSeconds.ToString(); |
| | | m_Json["createTime"] = TimeUtility.CreateSeconds.ToString(); |
| | | m_Json["familyID"] = PlayerDatas.Instance.baseData.FamilyId.ToString(); |
| | | m_Json["fightPower"] = PlayerDatas.Instance.baseData.FightPower.ToString(); |
| | | SendMessageToSDK(m_Json); |
| | | m_Json["roleID"] = PlayerDatas.Instance.PlayerId.ToString(); |
| | | m_Json["roleName"] = PlayerDatas.Instance.baseData.PlayerName; |
| | | m_Json["sid"] = ServerListCenter.Instance.currentServer.region_flag; |
| | | m_Json["serverName"] = ServerListCenter.Instance.currentServer.name; |
| | | m_Json["familyName"] = PlayerDatas.Instance.baseData.FamilyName; |
| | | m_Json["level"] = PlayerDatas.Instance.baseData.LV; |
| | | m_Json["job"] = PlayerDatas.Instance.baseData.Job.ToString(); |
| | | m_Json["money"] = PlayerDatas.Instance.baseData.diamond.ToString(); |
| | | m_Json["gameName"] = config.productName; |
| | | m_Json["vipLevel"] = PlayerDatas.Instance.baseData.VIPLv.ToString(); |
| | | m_Json["levelUpTime"] = TimeUtility.AllSeconds.ToString(); |
| | | m_Json["createTime"] = TimeUtility.CreateSeconds.ToString(); |
| | | m_Json["familyID"] = PlayerDatas.Instance.baseData.FamilyId.ToString(); |
| | | m_Json["fightPower"] = PlayerDatas.Instance.baseData.FightPower.ToString(); |
| | | SendMessageToSDK(m_Json); |
| | | }).Forget(); |
| | | } |
| | | |
| | | public void GotoFansHouse() |
| | |
| | | using System; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using UnityEngine; |
| | |
| | | } |
| | | |
| | | |
| | | protected override void OpenSubUIByTabIndex() |
| | | protected override async void OpenSubUIByTabIndex() |
| | | { |
| | | ArenaManager.Instance.nowAwardTabIndex = functionOrder; |
| | | Display(); |
| | |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | | using System.IO; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | |
| | | public class AssetVersion |
| | |
| | | } |
| | | |
| | | |
| | | public bool IsPriorAsset() |
| | | public async UniTask<bool> IsPriorAsset() |
| | | { |
| | | if (VersionConfig.Get().partAssetPackage) |
| | | if ((await VersionConfig.GetAsync()).partAssetPackage) |
| | | { |
| | | //如果这台机器曾经完整的下载过所有资源,那么就不再使用分包下载策略,在资源热更新的时候这种情况会触发。 |
| | | if (AssetVersionUtility.hasDownLoadFullAsset) |
| | |
| | | } |
| | | public static void GetAssetVersionFile() |
| | | { |
| | | checkAssetCompleted = false; |
| | | Debug.LogFormat("开始获取资源版本文件:时间 {0}", DateTime.Now); |
| | | var assetVersionUrl = StringUtility.Concat(VersionUtility.Instance.versionInfo.GetResourcesURL(VersionConfig.Get().branch), Language.fixPath, "/AssetsVersion.txt"); |
| | | assetVerUrl = assetVersionUrl; |
| | | Debug.Log("http地址:assetVersionUrl " + assetVersionUrl); |
| | | HttpRequest.Instance.UnityWebRequestGet(assetVersionUrl, 5, OnGetAssetVersionFile); |
| | | VersionConfig.GetAsync().ContinueWith(config => |
| | | { |
| | | checkAssetCompleted = false; |
| | | Debug.LogFormat("开始获取资源版本文件:时间 {0}", DateTime.Now); |
| | | var assetVersionUrl = StringUtility.Concat(VersionUtility.Instance.versionInfo.GetResourcesURL(config.branch), Language.fixPath, "/AssetsVersion.txt"); |
| | | assetVerUrl = assetVersionUrl; |
| | | Debug.Log("http地址:assetVersionUrl " + assetVersionUrl); |
| | | HttpRequest.Instance.UnityWebRequestGet(assetVersionUrl, 5, OnGetAssetVersionFile); |
| | | }).Forget(); |
| | | |
| | | } |
| | | |
| | | private static void OnGetAssetVersionFile(bool _ok, string _result) |
| | | private static async void OnGetAssetVersionFile(bool _ok, string _result) |
| | | { |
| | | Debug.LogFormat("获取资源版本文件结果:时间 {0},结果 {1}, 文件大小 {2}", DateTime.Now, _ok, _result.Length); |
| | | if (_ok) |
| | | { |
| | | assetVersionsLocalMd5 = FileExtersion.GetStringMD5Hash(_result); |
| | | var assetVersions = UpdateAssetVersions(_result); |
| | | var assetVersions = await UpdateAssetVersions(_result); |
| | | BeginCheckAssets(); |
| | | } |
| | | else |
| | |
| | | if (InGameDownTestUtility.enable && !InGameDownTestUtility.isReadStreamingAssets) |
| | | checkStream = false; |
| | | #endif |
| | | BeginCheckAssetsAsync(checkStream).Forget(); |
| | | } |
| | | |
| | | ThreadPool.QueueUserWorkItem( |
| | | (object aaa) => |
| | | private static async UniTaskVoid BeginCheckAssetsAsync(bool checkStream) |
| | | { |
| | | int count = 0; |
| | | foreach (var assetVersion in assetVersions.Values) |
| | | { |
| | | bool checkReuslt; |
| | | if (checkStream) |
| | | { |
| | | foreach (var assetVersion in assetVersions.Values) |
| | | { |
| | | bool checkReuslt; |
| | | if (checkStream) |
| | | { |
| | | AssetVersion localAssetVersion = null; |
| | | localAssetVersions.TryGetValue(assetVersion.relativePath, out localAssetVersion); |
| | | checkReuslt = assetVersion.CheckLocalFileValid(localAssetVersion); |
| | | } |
| | | else |
| | | { |
| | | checkReuslt = assetVersion.CheckLocalFileValid(false); |
| | | } |
| | | if (!checkReuslt) |
| | | { |
| | | if (assetVersion.IsPriorAsset()) |
| | | { |
| | | priorDownLoadAssetVersions.Add(assetVersion); |
| | | } |
| | | else |
| | | { |
| | | unpriorDownLoadAssetVersions.Add(assetVersion); |
| | | } |
| | | |
| | | assetVersion.localValid = false; |
| | | } |
| | | else |
| | | { |
| | | assetVersion.localValid = true; |
| | | } |
| | | } |
| | | |
| | | m_PriorAssetDownLoadDone = priorDownLoadAssetVersions.Count <= 0; |
| | | m_UnPriorAssetDownLoadDone = unpriorDownLoadAssetVersions.Count <= 0; |
| | | |
| | | checkAssetCompleted = true; |
| | | AssetVersion localAssetVersion = null; |
| | | localAssetVersions.TryGetValue(assetVersion.relativePath, out localAssetVersion); |
| | | checkReuslt = assetVersion.CheckLocalFileValid(localAssetVersion); |
| | | } |
| | | ); |
| | | else |
| | | { |
| | | checkReuslt = assetVersion.CheckLocalFileValid(false); |
| | | } |
| | | |
| | | if (!checkReuslt) |
| | | { |
| | | if (await assetVersion.IsPriorAsset()) |
| | | priorDownLoadAssetVersions.Add(assetVersion); |
| | | else |
| | | unpriorDownLoadAssetVersions.Add(assetVersion); |
| | | |
| | | assetVersion.localValid = false; |
| | | } |
| | | else |
| | | { |
| | | assetVersion.localValid = true; |
| | | } |
| | | |
| | | count++; |
| | | if (count % 50 == 0) |
| | | await UniTask.Yield(); // 每50个让出一帧,避免主线程卡顿 |
| | | } |
| | | |
| | | m_PriorAssetDownLoadDone = priorDownLoadAssetVersions.Count <= 0; |
| | | m_UnPriorAssetDownLoadDone = unpriorDownLoadAssetVersions.Count <= 0; |
| | | checkAssetCompleted = true; |
| | | } |
| | | |
| | | public static void BeginDownLoadTask(bool _prior) |
| | |
| | | } |
| | | } |
| | | |
| | | public static Dictionary<string, AssetVersion> UpdateAssetVersions(string _assetVersionFile) |
| | | public async static UniTask<Dictionary<string, AssetVersion>> UpdateAssetVersions(string _assetVersionFile) |
| | | { |
| | | InitPackageVersionInfo(); |
| | | await InitPackageVersionInfo(); |
| | | var lines = _assetVersionFile.Split(new string[] { FileExtersion.lineSplit }, StringSplitOptions.RemoveEmptyEntries); |
| | | assetVersions.Clear(); |
| | | for (int i = 0; i < lines.Length; i++) |
| | |
| | | return assetVersions; |
| | | } |
| | | |
| | | static void InitPackageVersionInfo() |
| | | static async UniTask InitPackageVersionInfo() |
| | | { |
| | | var text = Resources.Load<TextAsset>("AssetsVersionCmp"); |
| | | var text = await Resources.LoadAsync<TextAsset>("AssetsVersionCmp") as TextAsset; |
| | | if (text != null) |
| | | { |
| | | var lines = text.text.Split(new string[] { FileExtersion.lineSplit }, StringSplitOptions.RemoveEmptyEntries); |
| | |
| | | |
| | | protected async UniTask Co_StartDownLoad() |
| | | { |
| | | var config = await VersionConfig.GetAsync(); |
| | | |
| | | while (tasks.Count > 0) |
| | | { |
| | | DownloadHotMgr.Instance.Prepare(); |
| | | |
| | | for (int i = 0; i < tasks.Count; i++) |
| | | { |
| | | var assetVersion = tasks[i]; |
| | | var remoteURL = StringUtility.Concat(VersionUtility.Instance.versionInfo.GetResourcesURL(VersionConfig.Get().branch), Language.fixPath, "/", assetVersion.relativePath); |
| | | var remoteURL = StringUtility.Concat(VersionUtility.Instance.versionInfo.GetResourcesURL(config.branch), Language.fixPath, "/", assetVersion.relativePath); |
| | | var localURL = StringUtility.Concat(ResourcesPath.Instance.ExternalStorePath, assetVersion.relativePath); |
| | | DownloadHotMgr.Instance.AddTask(new DownloadHotTask(remoteURL, localURL)); |
| | | } |
| | |
| | | using System; |
| | | using System.Text.RegularExpressions; |
| | | using LitJson; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | |
| | | public class InGameDownLoad : SingletonMonobehaviour<InGameDownLoad> |
| | |
| | | |
| | | DownloadHotMgr.Instance.Prepare(); |
| | | |
| | | var versionConfig = VersionConfig.config; |
| | | |
| | | if (null == versionConfig) |
| | | { |
| | | // 如果前面都没获取到那一定是哪里出问题了 从这里打断 |
| | | throw new Exception("VersionConfig is null when AssignTasks, game will pause here"); |
| | | } |
| | | |
| | | for (int i = 0; i < this.assets.Count; i++) |
| | | { |
| | | var assetVersion = this.assets[i]; |
| | | totalSize += assetVersion.size;//统计资源总大小 |
| | | |
| | | //添加下载任务 |
| | | var remoteURL = StringUtility.Concat(VersionUtility.Instance.versionInfo.GetResourcesURL(VersionConfig.Get().branch), Language.fixPath, "/", assetVersion.relativePath); |
| | | var remoteURL = StringUtility.Concat(VersionUtility.Instance.versionInfo.GetResourcesURL(versionConfig.branch), Language.fixPath, "/", assetVersion.relativePath); |
| | | var localURL = StringUtility.Concat(ResourcesPath.Instance.ExternalStorePath, assetVersion.relativePath); |
| | | DownloadHotMgr.Instance.AddTask(new DownloadHotTask(remoteURL, localURL, assetVersion)); |
| | | } |
| | |
| | | using UnityEngine;
|
| | | using System.Collections;
|
| | | using UnityEngine.UI;
|
| | | using Cysharp.Threading.Tasks; |
| | |
|
| | |
|
| | | public class InGameDownLoadProgress : MonoBehaviour
|
| | |
| | | using UnityEngine; |
| | | using System.IO; |
| | | using System; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | #if UNITY_EDITOR |
| | | using UnityEditor; |
| | | #endif |
| | |
| | | [RuntimeInitializeOnLoadMethod] |
| | | public static void Init() |
| | | { |
| | | if (InGameDownTestUtility.enable) |
| | | { |
| | | VersionConfig.Get().assetAccess = InstalledAsset.NullAsset; |
| | | } |
| | | else |
| | | { |
| | | VersionConfig.Get().assetAccess = InstalledAsset.IngoreDownLoad; |
| | | } |
| | | VersionConfig.GetAsync().ContinueWith(config => { |
| | | if (InGameDownTestUtility.enable) |
| | | { |
| | | config.assetAccess = InstalledAsset.NullAsset; |
| | | } |
| | | else |
| | | { |
| | | config.assetAccess = InstalledAsset.IngoreDownLoad; |
| | | } |
| | | |
| | | VersionConfig.Get().partAssetPackage = InGameDownTestUtility.isPartPackage; |
| | | config.partAssetPackage = InGameDownTestUtility.isPartPackage; |
| | | }).Forget(); |
| | | |
| | | } |
| | | #endif |
| | | |
| | | public static bool GetReadVerionEx() |
| | | { |
| | | #if UNITY_EDITOR |
| | | //生成VersionConfigEx.txt 提供给AOT启动时使用 |
| | | var json = JsonUtility.ToJson(VersionConfig.Get()); |
| | | string versionConfigExFile = Application.dataPath + "/Resources/VersionConfigEx.txt"; |
| | | if (File.Exists(versionConfigExFile)) |
| | | VersionConfig.GetAsync().ContinueWith(config => |
| | | { |
| | | File.Delete(versionConfigExFile); |
| | | } |
| | | File.WriteAllText(versionConfigExFile, json); |
| | | AssetDatabase.SaveAssets(); |
| | | AssetDatabase.Refresh(); |
| | | Debug.Log("同步VersionConfigEx.txt成功"); |
| | | //生成VersionConfigEx.txt 提供给AOT启动时使用 |
| | | var json = JsonUtility.ToJson(config); |
| | | string versionConfigExFile = Application.dataPath + "/Resources/VersionConfigEx.txt"; |
| | | if (File.Exists(versionConfigExFile)) |
| | | { |
| | | File.Delete(versionConfigExFile); |
| | | } |
| | | File.WriteAllText(versionConfigExFile, json); |
| | | AssetDatabase.SaveAssets(); |
| | | AssetDatabase.Refresh(); |
| | | Debug.Log("同步VersionConfigEx.txt成功"); |
| | | }).Forget(); |
| | | |
| | | #endif |
| | | return enable && isReadVesionEx; |
| | | } |
| | |
| | | using System.Collections.Generic; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | public class AttributeManager : GameSystemManager<AttributeManager> |
| | | { |
| | |
| | | using System.Collections.Generic; |
| | | using LitJson; |
| | | using UnityEngine; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | public class ArenaBattleWin : BaseBattleWin |
| | | { |
| | |
| | | /// <summary> |
| | | /// 设置战斗字段 |
| | | /// </summary> |
| | | public virtual void SetBattleField(BattleField _battleField) |
| | | public virtual async void SetBattleField(BattleField _battleField) |
| | | { |
| | | // 1. 清理旧的战场 |
| | | if (battleField != null) |
| | |
| | | BattleHUDWin ui = UIManager.Instance.GetUI<BattleHUDWin>(); |
| | | if (null == ui) |
| | | { |
| | | ui = UIManager.Instance.OpenWindowAsync<BattleHUDWin>().Forget(); |
| | | ui = await UIManager.Instance.OpenWindowAsync<BattleHUDWin>(); |
| | | } |
| | | ui.SetBattleField(battleField); |
| | | |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using Cysharp.Threading.Tasks; |
| | | using UnityEngine; |
| | | |
| | | public class BattleEffectMgr |
| | |
| | | } |
| | | effectPlayer.SetSpeedRatio(battleField.speedRatio); |
| | | |
| | | effectPlayer.Play(true); |
| | | effectPlayer.Play(true).Forget(); |
| | | |
| | | effectPlayer.SetScaleX(isRedCamp ? 1 : -1); |
| | | |
| | |
| | | |
| | | |
| | | |
| | | public override void ShowWindow(HB424_tagSCTurnFightInit vNetData) |
| | | public override async void ShowWindow(HB424_tagSCTurnFightInit vNetData) |
| | | { |
| | | ArenaBattleWin fsBattleWin = UIManager.Instance.GetUI<ArenaBattleWin>();// as FullScreenBattleWin; |
| | | if (null == fsBattleWin) |
| | | { |
| | | fsBattleWin = UIManager.Instance.OpenWindowAsync<ArenaBattleWin>().Forget(); |
| | | fsBattleWin = await UIManager.Instance.OpenWindowAsync<ArenaBattleWin>(); |
| | | } |
| | | fsBattleWin.SetBattleField(this); |
| | | if (UIManager.Instance.IsOpened<ArenaWin>()) |
| | |
| | | } |
| | | } |
| | | |
| | | public bool IsInit |
| | | { |
| | | get; |
| | | protected set; |
| | | } = false; |
| | | |
| | | protected bool isFocus = false; |
| | | |
| | | public BattleRootNode battleRootNode; |
| | |
| | | battleEffectMgr = new BattleEffectMgr(); |
| | | battleTweenMgr = new BattleTweenMgr(); |
| | | recordPlayer = new RecordPlayer(); |
| | | soundManager = new BattleSoundManager(this); |
| | | |
| | | processingDeathObjIds = new HashSet<uint>(); |
| | | } |
| | |
| | | GameObject battleRootNodeGO = GameObject.Instantiate(go); |
| | | battleRootNode = battleRootNodeGO.GetComponent<BattleRootNode>(); |
| | | battleRootNodeGO.name = GetType().Name; |
| | | |
| | | soundManager = new BattleSoundManager(this); |
| | | |
| | | } |
| | | public void AddCastingSkill(long objID, SkillBase skill) |
| | | { |
| | |
| | | public async virtual UniTask Init(int _MapID, int _FuncLineID, JsonData _extendData, |
| | | List<TeamBase> _redTeamList, List<TeamBase> _blueTeamList, byte _turnMax) |
| | | { |
| | | IsInit = false; |
| | | SetData(_MapID, _FuncLineID, _extendData, _redTeamList, _blueTeamList, _turnMax); |
| | | battleEffectMgr.Init(this); |
| | | battleTweenMgr.Init(this); |
| | |
| | | |
| | | PreloadResources(redTeamList, blueTeamList); |
| | | EventBroadcast.Instance.Broadcast<string>(EventName.BATTLE_START, guid); |
| | | |
| | | IsInit = true; |
| | | |
| | | #if UNITY_EDITOR |
| | | if (Launch.Instance.isOpenSkillLogFile) |
| | |
| | | public async virtual UniTask Reload(int _MapID, int _FuncLineID, JsonData _extendData, |
| | | List<TeamBase> _redTeamList, List<TeamBase> _blueTeamList, byte _turnMax) |
| | | { |
| | | IsInit = false; |
| | | SetData(_MapID, _FuncLineID, _extendData, _redTeamList, _blueTeamList, _turnMax); |
| | | battleEffectMgr.Reload(this); |
| | | battleTweenMgr.Reload(this); |
| | |
| | | |
| | | PreloadResources(redTeamList, blueTeamList); |
| | | |
| | | IsInit = true; |
| | | } |
| | | |
| | | public virtual void SetData(int _MapID, int _FuncLineID, JsonData _extendData, |
| | |
| | | BattleManager.Instance.DistributeNextReportPackage(guid); |
| | | } |
| | | |
| | | public override void ShowWindow(HB424_tagSCTurnFightInit vNetData) |
| | | public override async void ShowWindow(HB424_tagSCTurnFightInit vNetData) |
| | | { |
| | | BoneFieldBattleWin fsBattleWin = UIManager.Instance.GetUI<BoneFieldBattleWin>();// as FullScreenBattleWin; |
| | | if (null == fsBattleWin) |
| | | { |
| | | fsBattleWin = UIManager.Instance.OpenWindowAsync<BoneFieldBattleWin>().Forget(); |
| | | fsBattleWin = await UIManager.Instance.OpenWindowAsync<BoneFieldBattleWin>(); |
| | | } |
| | | fsBattleWin.SetBattleField(this); |
| | | |
| | |
| | | using UnityEngine; |
| | | using UnityEngine; |
| | | using System.Collections.Generic; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | public class BattleStartAction : RecordAction |
| | | { |
| | |
| | | using System; |
| | | using System; |
| | | using LitJson; |
| | | using UnityEngine; |
| | | using System.Collections.Generic; |
| | |
| | | return false; |
| | | } |
| | | |
| | | public override void ShowWindow(HB424_tagSCTurnFightInit vNetData) |
| | | public override async void ShowWindow(HB424_tagSCTurnFightInit vNetData) |
| | | { |
| | | BattleWin battleWin = UIManager.Instance.GetUI<BattleWin>(); |
| | | if (null != battleWin) |
| | |
| | | BattleManager.Instance.DistributeNextReportPackage(guid); |
| | | } |
| | | |
| | | public override void ShowWindow(HB424_tagSCTurnFightInit vNetData) |
| | | public override async void ShowWindow(HB424_tagSCTurnFightInit vNetData) |
| | | { |
| | | StoryBossBattleWin fsBattleWin = UIManager.Instance.GetUI<StoryBossBattleWin>();// as FullScreenBattleWin; |
| | | if (null == fsBattleWin) |
| | | { |
| | | fsBattleWin = UIManager.Instance.OpenWindowAsync<StoryBossBattleWin>().Forget(); |
| | | fsBattleWin = await UIManager.Instance.OpenWindowAsync<StoryBossBattleWin>(); |
| | | } |
| | | fsBattleWin.SetBattleField(this); |
| | | } |
| | |
| | | BattleManager.Instance.DistributeNextReportPackage(guid); |
| | | } |
| | | |
| | | public override void ShowWindow(HB424_tagSCTurnFightInit vNetData) |
| | | public override async void ShowWindow(HB424_tagSCTurnFightInit vNetData) |
| | | { |
| | | TianziBillboradBattleWin fsBattleWin = UIManager.Instance.GetUI<TianziBillboradBattleWin>();// as FullScreenBattleWin; |
| | | if (null == fsBattleWin) |
| | | { |
| | | fsBattleWin = UIManager.Instance.OpenWindowAsync<TianziBillboradBattleWin>().Forget(); |
| | | fsBattleWin = await UIManager.Instance.OpenWindowAsync<TianziBillboradBattleWin>(); |
| | | } |
| | | fsBattleWin.SetBattleField(this); |
| | | |
| | |
| | | BattleManager.Instance.DistributeNextReportPackage(guid); |
| | | } |
| | | |
| | | public override void ShowWindow(HB424_tagSCTurnFightInit vNetData) |
| | | public override async void ShowWindow(HB424_tagSCTurnFightInit vNetData) |
| | | { |
| | | WarlordPavilionBattleWin fsBattleWin = UIManager.Instance.GetUI<WarlordPavilionBattleWin>();// as FullScreenBattleWin; |
| | | if (null == fsBattleWin) |
| | | { |
| | | fsBattleWin = UIManager.Instance.OpenWindowAsync<WarlordPavilionBattleWin>().Forget(); |
| | | fsBattleWin = await UIManager.Instance.OpenWindowAsync<WarlordPavilionBattleWin>(); |
| | | } |
| | | fsBattleWin.SetBattleField(this); |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | public void SetBattleField(BattleField _battleField) |
| | | public async void SetBattleField(BattleField _battleField) |
| | | { |
| | | CleanupBattleField(); |
| | | ClearContent(string.Empty, true); |
| | |
| | | var res = globalSpineCache[key]; |
| | | if (res.CachedResource.Asset != null) |
| | | { |
| | | // spine AssetName 无扩展名,UnloadAsset 需与 LoadAssetAsync(needExt=true) 一致加 .asset |
| | | string spineAssetName = res.CachedResource.Identifier.AssetName; |
| | | if (!spineAssetName.EndsWith(".asset")) spineAssetName += ".asset"; |
| | | ResManager.Instance.UnloadAsset( |
| | | res.CachedResource.Identifier.Directory, |
| | | res.CachedResource.Identifier.AssetName |
| | | res.CachedResource.Identifier.Directory, |
| | | spineAssetName |
| | | ); |
| | | } |
| | | globalSpineCache.Remove(key); |
| | |
| | | var res = globalSpineCache[key]; |
| | | if (res.CachedResource.Asset != null) |
| | | { |
| | | string spineAssetName2 = res.CachedResource.Identifier.AssetName; |
| | | if (!spineAssetName2.EndsWith(".asset")) spineAssetName2 += ".asset"; |
| | | ResManager.Instance.UnloadAsset( |
| | | res.CachedResource.Identifier.Directory, |
| | | res.CachedResource.Identifier.AssetName |
| | | spineAssetName2 |
| | | ); |
| | | } |
| | | globalSpineCache.Remove(key); |
| | |
| | | |
| | | ResManager.Instance.LoadAssetAsync<AudioClip>( |
| | | identifier.Directory, |
| | | identifier.AssetName).ContinueWith( |
| | | identifier.AssetName, |
| | | false).ContinueWith( |
| | | (asset) => |
| | | { |
| | | if (asset != null) |
| | |
| | | { |
| | | var identifier = new BattleResCache.ResourceIdentifier |
| | | { |
| | | Directory = "UIEffect/" + effectConfig.packageName, |
| | | Directory = "UIEffect/" + effectConfig.packageName.Replace("\\", "/"), |
| | | AssetName = effectConfig.fxName, |
| | | Type = BattleResCache.ResourceType.Spine, |
| | | IsPersistent = isPersistent, |
| | |
| | | using System; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | public class BattleWin : UIBase |
| | | { |
| | |
| | | |
| | | |
| | | |
| | | public void SetBattleField(BattleField _battleField) |
| | | public async void SetBattleField(BattleField _battleField) |
| | | { |
| | | battleField = _battleField; |
| | | if (battleRootNode != null) |
| | |
| | | |
| | | if (null == ui) |
| | | { |
| | | UIManager.Instance.OpenWindowAsync<BattleHUDWin>().ContinueWith(w => |
| | | { |
| | | w.SetBattleField(battleField); |
| | | battleField.UpdateCanvas(canvas); |
| | | }).Forget(); |
| | | ui = await UIManager.Instance.OpenWindowAsync<BattleHUDWin>(); |
| | | ui.SetBattleField(battleField); |
| | | battleField.UpdateCanvas(canvas); |
| | | return; |
| | | } |
| | | |
| | |
| | | |
| | | public class RecordPlayer |
| | | { |
| | | |
| | | |
| | | // 初始化之前允许的record action类型 |
| | | private readonly static List<Type> allowedActionTypes = new List<Type>() |
| | | { |
| | | typeof(BattleStartAction), |
| | | typeof(PreloadResAction), |
| | | }; |
| | | |
| | | private List<RecordAction> tempPreinitRecordActionList = new List<RecordAction>(); |
| | | |
| | | protected BattleField battleField; |
| | | |
| | | private Queue<RecordAction> recordActionQueue = new Queue<RecordAction>(); |
| | |
| | | public void PlayRecord(RecordAction recordAction) |
| | | { |
| | | if (recordAction == null) return; |
| | | if (!CheckRecordType(recordAction)) return; |
| | | recordAction.actionOwner = this; |
| | | // Debug.LogError("Enqueue record action " + recordAction.GetType() + " to queue"); |
| | | if (isForceFinish || stepForcefinish) |
| | |
| | | public void PlayRecord(RecordAction recordAction, RecordAction waitingAnimeAction) |
| | | { |
| | | if (recordAction == null) return; |
| | | if (!CheckRecordType(recordAction)) return; |
| | | recordAction.actionOwner = this; |
| | | // Debug.LogError("Enqueue record action " + recordAction.GetType() + " to queue"); |
| | | if (isForceFinish || stepForcefinish) |
| | |
| | | public void InsertRecord(RecordAction recordAction, int position = 0) |
| | | { |
| | | if (recordAction == null) return; |
| | | if (!CheckRecordType(recordAction)) return; |
| | | recordAction.actionOwner = this; |
| | | if (isForceFinish || stepForcefinish) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | private bool CheckRecordType(RecordAction recordAction) |
| | | { |
| | | if (battleField.IsInit) |
| | | { |
| | | return true; |
| | | } |
| | | else |
| | | { |
| | | if (!allowedActionTypes.Contains(recordAction.GetType())) |
| | | { |
| | | tempPreinitRecordActionList.Add(recordAction); |
| | | return false; |
| | | } |
| | | else |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | } |
| | | |
| | | public virtual void Run() |
| | | { |
| | | |
| | | if (battleField != null) |
| | | { |
| | | if (!battleField.IsInit) |
| | | { |
| | | return; |
| | | } |
| | | if (tempPreinitRecordActionList.Count > 0) |
| | | { |
| | | foreach (var action in tempPreinitRecordActionList) |
| | | { |
| | | PlayRecord(action); |
| | | } |
| | | tempPreinitRecordActionList.Clear(); |
| | | } |
| | | } |
| | | |
| | | ImmediatelyPlayRun(); |
| | | |
| | | // 等待下一个action |
| | |
| | | |
| | | // 设置音量(使用音效音量设置) |
| | | source.volume = SystemSetting.Instance.GetSoundEffect(); |
| | | |
| | | source.mute = SystemSetting.Instance.GetMuteSoundEffect(); |
| | | // 设置播放速度,使用pitch来控制 |
| | | // pitch范围建议在0.5-2.0之间以避免失真 |
| | | if (pitchControl) |
| | |
| | | |
| | | if (cellContainer == null) |
| | | { |
| | | cellContainer = await UIUtility.CreateWidget("BattleBuffCell", "Container_BuffCell"); |
| | | var inst = await UIUtility.CreateWidget("BattleBuffCell", "Container_BuffCell"); |
| | | if (this == null) |
| | | { |
| | | if (null != cellContainer) |
| | | { |
| | | DestroyImmediate(cellContainer); |
| | | } |
| | | if (null != inst) DestroyImmediate(inst); |
| | | return; |
| | | } |
| | | |
| | | if (cellContainer != null) |
| | | { |
| | | DestroyImmediate(inst); |
| | | return; |
| | | } |
| | | cellContainer = inst; |
| | | |
| | | if (cellContainer != null) |
| | | { |
| | |
| | | return; |
| | | } |
| | | await LoadPrefab(); //存在被卸载的可能,重新加载 |
| | | if (this == null) return; |
| | | var config = SkillConfig.Get((int)buffData.SkillID); |
| | | if (config == null) |
| | | { |
| | |
| | | |
| | | void Awake() |
| | | { |
| | | LoadPrefab(); |
| | | LoadPrefab().Forget(); |
| | | } |
| | | |
| | | GameObject cellContainer; |
| | |
| | | |
| | | if (cellContainer == null) |
| | | { |
| | | cellContainer = await UIUtility.CreateWidget("MinggeBuffCell", "Container_BuffCell"); |
| | | var inst = await UIUtility.CreateWidget("MinggeBuffCell", "Container_BuffCell"); |
| | | if (this == null) |
| | | { |
| | | if (null != cellContainer) |
| | | { |
| | | DestroyImmediate(cellContainer); |
| | | } |
| | | if (null != inst) DestroyImmediate(inst); |
| | | return; |
| | | } |
| | | |
| | | if (cellContainer != null) |
| | | { |
| | | DestroyImmediate(inst); |
| | | return; |
| | | } |
| | | cellContainer = inst; |
| | | |
| | | if (cellContainer != null) |
| | | { |
| | | cellContainer.transform.SetParentEx(this.transform, Vector3.zero, Quaternion.identity, Vector3.one); |
| | |
| | | using System.Linq; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | |
| | | public class BattlePassBaseCell : CellView |
| | |
| | | using System.Linq; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | public class BeautyMMActiveWin : UIBase |
| | | { |
| | |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | public class BeautyMMBaseWin : OneLevelWin |
| | | { |
| | | [SerializeField] Image ylBG; |
| | | |
| | | protected override void OpenSubUIByTabIndex() |
| | | protected override async void OpenSubUIByTabIndex() |
| | | { |
| | | switch (functionOrder) |
| | | { |
| | | case 0: |
| | | currentSubUI = UIManager.Instance.OpenWindowAsync<BeautyMMListWin>().Forget(); |
| | | currentSubUI = await UIManager.Instance.OpenWindowAsync<BeautyMMListWin>(); |
| | | ylBG.SetActive(false); |
| | | break; |
| | | case 1: |
| | | // 充值界面 |
| | | currentSubUI = UIManager.Instance.OpenWindowAsync<BeautyMMTravelWin>().Forget(); |
| | | currentSubUI = await UIManager.Instance.OpenWindowAsync<BeautyMMTravelWin>(); |
| | | ylBG.SetActive(true); |
| | | break; |
| | | default: |
| | |
| | | using System.Linq; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | |
| | | public class BeautyMMCell : MonoBehaviour |
| | |
| | | using System; |
| | | using System.Linq; |
| | | using LitJson; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | |
| | | public partial class BeautyMMManager : GameSystemManager<BeautyMMManager> |
| | |
| | | using System.Linq; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | public class BeautyMMShowWin : UIBase |
| | | { |
| | |
| | | //-------------------------------------------------------- |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | //玩家通用排名 |
| | | public class GuildRankCell : MonoBehaviour |
| | |
| | | //-------------------------------------------------------- |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | //玩家通用的前3排名 |
| | | public class GuildTop3Cell : MonoBehaviour |
| | |
| | | txtBossName.text = nPCConfig.NPCName; |
| | | txtDifficulty.text = nowPassLineID.ToString(); |
| | | txtFightPower.text = UIHelper.ReplaceLargeArtNum(dungeonConfig.FightPower); |
| | | bossModel.Create(nPCConfig.SkinID, modelSize); |
| | | bossModel.Create(nPCConfig.SkinID, modelSize).Forget(); |
| | | } |
| | | |
| | | public void DisplayChallengeButton(DungeonConfig dungeonConfig, FBInfo fBInfo) |
| | |
| | | using System; |
| | | using UnityEngine; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | public class ArenaTabHandler : BaseChallengeTabHandler |
| | | { |
| | |
| | | return HandleArenaNavigation; |
| | | } |
| | | |
| | | private void HandleArenaNavigation() |
| | | private async void HandleArenaNavigation() |
| | | { |
| | | if (!FuncOpen.Instance.IsFuncOpen(GetFuncId(), true)) |
| | | return; |
| | |
| | | ArenaBattleWin battleWin; |
| | | if (!UIManager.Instance.IsOpened<ArenaBattleWin>()) |
| | | { |
| | | battleWin = UIManager.Instance.OpenWindowAsync<ArenaBattleWin>().Forget(); |
| | | battleWin = await UIManager.Instance.OpenWindowAsync<ArenaBattleWin>(); |
| | | } |
| | | else |
| | | { |
| | |
| | | using System; |
| | | using UnityEngine; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | public class BoneFieldTabHandler : BaseChallengeTabHandler |
| | | { |
| | |
| | | return HandleBoneFieldNavigation; |
| | | } |
| | | |
| | | private void HandleBoneFieldNavigation() |
| | | private async void HandleBoneFieldNavigation() |
| | | { |
| | | if (!FuncOpen.Instance.IsFuncOpen(GetFuncId(), true)) |
| | | return; |
| | |
| | | BoneFieldBattleWin battleWin; |
| | | if (!UIManager.Instance.IsOpened<BoneFieldBattleWin>()) |
| | | { |
| | | battleWin = UIManager.Instance.OpenWindowAsync<BoneFieldBattleWin>().Forget(); |
| | | battleWin = await UIManager.Instance.OpenWindowAsync<BoneFieldBattleWin>(); |
| | | } |
| | | else |
| | | { |
| | |
| | | using System; |
| | | using UnityEngine; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | public class TianziBillboradTabHandler : BaseChallengeTabHandler |
| | | { |
| | |
| | | return HandleBoneFieldNavigation; |
| | | } |
| | | |
| | | private void HandleBoneFieldNavigation() |
| | | private async void HandleBoneFieldNavigation() |
| | | { |
| | | if (!FuncOpen.Instance.IsFuncOpen(GetFuncId(), true)) |
| | | return; |
| | |
| | | TianziBillboradBattleWin battleWin; |
| | | if (!UIManager.Instance.IsOpened<TianziBillboradBattleWin>()) |
| | | { |
| | | battleWin = UIManager.Instance.OpenWindowAsync<TianziBillboradBattleWin>().Forget(); |
| | | battleWin = await UIManager.Instance.OpenWindowAsync<TianziBillboradBattleWin>(); |
| | | } |
| | | else |
| | | { |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | public class WarlordPavilionTabHandler : BaseChallengeTabHandler |
| | | { |
| | |
| | | return HandleBoneFieldNavigation; |
| | | } |
| | | |
| | | private void HandleBoneFieldNavigation() |
| | | private async void HandleBoneFieldNavigation() |
| | | { |
| | | if (!FuncOpen.Instance.IsFuncOpen(GetFuncId(), true)) |
| | | return; |
| | |
| | | WarlordPavilionBattleWin battleWin; |
| | | if (!UIManager.Instance.IsOpened<WarlordPavilionBattleWin>()) |
| | | { |
| | | battleWin = UIManager.Instance.OpenWindowAsync<WarlordPavilionBattleWin>().Forget(); |
| | | battleWin = await UIManager.Instance.OpenWindowAsync<WarlordPavilionBattleWin>(); |
| | | } |
| | | else |
| | | { |
| | |
| | | using UnityEngine; |
| | | using System.IO; |
| | | using LitJson; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | |
| | | #if UNITY_EDITOR |
| | | using UnityEditor; |
| | |
| | | |
| | | public class VersionConfig : ScriptableObject |
| | | { |
| | | |
| | | public const string VERSION_ALTERNATIVE = "1.0.0"; |
| | | |
| | | [SerializeField] public string m_AppId = string.Empty; |
| | |
| | | { |
| | | if (string.IsNullOrEmpty(m_GameId)) |
| | | { |
| | | var gameText = Resources.Load<TextAsset>("Game"); |
| | | if (gameText != null) |
| | | { |
| | | m_GameId = gameText.text; |
| | | } |
| | | else |
| | | { |
| | | m_GameId = "xssg"; |
| | | } |
| | | Debug.LogError("VersionConfig gameId is empty, do getasync first"); |
| | | } |
| | | |
| | | return m_GameId; |
| | |
| | | } |
| | | } |
| | | |
| | | static VersionConfig config = null; |
| | | public static VersionConfig Get() |
| | | public static async UniTask<VersionConfig> GetAsync() |
| | | { |
| | | if (config == null) |
| | | { |
| | | if (Application.isEditor) |
| | | { |
| | | config = Resources.Load<VersionConfig>("VersionConfig"); |
| | | config = await Resources.LoadAsync<VersionConfig>("VersionConfig") as VersionConfig; |
| | | //debug登录后第二次启动默认恢复test |
| | | if (LocalSave.GetBool("RestoreTest")) |
| | | { |
| | |
| | | LocalSave.SetBool("RestoreTest", false); |
| | | Debug.Log("appid 恢复test"); |
| | | } |
| | | |
| | | } |
| | | else |
| | | { |
| | | var text = Resources.Load<TextAsset>("VersionConfigEx"); |
| | | if (text != null) |
| | | var textAsset = await Resources.LoadAsync<TextAsset>("VersionConfigEx") as TextAsset; |
| | | if (textAsset != null) |
| | | { |
| | | config = ScriptableObject.CreateInstance<VersionConfig>(); |
| | | var json = JsonMapper.ToObject(text.text); |
| | | var json = JsonMapper.ToObject(textAsset.text); |
| | | ReadJson(json); //逐一解析,不用VersionConfig类结构读取,因为变量定义是按asset的结构定义的 |
| | | } |
| | | else |
| | | { |
| | | Debug.LogError("[VersionConfig] VersionConfigEx not found, falling back to VersionConfig asset"); |
| | | config = await Resources.LoadAsync<VersionConfig>("VersionConfig") as VersionConfig; |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (string.IsNullOrEmpty(config.m_GameId)) |
| | | { |
| | | var gameText = await Resources.LoadAsync<TextAsset>("Game") as TextAsset; |
| | | if (gameText != null) |
| | | { |
| | | config.m_GameId = gameText.text; |
| | | } |
| | | else |
| | | { |
| | | config.m_GameId = "xssg"; |
| | | } |
| | | } |
| | | |
| | | return config; |
| | | } |
| | | |
| | | public static VersionConfig config = null; |
| | | // public static VersionConfig Get() |
| | | // { |
| | | // if (config == null) |
| | | // { |
| | | // if (Application.isEditor) |
| | | // { |
| | | // config = Resources.Load<VersionConfig>("VersionConfig"); |
| | | // //debug登录后第二次启动默认恢复test |
| | | // if (LocalSave.GetBool("RestoreTest")) |
| | | // { |
| | | // config.m_AppId = "test"; |
| | | // LocalSave.SetBool("RestoreTest", false); |
| | | // Debug.Log("appid 恢复test"); |
| | | // } |
| | | |
| | | // } |
| | | // else |
| | | // { |
| | | // var text = Resources.Load<TextAsset>("VersionConfigEx"); |
| | | // if (text != null) |
| | | // { |
| | | // config = ScriptableObject.CreateInstance<VersionConfig>(); |
| | | // var json = JsonMapper.ToObject(text.text); |
| | | // ReadJson(json); //逐一解析,不用VersionConfig类结构读取,因为变量定义是按asset的结构定义的 |
| | | // } |
| | | // } |
| | | // } |
| | | |
| | | // return config; |
| | | // } |
| | | |
| | | public static void ReadJson(JsonData _data) |
| | | { |
| | | try |
| | |
| | | using LitJson; |
| | | using System.IO; |
| | | using System.Text; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | |
| | | |
| | | public class VersionUtility : Singleton<VersionUtility> |
| | | { |
| | | // public static readonly string[] VERSION_URL = new string[] { |
| | | // "http://xssgcenter.secondworld.net.cn:11000/center/appversion_new.php/?"}; |
| | | // "http://gamecenter.secondworld.net.cn:11000/center/appversion_new.php/?"}; |
| | | |
| | | public string androidRoot { get { return string.Empty;/*StringUtility.Concat(SDKUtils.Instance.DeviceRootPath, "/", VersionConfig.Get().bundleIdentifier);*/ } } |
| | | |
| | |
| | | /// 是否为ios审核时间内 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public bool InIosAuditTime() |
| | | public async UniTask<bool> InIosAuditTime() |
| | | { |
| | | DateTime dateTime; |
| | | |
| | | try |
| | | { |
| | | var textAsset = Resources.Load<UnityEngine.TextAsset>("Config/AuditTime"); |
| | | var textAsset = await Resources.LoadAsync<UnityEngine.TextAsset>("Config/AuditTime") as UnityEngine.TextAsset; |
| | | var content = string.Empty; |
| | | if (textAsset != null) |
| | | { |
| | |
| | | |
| | | public bool NeedDownAsset() |
| | | { |
| | | if (versionInfo != null && versionInfo.downAsset == 1 && VersionConfig.Get().assetAccess != InstalledAsset.IngoreDownLoad) |
| | | if (VersionConfig.config == null) |
| | | { |
| | | VersionConfig.GetAsync().Forget(); |
| | | Debug.LogError("VersionConfig is null when check NeedDownAsset, check VersionConfig.GetAsync for more details"); |
| | | return false; |
| | | } |
| | | |
| | | if (versionInfo != null && versionInfo.downAsset == 1 && VersionConfig.config.assetAccess != InstalledAsset.IngoreDownLoad) |
| | | { |
| | | return true; |
| | | } |
| | |
| | | using System;
|
| | | using System.Collections.Generic;
|
| | | using Cysharp.Threading.Tasks; |
| | |
|
| | |
|
| | | //充值自选功能
|
| | |
| | | using System; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | public class DailySpecialsBaseWin : FunctionsBaseWin |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | protected override void OpenSubUIByTabIndex() |
| | | protected override async void OpenSubUIByTabIndex() |
| | | { |
| | | DisplayBG(functionOrder); |
| | | DisplayFan(functionOrder); |
| | |
| | | { |
| | | case 0: |
| | | // 每日特惠 |
| | | currentSubUI = UIManager.Instance.OpenWindowAsync<DailySpecialsWin>().Forget(); |
| | | currentSubUI = await UIManager.Instance.OpenWindowAsync<DailySpecialsWin>(); |
| | | break; |
| | | case 1: |
| | | // 特惠商城 |
| | | StoreModel.Instance.selectStoreFuncType = StoreFunc.SpecialStore; |
| | | currentSubUI = UIManager.Instance.OpenWindowAsync<DailySpecialsShopWin>().Forget(); |
| | | currentSubUI = await UIManager.Instance.OpenWindowAsync<DailySpecialsShopWin>(); |
| | | break; |
| | | case 2: |
| | | // 每日礼包 |
| | | currentSubUI = UIManager.Instance.OpenWindowAsync<DailySpecialsDayGiftWin>().Forget(); |
| | | currentSubUI = await UIManager.Instance.OpenWindowAsync<DailySpecialsDayGiftWin>(); |
| | | break; |
| | | case 3: |
| | | // 每周礼包 |
| | | currentSubUI = UIManager.Instance.OpenWindowAsync<DailySpecialsWeekGiftWin>().Forget(); |
| | | currentSubUI = await UIManager.Instance.OpenWindowAsync<DailySpecialsWeekGiftWin>(); |
| | | break; |
| | | default: |
| | | Debug.LogWarning("未知的标签索引: " + functionOrder); |
| | |
| | | [SerializeField] Text titleText;
|
| | |
|
| | |
|
| | | protected override void OpenSubUIByTabIndex()
|
| | | protected override async void OpenSubUIByTabIndex()
|
| | | {
|
| | | switch (functionOrder)
|
| | | {
|
| | | case 0:
|
| | | //日常任务
|
| | | UIManager.Instance.OpenWindowAsync<DayMissionWin>().ContinueWith(w => currentSubUI = w).Forget();
|
| | | currentSubUI = await UIManager.Instance.OpenWindowAsync<DayMissionWin>();
|
| | | titleText.text = Language.Get("DayMission2");
|
| | | break;
|
| | | case 1:
|
| | | //周奖励
|
| | | UIManager.Instance.OpenWindowAsync<WeekBattlePassWin>().ContinueWith(w => currentSubUI = w).Forget();
|
| | | currentSubUI = await UIManager.Instance.OpenWindowAsync<WeekBattlePassWin>();
|
| | | titleText.text = Language.Get("DayMission3");
|
| | | break;
|
| | | case 2:
|
| | | //主线任务(英雄之路)
|
| | | UIManager.Instance.OpenWindowAsync<MissionHeroRoadWin>().ContinueWith(w => currentSubUI = w).Forget();
|
| | | currentSubUI = await UIManager.Instance.OpenWindowAsync<MissionHeroRoadWin>();
|
| | | titleText.text = Language.Get("DayMission4");
|
| | | break;
|
| | | default:
|
| | |
| | | using UnityEngine; |
| | | using System.Collections; |
| | | using UnityEngine.UI; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | |
| | | public class DebugController : MonoBehaviour |
| | |
| | | m_Version.text = string.Empty; |
| | | #else |
| | | m_Version.text = string.Format("{0}_{1} 分支: {2}", |
| | | VersionConfig.Get().version, VersionConfig.Get().buildIndex, VersionConfig.Get().branch); |
| | | VersionConfig.config.version, VersionConfig.config.buildIndex, VersionConfig.config.branch); |
| | | #endif |
| | | } |
| | | |
| | |
| | | |
| | | public void Login() |
| | | { |
| | | if (null == VersionConfig.config) |
| | | { |
| | | throw new System.Exception("VersionConfig is null when Login, game will pause here"); |
| | | } |
| | | |
| | | appidRecorder = appid.text; |
| | | serverIdRecorder = serverId.text; |
| | | accountRecorder = account.text; |
| | |
| | | |
| | | if (!string.IsNullOrEmpty(appid.text)) |
| | | { |
| | | bool needRestore = VersionConfig.Get().m_AppId != appid.text; |
| | | VersionConfig.Get().m_AppId = appid.text; |
| | | bool needRestore = VersionConfig.config.m_AppId != appid.text; |
| | | VersionConfig.config.m_AppId = appid.text; |
| | | #if UNITY_EDITOR |
| | | //debug登录后第二次启动默认恢复test |
| | | if (needRestore) |
| | |
| | | public void Init() |
| | | { |
| | | isWhiteListAccount = false; |
| | | if (VersionConfig.Get().debugVersion) |
| | | VersionConfig.GetAsync().ContinueWith(config => |
| | | { |
| | | debugAccount = true; |
| | | } |
| | | else |
| | | { |
| | | var parentDirectory = Directory.GetParent(Application.persistentDataPath); |
| | | debugAccount = File.Exists(parentDirectory + "/Debug"); |
| | | } |
| | | |
| | | if (LocalSave.GetString("#@#BrancH") != string.Empty) |
| | | { |
| | | var branch = LocalSave.GetString("#@#BrancH"); |
| | | int tmpbranch; |
| | | int.TryParse(LocalSave.GetString("#@#BrancH").Substring(1), out tmpbranch); |
| | | if (branch.StartsWith("d") && tmpbranch != 0) |
| | | if (config != null && config.debugVersion) |
| | | { |
| | | debugBranch = tmpbranch; |
| | | debugAccount = true; |
| | | } |
| | | else if (branch.StartsWith("r") && tmpbranch != 0) |
| | | { |
| | | debugBranch = tmpbranch; |
| | | debugAccount = false; |
| | | } |
| | | } |
| | | |
| | | if (debugAccount) |
| | | { |
| | | if (Application.isMobilePlatform) |
| | | else |
| | | { |
| | | var parentDirectory = Directory.GetParent(Application.persistentDataPath); |
| | | if (File.Exists(parentDirectory + "/Debug")) |
| | | debugAccount = File.Exists(parentDirectory + "/Debug"); |
| | | } |
| | | |
| | | if (LocalSave.GetString("#@#BrancH") != string.Empty) |
| | | { |
| | | var branch = LocalSave.GetString("#@#BrancH"); |
| | | int tmpbranch; |
| | | int.TryParse(LocalSave.GetString("#@#BrancH").Substring(1), out tmpbranch); |
| | | if (branch.StartsWith("d") && tmpbranch != 0) |
| | | { |
| | | var content = File.ReadAllText(parentDirectory + "/Debug"); |
| | | if (!string.IsNullOrEmpty(content)) |
| | | debugBranch = tmpbranch; |
| | | debugAccount = true; |
| | | } |
| | | else if (branch.StartsWith("r") && tmpbranch != 0) |
| | | { |
| | | debugBranch = tmpbranch; |
| | | debugAccount = false; |
| | | } |
| | | } |
| | | |
| | | if (debugAccount) |
| | | { |
| | | if (Application.isMobilePlatform) |
| | | { |
| | | var parentDirectory = Directory.GetParent(Application.persistentDataPath); |
| | | if (File.Exists(parentDirectory + "/Debug")) |
| | | { |
| | | var json = JsonMapper.ToObject<DebugBranch>(File.ReadAllText(parentDirectory + "/Debug")); |
| | | debugBranch = json.branch; |
| | | var content = File.ReadAllText(parentDirectory + "/Debug"); |
| | | if (!string.IsNullOrEmpty(content)) |
| | | { |
| | | var json = JsonMapper.ToObject<DebugBranch>(File.ReadAllText(parentDirectory + "/Debug")); |
| | | debugBranch = json.branch; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }).Forget(); |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | |
| | | using System; |
| | | |
| | | using Cysharp.Threading.Tasks; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | |
| | |
| | | if (isNewEquip) |
| | | { |
| | | //找对比装备 |
| | | oldEquip = PackManager.Instance.GetItemByIndex(PackType.Equip, EquipModel.Instance.selectFloorEquip.config.EquipPlace - 1); |
| | | if (EquipModel.Instance.selectFloorEquip != null && EquipModel.Instance.selectFloorEquip.config != null) |
| | | oldEquip = PackManager.Instance.GetItemByIndex(PackType.Equip, EquipModel.Instance.selectFloorEquip.config.EquipPlace - 1); |
| | | } |
| | | |
| | | if (oldEquip == null) |
| | |
| | |
|
| | | void Display()
|
| | | {
|
| | | if (EquipModel.Instance.selectFloorEquip == null || EquipModel.Instance.selectFloorEquip.config == null)
|
| | | {
|
| | | CloseWindow();
|
| | | return;
|
| | | }
|
| | | EquipModel.Instance.lastShowEquipIndex = EquipModel.Instance.selectFloorEquip.config.EquipPlace - 1;
|
| | | var oldEquip = PackManager.Instance.GetItemByIndex(PackType.Equip, EquipModel.Instance.lastShowEquipIndex);
|
| | | if (oldEquip == null)
|
| | |
| | | using System; |
| | | using LitJson; |
| | | using UnityEngine.UI; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | |
| | | public class EquipModel : GameSystemManager<EquipModel> |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | public class FirstChargeManager : GameSystemManager<FirstChargeManager> |
| | | { |
| | |
| | | using System.Collections.Generic; |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | |
| | | DisplayButton(firstId); |
| | | } |
| | | |
| | | protected override void OpenSubUIByTabIndex() |
| | | protected override async void OpenSubUIByTabIndex() |
| | | { |
| | | int firstId = model.GetFirstIDByTabIndex(functionOrder); |
| | | model.SetClickTabState(firstId); |
| | |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | //方案预设 方案选择组件 |
| | | public class FuncPresetChooseCell : MonoBehaviour |
| | |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | //方案预设 方案选择组件, 隐藏的方案 |
| | | public class FuncPresetChooseMoreCell : MonoBehaviour |
| | |
| | | using UnityEngine; |
| | | using LitJson; |
| | | using System; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | //方案预设:流派设定 |
| | | // 这里存储的是流派id设定; 功能预设在各个功能里如命格的是存在命格背包对应,武将是另外通知使用的格子索引 |
| | |
| | | using UnityEngine; |
| | | using UnityEngine; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | /// <summary> |
| | | /// 古宝基础界面 |
| | |
| | | { |
| | | [SerializeField] Transform bg; |
| | | [SerializeField] Transform jbbg; |
| | | protected override void OpenSubUIByTabIndex() |
| | | protected override async void OpenSubUIByTabIndex() |
| | | { |
| | | switch (functionOrder) |
| | | { |
| | | case 0: |
| | | UIManager.Instance.OpenWindowAsync<GubaoListWin>().ContinueWith(w => currentSubUI = w).Forget(); |
| | | currentSubUI = await UIManager.Instance.OpenWindowAsync<GubaoListWin>(); |
| | | jbbg.SetActive(false); |
| | | bg.SetActive(true); |
| | | break; |
| | | case 1: |
| | | UIManager.Instance.OpenWindowAsync<GubaoCallWin>().ContinueWith(w => currentSubUI = w).Forget(); |
| | | currentSubUI = await UIManager.Instance.OpenWindowAsync<GubaoCallWin>(); |
| | | jbbg.SetActive(true); |
| | | bg.SetActive(false); |
| | | break; |
| | | case 2: |
| | | UIManager.Instance.OpenWindowAsync<GubaoSuiteListWin>().ContinueWith(w => currentSubUI = w).Forget(); |
| | | currentSubUI = await UIManager.Instance.OpenWindowAsync<GubaoSuiteListWin>(); |
| | | jbbg.SetActive(false); |
| | | bg.SetActive(true); |
| | | break; |
| | |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | public class GubaoCell : MonoBehaviour |
| | | { |
| | |
| | | using System; |
| | | using System.Linq; |
| | | using LitJson; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | |
| | | public partial class GubaoManager : GameSystemManager<GubaoManager> |
| | |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | /// <summary> |
| | | /// 创建公会界面 |
| | |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | /// <summary> |
| | | /// 公会捐赠界面 |
| | |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | public class GuildFuncCell : MonoBehaviour |
| | | { |
| | |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | /// <summary> |
| | | /// 公会大厅 |
| | |
| | | using System.Linq; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | public class GuildHawkerWin : UIBase |
| | | { |
| | |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | /// <summary> |
| | | /// 加入公会界面 :公会查找列表,也是排行榜 |
| | |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | /// <summary> |
| | | /// 公会管理界面 |
| | |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | |
| | | //公会查找列表,也是排行榜 |
| | |
| | | using System.Collections.Generic;
|
| | | using System.Linq;
|
| | | using UnityEngine;
|
| | | using Cysharp.Threading.Tasks; |
| | |
|
| | |
|
| | | public partial class HappyXBModel : GameSystemManager<HappyXBModel>
|
| | |
| | | using UnityEngine; |
| | | using UnityEngine.Events; |
| | | using UnityEngine.UI; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | |
| | | public class HeroCallHopeAddCell : MonoBehaviour |
| | |
| | | { |
| | | head.SetActive(true); |
| | | addImg.SetActive(false); |
| | | head.Init(heroID, headGray, ()=> { heroAction.Invoke(quality); }); |
| | | head.Init(heroID, headGray, ()=> { heroAction.Invoke(quality); }).Forget(); |
| | | } |
| | | else |
| | | { |
| | |
| | | using System.Collections.Generic; |
| | | using Cysharp.Threading.Tasks; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | |
| | |
| | | public void Display(int heroID) |
| | | { |
| | | var hero = HeroConfig.Get(heroID); |
| | | heroHeadBaseCell.Init(hero.HeroID, hero.SkinIDList[0]); |
| | | heroHeadBaseCell.Init(hero.HeroID, hero.SkinIDList[0]).Forget(); |
| | | nameText.text = hero.Name; |
| | | jobImg.SetSprite(HeroUIManager.Instance.GetJobIconName(hero.Class)); |
| | | } |
| | | |
| | | public void Display(HeroInfo hero) |
| | | { |
| | | heroHeadBaseCell.Init(hero.heroId, hero.SkinID, hero.heroStar, hero.awakeLevel, hero.heroLevel); |
| | | heroHeadBaseCell.Init(hero.heroId, hero.SkinID, hero.heroStar, hero.awakeLevel, hero.heroLevel).Forget(); |
| | | nameText.text = hero.breakLevel == 0 ? hero.heroConfig.Name : Language.Get("herocardbreaklv", hero.heroConfig.Name, hero.breakLevel); |
| | | jobImg.SetSprite(HeroUIManager.Instance.GetJobIconName(hero.heroConfig.Class)); |
| | | } |
| | |
| | | PlayAnimation(motionName, true); |
| | | spineAnimationState.Complete -= OnAnimationComplete; |
| | | spineAnimationState.Complete += OnAnimationComplete; |
| | | |
| | | #if UNITY_EIDTOR |
| | | await UniTask.Delay(100); |
| | | if (skeletonGraphic != null && skeletonGraphic.material != null) |
| | | { |
| | | skeletonGraphic.material.shader = Shader.Find(skeletonGraphic.material.shader.name); |
| | | } |
| | | #endif |
| | | } |
| | | |
| | | |
| | |
| | | using Cysharp.Threading.Tasks; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | |
| | |
| | | public void Display(HeroInfo hero) |
| | | { |
| | | this.hero = hero; |
| | | heroHeadBaseCell.Init(hero.heroId, hero.SkinID, hero.heroStar, hero.awakeLevel, hero.heroLevel, OnClick); |
| | | heroHeadBaseCell.Init(hero.heroId, hero.SkinID, hero.heroStar, hero.awakeLevel, hero.heroLevel, OnClick).Forget(); |
| | | nameText.text = hero.breakLevel == 0 ? hero.heroConfig.Name : Language.Get("herocardbreaklv", hero.heroConfig.Name, hero.breakLevel); |
| | | jobImg.SetSprite(HeroUIManager.Instance.GetJobIconName(hero.heroConfig.Class)); |
| | | bool isChoose = manager.chooseCostHeroInfos.Contains(hero); |
| | |
| | | using Cysharp.Threading.Tasks; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | |
| | |
| | | |
| | | public void Display(HeroInfo hero) |
| | | { |
| | | heroHeadBaseCell.Init(hero.heroId, hero.SkinID, hero.heroStar, hero.awakeLevel, hero.heroLevel); |
| | | heroHeadBaseCell.Init(hero.heroId, hero.SkinID, hero.heroStar, hero.awakeLevel, hero.heroLevel).Forget(); |
| | | nameText.text = hero.breakLevel == 0 ? hero.heroConfig.Name : Language.Get("herocardbreaklv", hero.heroConfig.Name, hero.breakLevel); |
| | | jobImg.SetSprite(HeroUIManager.Instance.GetJobIconName(hero.heroConfig.Class)); |
| | | } |
| | |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | public class HeroFatesUpgradeWin : UIBase |
| | | { |
| | |
| | | |
| | | void Awake() |
| | | { |
| | | LoadPrefab(); |
| | | LoadPrefab().Forget(); |
| | | } |
| | | |
| | | //showState 0:不显示 1:新增 2:提升 |
| | | //giftID 0 :代表灰色需升星激活 -1:代表棕色需觉醒激活,其他根据配表,没有天赋的外层控制显隐 |
| | | public void Init(int giftID, int lv, int showState = 0, int heroID = 0, int index = 0, int awakeLevel = 0) |
| | | public async UniTask Init(int giftID, int lv, int showState = 0, int heroID = 0, int index = 0, int awakeLevel = 0) |
| | | { |
| | | LoadPrefab(); //存在被卸载的可能,重新加载 |
| | | await LoadPrefab(); //存在被卸载的可能,重新加载 |
| | | if (this == null) return; |
| | | if (HeroTalentConfig.HasKey(giftID)) |
| | | { |
| | | var config = HeroTalentConfig.Get(giftID); |
| | |
| | | } |
| | | if (cellContainer == null) |
| | | { |
| | | cellContainer = await UIUtility.CreateWidget("GiftBaseCell", "Container_GiftCell"); |
| | | var inst = await UIUtility.CreateWidget("GiftBaseCell", "Container_GiftCell"); |
| | | |
| | | if (this == null) |
| | | { |
| | | if (null != cellContainer) |
| | | { |
| | | GameObject.DestroyImmediate(cellContainer); |
| | | } |
| | | if (null != inst) GameObject.DestroyImmediate(inst); |
| | | return; |
| | | } |
| | | |
| | | if (cellContainer != null) |
| | | { |
| | | GameObject.DestroyImmediate(inst); |
| | | return; |
| | | } |
| | | cellContainer = inst; |
| | | |
| | | if (cellContainer != null) |
| | | { |
| | | cellContainer.transform.SetParentEx(this.transform, Vector3.zero, Quaternion.identity, Vector3.one); |
| | | cellContainer.transform.SetAsFirstSibling(); |
| | | } |
| | |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | |
| | | /// <summary> |
| | |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | /// <summary> |
| | | /// 武将基础界面 |
| | |
| | | |
| | | |
| | | |
| | | protected override void OpenSubUIByTabIndex() |
| | | protected override async void OpenSubUIByTabIndex() |
| | | { |
| | | Debug.Log("打开子界面 : " + functionOrder); |
| | | // 主城 内政 武将 挑战 公会 |
| | |
| | | switch (functionOrder) |
| | | { |
| | | case 0: |
| | | currentSubUI = UIManager.Instance.OpenWindowAsync<HeroListWin>().Forget(); |
| | | currentSubUI = await UIManager.Instance.OpenWindowAsync<HeroListWin>(); |
| | | break; |
| | | case 1: |
| | | currentSubUI = UIManager.Instance.OpenWindowAsync<HeroCollectionWin>().Forget(); |
| | | currentSubUI = await UIManager.Instance.OpenWindowAsync<HeroCollectionWin>(); |
| | | break; |
| | | case 2: |
| | | currentSubUI = UIManager.Instance.OpenWindowAsync<HeroFatesWin>().Forget(); |
| | | currentSubUI = await UIManager.Instance.OpenWindowAsync<HeroFatesWin>(); |
| | | break; |
| | | default: |
| | | Debug.LogWarning("未知的标签索引: " + functionOrder); |
| | |
| | | if (i < heroConfig.TalentList.Length) |
| | | { |
| | | giftBaseCells[i].SetActive(true); |
| | | giftBaseCells[i].Init(heroConfig.TalentList[i], HeroUIManager.Instance.maxGiftLevel); |
| | | giftBaseCells[i].Init(heroConfig.TalentList[i], HeroUIManager.Instance.maxGiftLevel).Forget(); |
| | | } |
| | | else |
| | | { |
| | |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | using System.Collections.Generic; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | public class HeroCardCell : MonoBehaviour |
| | | { |
| | |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | using System.Collections.Generic; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | public class HeroCollectionCardCell : MonoBehaviour |
| | | { |
| | |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using Cysharp.Threading.Tasks; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | |
| | |
| | | { |
| | | // fullPanel.SetActive(true); |
| | | lvupPanel.SetActive(state == 1); |
| | | fullHeadCell.Init(HeroUIManager.Instance.selectCollectHeroID, config.SkinIDList[0], colData.BookStarLV); |
| | | fullHeadCell.Init(HeroUIManager.Instance.selectCollectHeroID, config.SkinIDList[0], colData.BookStarLV).Forget(); |
| | | name3.text = colData.BookBreakLV == 0 ? config.Name : Language.Get("herocardbreaklv", config.Name, colData.BookBreakLV); |
| | | |
| | | |
| | |
| | | using System.Collections.Generic; |
| | | using Cysharp.Threading.Tasks; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | |
| | |
| | | heroHeadBaseCell.Init(hero.heroId, hero.SkinID, hero.heroStar, hero.awakeLevel, hero.heroLevel, () => |
| | | { |
| | | Click(hero, index); |
| | | }); |
| | | }).Forget(); |
| | | nameText.text = hero.breakLevel == 0 ? hero.heroConfig.Name : Language.Get("herocardbreaklv", hero.heroConfig.Name, hero.breakLevel); |
| | | |
| | | jobImg.SetSprite(HeroUIManager.Instance.GetJobIconName(hero.heroConfig.Class)); |
| | |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | |
| | | /// <summary> |
| | |
| | | using System.Collections.Generic; |
| | | using Cysharp.Threading.Tasks; |
| | | using UnityEngine; |
| | | |
| | | public class HeroGiftLineCell : CellView |
| | |
| | | var giftID = configList[index + i]; |
| | | var giftLV = HeroUIManager.Instance.maxGiftLevel; |
| | | cardList[i].SetActive(true); |
| | | cardList[i].Init(giftID, giftLV); |
| | | cardList[i].Init(giftID, giftLV).Forget(); |
| | | } |
| | | else |
| | | { |
| | |
| | | using System.Collections.Generic; |
| | | using Cysharp.Threading.Tasks; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | |
| | |
| | | int giftID = hero.talentIDList[index]; |
| | | int giftLV = hero.talentLvList[index]; |
| | | |
| | | giftCell.Init(giftID, giftLV, 0, hero.heroId, index, hero.awakeLevel); |
| | | giftCell.Init(giftID, giftLV, 0, hero.heroId, index, hero.awakeLevel).Forget(); |
| | | |
| | | if (hero.talentLockList.IndexOf(index) != -1) |
| | | { |
| | |
| | | public void Display() |
| | | { |
| | | heroShow.Init(hero.heroId, hero.SkinID, hero.breakLevel, hero.heroStar, hero.awakeLevel, hero.heroLevel); |
| | | |
| | | if (hero.talentRandomIDList.Count == 0) |
| | | { |
| | | currentGo.SetActive(true); |
| | |
| | | afterGiftCells[i].SetActive(true); |
| | | |
| | | |
| | | afterGiftCells[i].Init(hero.talentRandomIDList[i], hero.talentLvList[i], 0, hero.heroId, i, hero.awakeLevel); |
| | | afterGiftCells[i].Init(hero.talentRandomIDList[i], hero.talentLvList[i], 0, hero.heroId, i, hero.awakeLevel).Forget(); |
| | | |
| | | //对比变化的天赋显示特效 |
| | | if (hero.talentRandomIDList[i] != hero.talentIDList[i]) |
| | |
| | | |
| | | void Awake() |
| | | { |
| | | LoadPrefab(); |
| | | LoadPrefab().Forget(); |
| | | } |
| | | |
| | | // 武将小头像,(职业和名称不再此管理,各个界面排版不同) |
| | | public void Init(int heroID, int skinID, int star = 0, int awakelv = 0, int lv = 0, UnityAction onclick = null) |
| | | public async UniTask Init(int heroID, int skinID, int star = 0, int awakelv = 0, int lv = 0, UnityAction onclick = null) |
| | | { |
| | | LoadPrefab(); //存在被卸载的可能,重新加载 |
| | | await LoadPrefab(); //存在被卸载的可能,重新加载 |
| | | if (this == null) return; |
| | | if (onclick != null) |
| | | { |
| | | clickBtn.AddListener(onclick); |
| | |
| | | // 武将小头像 Async版本 |
| | | public async UniTask InitAsync(int heroID, int skinID, int star = 0, int awakelv = 0, int lv = 0, UnityAction onclick = null) |
| | | { |
| | | LoadPrefab(); //存在被卸载的可能,重新加载 |
| | | await LoadPrefab(); //存在被卸载的可能,重新加载 |
| | | if (this == null) return; |
| | | if (onclick != null) |
| | | { |
| | | clickBtn.AddListener(onclick); |
| | |
| | | } |
| | | if (cellContainer == null) |
| | | { |
| | | cellContainer = await UIUtility.CreateWidget("HeroHeadBaseCell", "Container_HeadCell"); |
| | | var inst = await UIUtility.CreateWidget("HeroHeadBaseCell", "Container_HeadCell"); |
| | | |
| | | if (this == null) |
| | | { |
| | | if (cellContainer != null) |
| | | { |
| | | DestroyImmediate(cellContainer); |
| | | return; |
| | | } |
| | | if (inst != null) DestroyImmediate(inst); |
| | | return; |
| | | } |
| | | |
| | | if (cellContainer != null) |
| | | { |
| | | DestroyImmediate(inst); |
| | | return; |
| | | } |
| | | cellContainer = inst; |
| | | |
| | | if (cellContainer != null) |
| | | { |
| | | cellContainer.transform.SetParentEx(this.transform, Vector3.zero, Quaternion.identity, Vector3.one); |
| | | cellContainer.transform.SetAsFirstSibling(); |
| | | } |
| | |
| | | public async UniTask Init(int heroID, bool _gray = false, UnityAction onclick = null) |
| | | { |
| | | await LoadPrefab(); |
| | | clickBtn.AddListener(onclick); |
| | | if (this == null) return; |
| | | if (onclick != null) |
| | | clickBtn.AddListener(onclick); |
| | | var heroConfig = HeroConfig.Get(heroID); |
| | | qualityBG.SetSprite("heroheadBG" + heroConfig.Quality); |
| | | |
| | |
| | | } |
| | | if (cellContainer == null) |
| | | { |
| | | cellContainer = await UIUtility.CreateWidget("HeroHeadBaseNoTrainCell", "Container_HeadCell"); |
| | | var inst = await UIUtility.CreateWidget("HeroHeadBaseNoTrainCell", "Container_HeadCell"); |
| | | |
| | | if (this == null) |
| | | { |
| | | if (cellContainer != null) |
| | | { |
| | | DestroyImmediate(cellContainer); |
| | | } |
| | | if (inst != null) DestroyImmediate(inst); |
| | | return; |
| | | } |
| | | |
| | | if (cellContainer != null) |
| | | { |
| | | DestroyImmediate(inst); |
| | | return; |
| | | } |
| | | cellContainer = inst; |
| | | |
| | | if (cellContainer != null) |
| | | { |
| | | cellContainer.transform.SetParentEx(this.transform, Vector3.zero, Quaternion.identity, Vector3.one); |
| | | cellContainer.transform.SetAsFirstSibling(); |
| | | } |
| | |
| | | using System.Collections.Generic; |
| | | using Cysharp.Threading.Tasks; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | |
| | |
| | | heroHeadBaseCell.Init(hero.heroId, hero.SkinID, hero.heroStar, hero.awakeLevel, hero.heroLevel, () => |
| | | { |
| | | Click(hero, index); |
| | | }); |
| | | }).Forget(); |
| | | nameText.text = hero.breakLevel == 0 ? hero.heroConfig.Name : Language.Get("herocardbreaklv", hero.heroConfig.Name, hero.breakLevel); |
| | | |
| | | jobImg.SetSprite(HeroUIManager.Instance.GetJobIconName(hero.heroConfig.Class)); |
| | |
| | | [SerializeField] Transform caseesObj; |
| | | FuncPresetChooseCells presetChooseCells; |
| | | |
| | | Action presetChooseCellssetOnLoaded; |
| | | |
| | | [SerializeField] Button funPresetBtn; |
| | | |
| | | |
| | |
| | | presetObj.transform.SetParentEx(caseesObj, Vector3.zero, Quaternion.identity, Vector3.one); |
| | | presetChooseCells = presetObj.GetComponent<FuncPresetChooseCells>(); |
| | | presetChooseCells.ChangeAlignment(TextAnchor.MiddleCenter); |
| | | presetChooseCellssetOnLoaded?.Invoke(); |
| | | presetChooseCellssetOnLoaded = null; |
| | | }).Forget(); |
| | | |
| | | |
| | |
| | | } |
| | | fightPowerText.text = UIHelper.ReplaceLargeArtNum(FightPowerManager.Instance.GetTeamFightPower(HeroUIManager.Instance.selectTeamType, true)); |
| | | |
| | | presetChooseCells.Display((int)BattlePreSetType.Story, (int)FuncPresetType.Team); |
| | | if (null == presetChooseCells) |
| | | { |
| | | presetChooseCellssetOnLoaded = () => |
| | | { |
| | | if (this == null) |
| | | return; |
| | | presetChooseCells.Display((int)BattlePreSetType.Story, (int)FuncPresetType.Team); |
| | | }; |
| | | } |
| | | else |
| | | { |
| | | presetChooseCells.Display((int)BattlePreSetType.Story, (int)FuncPresetType.Team); |
| | | } |
| | | |
| | | |
| | | funPresetBtn.SetActive(FuncPresetManager.Instance.IsPreShow()); |
| | | } |
| | |
| | | |
| | | |
| | | flyAlphaTween.alpha = 1; |
| | | flyHead.Init(flyHero.heroId, flyHero.SkinID); |
| | | flyHead.Init(flyHero.heroId, flyHero.SkinID).Forget(); |
| | | flyHead.transform.position = startPos; |
| | | var targetPos = scenePosImgs[posList[0]].transform.position; |
| | | flyHead.transform.localScale = Vector3.one; |
| | |
| | | public async void Init(int heroID, int skinID, int breakLevel = 0, int star = 0, int awakelv = 0, int lv = 0, bool isShowLock = false) |
| | | { |
| | | await LoadPrefab(); //存在被卸载的可能,重新加载 |
| | | if (this == null) return; |
| | | var heroConfig = HeroConfig.Get(heroID); |
| | | qualityBG.SetSprite("herodz" + heroConfig.Quality); |
| | | // int skinID = 0; |
| | |
| | | } |
| | | if (cellContainer == null) |
| | | { |
| | | cellContainer = await UIUtility.CreateWidget("HeroShowBaseCell", "Container_HeroShow"); |
| | | var inst = await UIUtility.CreateWidget("HeroShowBaseCell", "Container_HeroShow"); |
| | | |
| | | if (this == null) |
| | | { |
| | | if (cellContainer != null) |
| | | { |
| | | DestroyImmediate(cellContainer); |
| | | return; |
| | | } |
| | | if (inst != null) DestroyImmediate(inst); |
| | | return; |
| | | } |
| | | |
| | | if (cellContainer != null) |
| | | { |
| | | DestroyImmediate(inst); |
| | | return; |
| | | } |
| | | cellContainer = inst; |
| | | |
| | | if (cellContainer != null) |
| | | { |
| | | cellContainer.transform.SetParentEx(this.transform, Vector3.zero, Quaternion.identity, Vector3.one); |
| | | cellContainer.transform.SetAsFirstSibling(); |
| | | } |
| | |
| | | public bool enable = true; |
| | | |
| | | |
| | | public void Start() |
| | | public async void Start() |
| | | { |
| | | heroModel.Create(heroSkinID, scale); |
| | | await heroModel.Create(heroSkinID, scale); |
| | | heroModel.PlayAnimation(actionName, true); |
| | | heroModel.SetEnabled(enable); |
| | | } |
| | |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | using UnityEngine; |
| | | |
| | |
| | | using System; |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using Cysharp.Threading.Tasks; |
| | | using LitJson; |
| | | |
| | | using UnityEngine; |
| | |
| | | } |
| | | } |
| | | |
| | | giftBaseCells[i].Init(giftID, giftLV, state, hero.heroId, i, hero.awakeLevel); |
| | | giftBaseCells[i].Init(giftID, giftLV, state, hero.heroId, i, hero.awakeLevel).Forget(); |
| | | } |
| | | else |
| | | { |
| | |
| | | //非对比的显示 |
| | | if (i < normalGiftMaxCnt) |
| | | { |
| | | giftBaseCells[i].Init(0, 0); |
| | | giftBaseCells[i].Init(0, 0).Forget(); |
| | | } |
| | | else |
| | | { |
| | | giftBaseCells[i].Init(-1, 0, 0, hero.heroId, i); |
| | | giftBaseCells[i].Init(-1, 0, 0, hero.heroId, i).Forget(); |
| | | } |
| | | } |
| | | |
| | |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using LitJson; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | using UnityEngine; |
| | | |
| | |
| | | using System;
|
| | | using LitJson;
|
| | | using Cysharp.Threading.Tasks;
|
| | |
|
| | | using System.Collections.Generic;
|
| | | using System.Linq;
|
| | |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | public class AffairFuncCell : MonoBehaviour |
| | | { |
| | |
| | | using System.Linq; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | |
| | | /// <summary> |
| | |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using LitJson; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | public class ItemTipUtility |
| | | { |
| | |
| | | using System.Collections.Generic;
|
| | | using UnityEngine;
|
| | | using UnityEngine.UI;
|
| | | using Cysharp.Threading.Tasks; |
| | |
|
| | | public class ItemTipWayWin : UIBase
|
| | | {
|
| | |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | //拥有的货币:数量显示,点击按钮打开对应获取界面 |
| | | public class OwnMoneyCell : MonoBehaviour |
| | |
| | | using UnityEngine;
|
| | | using UnityEngine.UI;
|
| | | using Cysharp.Threading.Tasks; |
| | |
|
| | | /// <summary>
|
| | | /// 合成格子
|
| | |
| | | using System.Linq;
|
| | | using LitJson;
|
| | | using UnityEngine;
|
| | | using Cysharp.Threading.Tasks; |
| | |
|
| | |
|
| | | public class ItemLogicUtility : Singleton<ItemLogicUtility>
|
| | |
| | | }
|
| | | if (cellContainer == null)
|
| | | {
|
| | | cellContainer = await UIUtility.CreateWidget("ItemCell_120", "Container_ItemCell");
|
| | | var inst = await UIUtility.CreateWidget("ItemCell_120", "Container_ItemCell");
|
| | |
|
| | | if (this == null)
|
| | | {
|
| | | if (inst != null) DestroyImmediate(inst);
|
| | | return;
|
| | | }
|
| | |
|
| | | if (cellContainer != null)
|
| | | {
|
| | | DestroyImmediate(inst);
|
| | | return;
|
| | | }
|
| | | cellContainer = inst;
|
| | |
|
| | | if (cellContainer != null)
|
| | | {
|
| | |
| | | if (config == null) return;
|
| | |
|
| | | await LoadPrefab(); //存在被卸载的可能,重新加载
|
| | | if (this == null) return;
|
| | | itemIcon.SetActive(true);
|
| | | bgIcon.SetActive(true);
|
| | |
|
| | |
| | | using LitJson; |
| | | using System.Collections; |
| | | using System.IO; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | public class PackManager : GameSystemManager<PackManager> |
| | | { |
| | |
| | | |
| | | public int[] noRedpointComposeItemIDs; |
| | | |
| | | public override void Init() |
| | | public async override void Init() |
| | | { |
| | | DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent += OnBeforePlayerDataInitialize; |
| | | DTC0403_tagPlayerLoginLoadOK.playerLoginOkEvent += OnPlayerLoginOk; |
| | | ParseConfig(); |
| | | await ParseConfig(); |
| | | //SysNotifyMgr.Instance.sysNotifyEvent += RefreshSysInfo; |
| | | |
| | | |
| | |
| | | |
| | | |
| | | #region 玩家装备特殊逻辑 |
| | | void ParseConfig() |
| | | async UniTask ParseConfig() |
| | | { |
| | | |
| | | ParsePackConfigIni(); |
| | | await ParsePackConfigIni(); |
| | | autoUseItemIDs = JsonMapper.ToObject<int[]>(FuncConfigConfig.Get("AutoUseItem").Numerical1); |
| | | var config= FuncConfigConfig.Get("InitBagCellCount"); |
| | | initBagGridCount = int.Parse(config.Numerical1); |
| | |
| | | noRedpointComposeItemIDs = JsonMapper.ToObject<int[]>(config.Numerical1); |
| | | } |
| | | |
| | | void ParsePackConfigIni() |
| | | async UniTask ParsePackConfigIni() |
| | | { |
| | | string[] lines = LoadConfigIni("MapServerConfig"); |
| | | string[] lines = await LoadConfigIni("MapServerConfig.ini"); |
| | | foreach (string line in lines) |
| | | { |
| | | if (line.StartsWith("PackCnt") && line.Contains("=")) |
| | |
| | | } |
| | | } |
| | | |
| | | public string[] LoadConfigIni(string name) |
| | | public async UniTask<string[]> LoadConfigIni(string name) |
| | | { |
| | | string path = string.Empty; |
| | | #if UNITY_EDITOR |
| | | if (!AssetSource.isUseAssetBundle) |
| | | { |
| | | path = ResourcesPath.CONFIG_FODLER + "/" + name + ".ini"; |
| | | } |
| | | else |
| | | #endif |
| | | { |
| | | //从服务端拷贝是ini,打包用txt统一处理 |
| | | path = AssetVersionUtility.GetAssetFilePath($"Config/{name}.txt"); |
| | | } |
| | | // string path = string.Empty; |
| | | // #if UNITY_EDITOR |
| | | // if (!AssetSource.isUseAssetBundle) |
| | | // { |
| | | // path = ResourcesPath.CONFIG_FODLER + "/" + name + ".ini"; |
| | | // } |
| | | // else |
| | | // #endif |
| | | // { |
| | | // //从服务端拷贝是ini,打包用txt统一处理 |
| | | // path = AssetVersionUtility.GetAssetFilePath($"Config/{name}.txt"); |
| | | // } |
| | | |
| | | return File.ReadAllLines(path); |
| | | return await ResManager.Instance.LoadConfigAsync(name, false); |
| | | |
| | | // return File.ReadAllLines(path); |
| | | } |
| | | |
| | | public int GetCanBuyPackGirdCount(PackType type) |
| | |
| | | { |
| | | return null; |
| | | } |
| | | |
| | | |
| | | ItemModel itemModel = null; |
| | | itemGUIDDict.TryGetValue(guid, out itemModel); |
| | | return itemModel; |
| | |
| | | { |
| | | info.text = LoginManager.Instance.loginErrorInfo; |
| | | } |
| | | |
| | | } |
| | |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | |
| | | |
| | |
| | | m_TotalProgressSlider.value = 0f; |
| | | } |
| | | |
| | | if (null == VersionConfig.config) |
| | | { |
| | | throw new Exception("VersionConfig is null when LaunchWin open, check VersionConfig.GetAsync for more details"); |
| | | } |
| | | |
| | | // m_AlphaTween.SetStartState(); |
| | | |
| | | m_BuildTime.text = VersionConfig.Get().debugVersion ? VersionConfig.Get().buildTime : ""; |
| | | m_BuildTime.text = VersionConfig.config.debugVersion ? VersionConfig.config.buildTime : ""; |
| | | |
| | | if (m_NetworkContainer != null) |
| | | { |
| | | m_NetworkContainer.SetActive(false); |
| | | } |
| | | |
| | | var AppleCheck = InitialFunctionConfig.Get("CheckTime").Numerical1; |
| | | var AndroidCheck = InitialFunctionConfig.Get("CheckTime").Numerical2; |
| | | var CheckAll = InitialFunctionConfig.Get("NetworkCheck").Numerical1; |
| | | var checkTimeCfg = LaunchCommon.InitialFunctionConfig.Get("CheckTime"); |
| | | var networkCheckCfg = LaunchCommon.InitialFunctionConfig.Get("NetworkCheck"); |
| | | Debug.LogErrorFormat("checktimecfg is null {0}, networkCheckCfg is null {1}", checkTimeCfg == null, networkCheckCfg == null); |
| | | var AppleCheck = checkTimeCfg?.Numerical1 ?? "0"; |
| | | var AndroidCheck = checkTimeCfg?.Numerical2 ?? "0"; |
| | | var CheckAll = networkCheckCfg?.Numerical1 ?? "3"; |
| | | AllTimes = int.Parse(CheckAll); |
| | | var CheckTime = InitialFunctionConfig.Get("NetworkCheck").Numerical2; |
| | | var CheckTime = networkCheckCfg?.Numerical2 ?? "5"; |
| | | WaitSeconds = int.Parse(CheckTime); |
| | | ShowCircleView = false; |
| | | if (Application.platform == RuntimePlatform.IPhonePlayer && AppleCheck == "1") |
| | | ShowCircleView = true; |
| | | if (Application.platform == RuntimePlatform.Android && AndroidCheck == "1") |
| | | ShowCircleView = true; |
| | | |
| | | if (ShowCircleView) |
| | | |
| | | if (Application.platform == RuntimePlatform.WebGLPlayer) |
| | | { |
| | | m_AndroidProgressContainer.SetActive(false); |
| | | m_IosProgressContainer.SetActive(true); |
| | | m_Version.text = string.Empty; |
| | | m_IosProgressContainer.SetActive(false); |
| | | LoginManager.Instance.GetVersionStr().ContinueWith(versionStr => |
| | | { |
| | | m_Version.text = versionStr; |
| | | }).Forget(); |
| | | } |
| | | else |
| | | { |
| | | m_AndroidProgressContainer.SetActive(true); |
| | | m_IosProgressContainer.SetActive(false); |
| | | //打包版本 + 功能版本 + 语言ID |
| | | m_Version.text = LoginManager.Instance.GetVersionStr(); |
| | | if (ShowCircleView) |
| | | { |
| | | m_AndroidProgressContainer.SetActive(false); |
| | | m_IosProgressContainer.SetActive(true); |
| | | m_Version.text = string.Empty; |
| | | } |
| | | else |
| | | { |
| | | m_AndroidProgressContainer.SetActive(true); |
| | | m_IosProgressContainer.SetActive(false); |
| | | //打包版本 + 功能版本 + 语言ID |
| | | LoginManager.Instance.GetVersionStr().ContinueWith(versionStr => |
| | | { |
| | | m_Version.text = versionStr; |
| | | }).Forget(); |
| | | } |
| | | } |
| | | |
| | | if (m_StageDescription != null) |
| | |
| | | using System; |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using Cysharp.Threading.Tasks; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | |
| | |
| | | currentProgress = targetProgress = 0; |
| | | Refresh(); |
| | | //打包版本 + 功能版本 + 语言ID |
| | | m_Version.text = LoginManager.Instance.GetVersionStr(); |
| | | LoginManager.Instance.GetVersionStr().ContinueWith(versionStr => |
| | | { |
| | | m_Version.text = versionStr; |
| | | }).Forget(); |
| | | } |
| | | |
| | | protected override void OnPreClose() |
| | |
| | | { |
| | | if (VersionUtility.Instance.versionInfo == null || noticeShowed) |
| | | return; |
| | | var url = VersionUtility.Instance.versionInfo.GetNoticeURL(VersionConfig.Get().branch); |
| | | |
| | | if (null == VersionConfig.config) |
| | | { |
| | | throw new System.Exception("VersionConfig is null when OpenGameNotice, game will pause here"); |
| | | } |
| | | |
| | | var url = VersionUtility.Instance.versionInfo.GetNoticeURL(VersionConfig.config.branch); |
| | | if (!string.IsNullOrEmpty(url)) |
| | | { |
| | | SDKUtils.Instance.OpenUrl(url); |
| | |
| | | { |
| | | if (VersionUtility.Instance.versionInfo == null) |
| | | return false; |
| | | var url = VersionUtility.Instance.versionInfo.GetNoticeURL(VersionConfig.Get().branch); |
| | | |
| | | if (null == VersionConfig.config) |
| | | { |
| | | throw new System.Exception("VersionConfig is null when HasNotice, check VersionConfig.GetAsync for more details"); |
| | | } |
| | | |
| | | var url = VersionUtility.Instance.versionInfo.GetNoticeURL(VersionConfig.config.branch); |
| | | Debug.LogFormat("公告地址:{0}", url); |
| | | return !string.IsNullOrEmpty(url); |
| | | } |
| | |
| | | { |
| | | if (VersionUtility.Instance.versionInfo == null) |
| | | return; |
| | | var url = VersionUtility.Instance.versionInfo.GetNoticeURL(VersionConfig.Get().branch); |
| | | if (null == VersionConfig.config) |
| | | { |
| | | throw new System.Exception("VersionConfig is null when OpenGameNoticeForce, check VersionConfig.GetAsync for more details"); |
| | | } |
| | | var url = VersionUtility.Instance.versionInfo.GetNoticeURL(VersionConfig.config.branch); |
| | | if (!string.IsNullOrEmpty(url)) |
| | | { |
| | | SDKUtils.Instance.OpenUrl(url); |
| | |
| | | // #if UNITY_EDITOR |
| | | // GlobalTimeEvent.Instance.MSEvent += OnMSEvent; |
| | | // #endif |
| | | |
| | | if (null == VersionConfig.config) |
| | | { |
| | | await VersionConfig.GetAsync(); |
| | | } |
| | | } |
| | | |
| | | public override void Release() |
| | |
| | | { |
| | | GameNetSystem.Instance.SetIsWaitLogin(false); |
| | | var send = new C0101_tagCPlayerLogin(); |
| | | switch (VersionConfig.Get().versionAuthority) |
| | | switch (VersionConfig.config.versionAuthority) |
| | | { |
| | | case VersionAuthority.InterTest: |
| | | send.IDType = 1; |
| | |
| | | send.MAC = DeviceUtility.GetMac(); |
| | | send.Version = _serverInfo.Version; |
| | | send.LineNO = 255; |
| | | send.AppID = VersionConfig.Get().appId; |
| | | send.AppID = VersionConfig.config.appId; |
| | | send.AccountID = 1000;// 内部登陆的时候的id |
| | | send.TokenExpire = "1519750743000";// 内部登陆的时长,无所谓的 |
| | | send.Phone = 0; |
| | |
| | | { |
| | | var deviceInfo = DeviceUtility.GetDeviceModel(); |
| | | deviceInfo.Replace(" ", "").Replace("=", "").Replace("%", "").Replace("-", "").Replace("|", ""); |
| | | var versionStr = StringUtility.Concat(VersionConfig.Get().version, "_", |
| | | VersionConfig.Get().buildIndex.ToString(), "_", |
| | | var versionStr = StringUtility.Concat(VersionConfig.config.version, "_", |
| | | VersionConfig.config.buildIndex.ToString(), "_", |
| | | hotVersion, "-", deviceInfo); |
| | | |
| | | send.Extra = StringUtility.Concat(VersionConfig.Get().SpID, "|", |
| | | send.Extra = StringUtility.Concat(VersionConfig.config.SpID, "|", |
| | | SDKUtils.Instance.Device.uniqueID, "|", |
| | | sdkLoginResult.token, "|", |
| | | sdkLoginResult.qkUserName, "|", |
| | |
| | | send.MAC = DeviceUtility.GetMac(); |
| | | send.Version = _serverInfo.Version; |
| | | send.LineNO = 255; |
| | | send.AppID = VersionConfig.Get().appId; |
| | | send.AppID = VersionConfig.config.appId; |
| | | send.AccountID = (uint)sdkLoginResult.accountID; |
| | | send.TokenExpire = sdkLoginResult.tokenExpire; |
| | | send.Phone = (byte)sdkLoginResult.phone; |
| | |
| | | return send; |
| | | } |
| | | |
| | | public string GetVersionStr() |
| | | public async UniTask<string> GetVersionStr() |
| | | { |
| | | return StringUtility.Concat(VersionConfig.Get().version, "_", VersionConfig.Get().buildIndex.ToString(), "_", InitialFunctionConfig.Get("version").Numerical1); |
| | | await VersionConfig.GetAsync(); |
| | | await InitialFunctionConfig.LazyInitAsync(); |
| | | var versionConfig = VersionConfig.config; |
| | | var funcVersionNumerical = InitialFunctionConfig.Get("version")?.Numerical1 ?? string.Empty; |
| | | if (versionConfig == null) |
| | | { |
| | | return funcVersionNumerical; |
| | | } |
| | | return StringUtility.Concat(versionConfig.version, "_", versionConfig.buildIndex.ToString(), "_", funcVersionNumerical); |
| | | } |
| | | } |
| | |
| | | using UnityEngine.UI; |
| | | using System.IO; |
| | | using Cysharp.Threading.Tasks; |
| | | using UnityEngine.EventSystems; |
| | | |
| | | public class LoginWin : UIBase, ICanvasRaycastFilter |
| | | { |
| | |
| | | base.OnPreOpen(); |
| | | Debug.Log("打开登录窗口"); |
| | | LoginManager.Instance.RefreshHotVersion(); |
| | | LaunchBackGroundWin launchBackGroundWin = UIManager.Instance.GetUI<LaunchBackGroundWin>(); |
| | | if (null != launchBackGroundWin) |
| | | { |
| | | launchBackGroundWin.transform.SetAsFirstSibling(); |
| | | } |
| | | |
| | | ServerListCenter.Instance.serverSelectEvent += OnServerChange; |
| | | ServerListCenter.Instance.onServerListRefreshEvent += OnServerListRefresh; |
| | |
| | | { |
| | | base.Refresh(); |
| | | Debug.Log("刷新登录窗口"); |
| | | LogLoginInteractionDiagnostics("Refresh begin"); |
| | | |
| | | //打包版本 + 功能版本 + 语言ID |
| | | verInfo.text = LoginManager.Instance.GetVersionStr(); |
| | | LoginManager.Instance.GetVersionStr().ContinueWith(versionStr => |
| | | { |
| | | verInfo.text = versionStr; |
| | | }).Forget(); |
| | | |
| | | BuiltInLoader.LoadSpriteAsync("TB_DL_Logo").ContinueWith(sprite => |
| | | { |
| | | m_Logo.overrideSprite = sprite; |
| | | m_Logo.SetNativeSize(); |
| | | m_Logo.rectTransform.anchoredPosition = VersionConfig.Get().logoPosition; |
| | | VersionConfig.GetAsync().ContinueWith(config => |
| | | { |
| | | m_Logo.rectTransform.anchoredPosition = config.logoPosition; |
| | | }).Forget(); |
| | | m_Notice.SetActive(GameNotice.HasNotice()); |
| | | }).Forget(); |
| | | |
| | |
| | | // 账号切换 |
| | | m_SwitchAccount.SetActive(false); |
| | | // 用户帮助 |
| | | bool isGetServerList = ServerListCenter.Instance.serverListGot; |
| | | |
| | | m_ContainerAccount.SetActive(false); |
| | | |
| | | // TODO YYL |
| | | var appId = VersionConfig.Get().appId; |
| | | var branch = VersionConfig.Get().branch; |
| | | VersionConfig.GetAsync().ContinueWith(config => |
| | | { |
| | | var appId = VersionConfig.config.appId; |
| | | var branch = VersionConfig.config.branch; |
| | | m_ContainerAccount.SetActive(isGetServerList |
| | | && (VersionConfig.config.versionAuthority == VersionAuthority.InterTest || VersionConfig.config.isBanShu)); |
| | | }).Forget(); |
| | | |
| | | // m_UserHelp.SetActive(ContactConfig.GetConfig(appId, branch) != null); |
| | | |
| | | // 是否已经获取到服务器列表 |
| | | bool isGetServerList = ServerListCenter.Instance.serverListGot; |
| | | m_WaitServerList.SetActive(!isGetServerList); |
| | | |
| | | m_ContainerEnterGame.SetActive(isGetServerList); |
| | | m_ContainerAccount.SetActive(isGetServerList |
| | | && (VersionConfig.Get().versionAuthority == VersionAuthority.InterTest || VersionConfig.Get().isBanShu)); |
| | | |
| | | m_EnterGame.SetActive(isGetServerList); |
| | | |
| | | if (isGetServerList) |
| | |
| | | |
| | | // 用户协议 todo |
| | | checkRead.isOn = LocalSave.GetBool("secretToggleStart5"); |
| | | } |
| | | |
| | | public async UniTask RefreshAsync() |
| | | { |
| | | base.Refresh(); |
| | | Debug.Log("刷新登录窗口"); |
| | | |
| | | //打包版本 + 功能版本 + 语言ID |
| | | verInfo.text = LoginManager.Instance.GetVersionStr(); |
| | | |
| | | var sprite = await BuiltInLoader.LoadSpriteAsync("TB_DL_Logo"); |
| | | if (this == null) return; |
| | | m_Logo.overrideSprite = sprite; |
| | | m_Logo.SetNativeSize(); |
| | | m_Logo.rectTransform.anchoredPosition = VersionConfig.Get().logoPosition; |
| | | m_Notice.SetActive(GameNotice.HasNotice()); |
| | | |
| | | |
| | | bool hasNotice = GameNotice.HasNotice(); |
| | | |
| | | // 账号切换 |
| | | m_SwitchAccount.SetActive(false); |
| | | // 用户帮助 |
| | | // TODO YYL |
| | | var appId = VersionConfig.Get().appId; |
| | | var branch = VersionConfig.Get().branch; |
| | | // m_UserHelp.SetActive(ContactConfig.GetConfig(appId, branch) != null); |
| | | |
| | | // 是否已经获取到服务器列表 |
| | | bool isGetServerList = ServerListCenter.Instance.serverListGot; |
| | | m_WaitServerList.SetActive(!isGetServerList); |
| | | |
| | | m_ContainerEnterGame.SetActive(isGetServerList); |
| | | m_ContainerAccount.SetActive(isGetServerList |
| | | && (VersionConfig.Get().versionAuthority == VersionAuthority.InterTest || VersionConfig.Get().isBanShu)); |
| | | m_EnterGame.SetActive(isGetServerList); |
| | | |
| | | if (isGetServerList) |
| | | { |
| | | ChangeServerInfo(ServerListCenter.Instance.currentServer); |
| | | } |
| | | |
| | | |
| | | ChangeUserInfo(LoginManager.Instance.localSaveAccountName); |
| | | |
| | | m_EnterGame.SetActive(true); |
| | | //m_QQLogin.SetActive(false); |
| | | //m_WXLogin.SetActive(false); |
| | | |
| | | // 用户协议 todo |
| | | checkRead.isOn = LocalSave.GetBool("secretToggleStart5"); |
| | | LogLoginInteractionDiagnostics("Refresh end"); |
| | | DelayLogLoginInteractionDiagnostics().Forget(); |
| | | } |
| | | |
| | | private void OnLoginOk(SDKUtils.FP_LoginOk arg0) |
| | |
| | | |
| | | private void OnServerListRefresh() |
| | | { |
| | | if (null == VersionConfig.config) |
| | | { |
| | | throw new System.Exception("VersionConfig is null when OnServerListRefresh, check VersionConfig.GetAsync for more details"); |
| | | } |
| | | m_WaitServerList.SetActive(!ServerListCenter.Instance.serverListGot); |
| | | m_ContainerEnterGame.SetActive(ServerListCenter.Instance.serverListGot); |
| | | m_ContainerAccount.SetActive(ServerListCenter.Instance.serverListGot |
| | | && (VersionConfig.Get().versionAuthority == VersionAuthority.InterTest || VersionConfig.Get().isBanShu)); |
| | | && (VersionConfig.config.versionAuthority == VersionAuthority.InterTest || VersionConfig.config.isBanShu)); |
| | | } |
| | | |
| | | protected virtual void EnterGame() |
| | |
| | | { |
| | | raycastTarget = true; |
| | | LoginManager.Instance.RequestServerListLoop(); |
| | | } |
| | | |
| | | private void LogLoginInteractionDiagnostics(string context) |
| | | { |
| | | var eventSystem = EventSystem.current; |
| | | Debug.Log($"[LoginWin][Diag] {context} sortingOrder={GetSortingOrder()} siblingIndex={transform.GetSiblingIndex()} raycastTarget={raycastTarget} canvasGroup.blocksRaycasts={(canvasGroup != null ? canvasGroup.blocksRaycasts : false)} canvasGroup.interactable={(canvasGroup != null ? canvasGroup.interactable : false)} EventSystem={(eventSystem != null ? eventSystem.name : "<null>")} account.enabled={(m_Account != null && m_Account.enabled)} account.interactable={(m_Account != null && m_Account.interactable)} enter.active={(m_EnterGame != null && m_EnterGame.gameObject.activeInHierarchy)} enter.interactable={(m_EnterGame != null && m_EnterGame.interactable)} serverSelect.interactable={(m_ServerSelect != null && m_ServerSelect.interactable)} waitServerListActive={(m_WaitServerList != null && m_WaitServerList.gameObject.activeInHierarchy)} enterContainerActive={(m_ContainerEnterGame != null && m_ContainerEnterGame.gameObject.activeInHierarchy)}"); |
| | | UIManager.Instance.DumpUIDiagnostics("LoginWin/" + context); |
| | | } |
| | | |
| | | private async UniTaskVoid DelayLogLoginInteractionDiagnostics() |
| | | { |
| | | await UniTask.DelayFrame(2); |
| | | LogLoginInteractionDiagnostics("Refresh +2f"); |
| | | await UniTask.DelayFrame(30); |
| | | LogLoginInteractionDiagnostics("Refresh +32f"); |
| | | } |
| | | |
| | | |
| | |
| | | if (GameNetSystem.Instance.netState == GameNetSystem.NetState.NerverConnect || |
| | | GameNetSystem.Instance.netState == GameNetSystem.NetState.DisConnected) |
| | | { |
| | | switch (VersionConfig.Get().versionAuthority) |
| | | switch (VersionConfig.config.versionAuthority) |
| | | { |
| | | case VersionAuthority.InterTest: |
| | | if (string.IsNullOrEmpty(m_Account.text)) |
| | |
| | | using UnityEngine; |
| | | using LitJson; |
| | | using System; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | public class ServerListCenter : Singleton<ServerListCenter> |
| | | { |
| | | public static readonly string[] JUMP_URL = new string[] |
| | | { |
| | | "http://xssgcenter.secondworld.net.cn:11000/center/server_list.php/?", |
| | | "http://gamecenter.secondworld.net.cn:11000/center/server_list.php/?", |
| | | "http://106.55.151.92:11000/center/server_list_new.php/?" |
| | | }; |
| | | |
| | |
| | | |
| | | } |
| | | |
| | | public void RequestJumpUrl() |
| | | public async UniTask RequestJumpUrl() |
| | | { |
| | | if (VersionUtility.Instance.InIosAuditTime()) |
| | | if (await VersionUtility.Instance.InIosAuditTime()) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | var url = StringUtility.Concat(JUMP_URL[jumpUrlIndex % JUMP_URL.Length], "game=xssg&flag=", VersionConfig.Get().appId, "_", VersionConfig.Get().branch.ToString(), "_", VersionConfig.Get().version); |
| | | if (VersionConfig.config == null) |
| | | { |
| | | throw new System.Exception("VersionConfig is null when RequestJumpUrl, check VersionConfig.GetAsync for more details"); |
| | | } |
| | | |
| | | var url = StringUtility.Concat(JUMP_URL[jumpUrlIndex % JUMP_URL.Length], "game=xssg&flag=", VersionConfig.config.appId, "_", VersionConfig.config.branch.ToString(), "_", VersionConfig.config.version); |
| | | jumpUrlIndex++; |
| | | serverUrl = url; |
| | | // 加时间戳防止浏览器/CDN缓存 |
| | | url = StringUtility.Concat(url, "&_t=", DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString()); |
| | | Debug.Log("http地址:serverlist " + url); |
| | | HttpRequest.Instance.RequestHttpGet(url, HttpRequest.defaultHttpContentType, 1, OnRequestJumpUrl); |
| | | } |
| | |
| | | { |
| | | if (_ok) |
| | | { |
| | | // 去除响应开头可能存在的 UTF-8 BOM(\uFEFF),否则 WebGL 下会拼成 localhost:8080/%EF%BB%BF... 导致 404 |
| | | _result = _result.TrimStart('\uFEFF'); |
| | | |
| | | var serverUrls = _result.Split(new string[] { "||" }, StringSplitOptions.RemoveEmptyEntries); |
| | | SERVERLIST_URL_COMMON = serverUrls[0]; |
| | | SERVERLIST_URL_PLAYER = serverUrls[1]; |
| | | |
| | | Debug.LogError("SERVERLIST_URL_COMMON is " + SERVERLIST_URL_COMMON); |
| | | Debug.LogError("SERVERLIST_URL_PLAYER is " + SERVERLIST_URL_PLAYER); |
| | | RequestServerList(); |
| | | } |
| | | else |
| | | { |
| | | Debug.Log("http 数据通讯: ServerlistCenter:" + serverUrl + " result:" + _result); |
| | | //BuglyAgent.ReportException(new System.Exception(), "http 数据通讯: ServerlistCenter:" + serverUrl + " result:" + _result); |
| | | Clock.AlarmAt(DateTime.Now + new TimeSpan(TimeSpan.TicksPerSecond), RequestJumpUrl); |
| | | Clock.AlarmAt(DateTime.Now + new TimeSpan(TimeSpan.TicksPerSecond), () => RequestJumpUrl().Forget()); |
| | | } |
| | | } |
| | | |
| | |
| | | serverListPlayerPartGot = false; |
| | | RequestServerCommonList(); |
| | | |
| | | if (VersionConfig.Get().versionAuthority == VersionAuthority.InterTest) |
| | | if (VersionConfig.config == null) |
| | | { |
| | | throw new System.Exception("VersionConfig is null when RequestServerList, check VersionConfig.GetAsync for more details"); |
| | | } |
| | | |
| | | if (VersionConfig.config.versionAuthority == VersionAuthority.InterTest) |
| | | { |
| | | var localSaveAccountName = LocalSave.GetString(LoginManager.USER_ACCOUNT); |
| | | RequestServerListPlayer(localSaveAccountName); |
| | |
| | | |
| | | public void RequestServerCommonList() |
| | | { |
| | | HttpRequest.Instance.RequestHttpGet(SERVERLIST_URL_COMMON, HttpRequest.defaultHttpContentType, 1, OnGetServerList); |
| | | // 加时间戳防止浏览器/CDN缓存 |
| | | var url = SERVERLIST_URL_COMMON; |
| | | var separator = url.Contains("?") ? "&" : "?"; |
| | | url = StringUtility.Concat(url, separator, "_t=", DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString()); |
| | | HttpRequest.Instance.RequestHttpGet(url, HttpRequest.defaultHttpContentType, 1, OnGetServerList); |
| | | } |
| | | |
| | | private void OnGetServerList(bool _ok, string _result) |
| | | { |
| | | if (_ok) |
| | | { |
| | | _result = _result.TrimStart('\uFEFF'); |
| | | Debug.LogError("get server list string is " + _result); |
| | | ServerListParser.Instance.PushCommonServerListRawData(_result); |
| | | NetLinkWin.Hide(); |
| | | } |
| | | else |
| | | { |
| | | Debug.LogError("failure to get server list " + _result); |
| | | Clock.AlarmAt(DateTime.Now + new TimeSpan(TimeSpan.TicksPerSecond), RequestServerCommonList); |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | public void RequestServerListPlayer(string _accountName) |
| | | public async void RequestServerListPlayer(string _accountName) |
| | | { |
| | | if (VersionUtility.Instance.InIosAuditTime()) |
| | | if (await VersionUtility.Instance.InIosAuditTime()) |
| | | { |
| | | return; |
| | | } |
| | |
| | | url = StringUtility.Concat(SERVERLIST_URL_PLAYER, "&", HttpRequest.HashtablaToString(tables)); |
| | | } |
| | | |
| | | // 加时间戳防止浏览器/CDN缓存 |
| | | url = StringUtility.Concat(url, "&_t=", DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString()); |
| | | HttpRequest.Instance.RequestHttpGet(url, HttpRequest.defaultHttpContentType, 1, OnGetServerListPlayer); |
| | | } |
| | | |
| | |
| | | if (_ok) |
| | | { |
| | | serverListPlayerPartGot = true; |
| | | _result = _result.TrimStart('\uFEFF'); |
| | | ServerListParser.Instance.PushPlayerServerListRawData(_result); |
| | | } |
| | | else |
| | |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using Cysharp.Threading.Tasks; |
| | | using UnityEngine; |
| | | using System.Threading; |
| | | using LitJson; |
| | | |
| | | public class ServerListParser : SingletonMonobehaviour<ServerListParser> |
| | |
| | | public void PushCommonServerListRawData(string content) |
| | | { |
| | | hasCommonResult = false; |
| | | ThreadPool.QueueUserWorkItem((object aaa) => |
| | | { |
| | | serverInfoCommon = JsonMapper.ToObject<ServerInfoCommon>(content); |
| | | hasCommonResult = true; |
| | | }); |
| | | ParseCommonServerListAsync(content).Forget(); |
| | | } |
| | | |
| | | private async UniTaskVoid ParseCommonServerListAsync(string content) |
| | | { |
| | | await UniTask.Yield(); |
| | | serverInfoCommon = JsonMapper.ToObject<ServerInfoCommon>(content); |
| | | hasCommonResult = true; |
| | | } |
| | | |
| | | public void PushPlayerServerListRawData(string content) |
| | |
| | | if (RankArr["player"]["group_list"].Count == 0) |
| | | return; |
| | | |
| | | ThreadPool.QueueUserWorkItem((object aaa) => |
| | | { |
| | | serverInfoPlayer = JsonMapper.ToObject<ServerInfoPlayer>(content); |
| | | hasPlayerResult = true; |
| | | SetIsInWhiteList(); |
| | | }); |
| | | ParsePlayerServerListAsync(content).Forget(); |
| | | } |
| | | |
| | | private async UniTaskVoid ParsePlayerServerListAsync(string content) |
| | | { |
| | | await UniTask.Yield(); |
| | | serverInfoPlayer = JsonMapper.ToObject<ServerInfoPlayer>(content); |
| | | hasPlayerResult = true; |
| | | SetIsInWhiteList(); |
| | | } |
| | | |
| | | public void ReportCommonResult() |
| | |
| | | var groupDatas = new List<ServerDataCouple>(); |
| | | var serverDataList = new List<ServerData>(serverGroup.group_list); |
| | | |
| | | if (null == VersionConfig.config) |
| | | { |
| | | throw new System.Exception("VersionConfig is null when RefreshServerList, check VersionConfig.GetAsync for more details"); |
| | | } |
| | | |
| | | for (int i = serverDataList.Count - 1; i >= 0; i--) |
| | | { |
| | | if (VersionConfig.Get().isBanShu) |
| | | if (VersionConfig.config.isBanShu) |
| | | { |
| | | if (serverDataList[i].region_flag != 8000) |
| | | { |
| | |
| | | using System; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | public class MailCell : CellView |
| | | { |
| | |
| | | txtCurrentMailCount.text = StringUtility.Concat(personalMailCount.ToString(), "/", MailManager.Instance.personalMailMaxLimitCount.ToString()); |
| | | } |
| | | |
| | | protected override void OpenSubUIByTabIndex() |
| | | protected override async void OpenSubUIByTabIndex() |
| | | { |
| | | switch (functionOrder) |
| | | { |
| | |
| | | using System; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | |
| | | public class AutoFightWin : UIBase |
| | |
| | | |
| | | // if (null != battleField) |
| | | // { |
| | | // StoryBossBattleWin fsBattleWin = UIManager.Instance.OpenWindowAsync<StoryBossBattleWin>().Forget(); |
| | | // StoryBossBattleWin fsBattleWin = await UIManager.Instance.OpenWindowAsync<StoryBossBattleWin>(); |
| | | // fsBattleWin.SetBattleField(battleField); |
| | | // return; |
| | | // } |
| | |
| | | using System; |
| | | using System; |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | /// <summary> |
| | | /// 游戏主界面底部功能按钮 |
| | |
| | | /// <summary> |
| | | /// 根据标签索引打开对应的子界面 |
| | | /// </summary> |
| | | protected override void OpenSubUIByTabIndex() |
| | | protected override async void OpenSubUIByTabIndex() |
| | | { |
| | | |
| | | Debug.Log("打开子界面 : " + functionOrder); |
| | |
| | | // 打开主页界面 |
| | | if (!UIManager.Instance.IsOpened<BattleWin>()) |
| | | { |
| | | UIManager.Instance.OpenWindowAsync<BattleWin>().ContinueWith(battleWin => |
| | | battleWin.SetBattleField(BattleManager.Instance.storyBattleField)).Forget(); |
| | | BattleWin battleWin = await UIManager.Instance.OpenWindowAsync<BattleWin>(); |
| | | battleWin.SetBattleField(BattleManager.Instance.storyBattleField); |
| | | } |
| | | else |
| | | { |
| | | BattleWin battleWin = UIManager.Instance.GetUI<BattleWin>(); |
| | | battleWin.SetBattleField(BattleManager.Instance.storyBattleField); |
| | | } |
| | | UIManager.Instance.OpenWindowAsync<HomeWin>().ContinueWith(w => currentSubUI = w).Forget(); |
| | | currentSubUI = await UIManager.Instance.OpenWindowAsync<HomeWin>(); |
| | | break; |
| | | case 1: |
| | | UIManager.Instance.OpenWindowAsync<AffairBaseWin>().ContinueWith(w => currentSubUI = w).Forget(); |
| | | currentSubUI = await UIManager.Instance.OpenWindowAsync<AffairBaseWin>(); |
| | | break; |
| | | case 2: |
| | | if (gameTip.gameObject.activeSelf) |
| | |
| | | HappyXBModel.Instance.startTenCallGuide = true; |
| | | } |
| | | } |
| | | UIManager.Instance.OpenWindowAsync<HeroBaseWin>(0).ContinueWith(w => currentSubUI = w).Forget(); |
| | | currentSubUI = await UIManager.Instance.OpenWindowAsync<HeroBaseWin>(0); |
| | | break; |
| | | // case 3: |
| | | // 挑战界面不跳转 |
| | | // Debug.Log("打开挑战界面"); |
| | | // break; |
| | | case 4: |
| | | UIManager.Instance.OpenWindowAsync<GuildBaseWin>().ContinueWith(w => currentSubUI = w).Forget(); |
| | | currentSubUI = await UIManager.Instance.OpenWindowAsync<GuildBaseWin>(); |
| | | break; |
| | | default: |
| | | Debug.LogWarning("未知的标签索引: " + functionOrder); |
| | |
| | | { |
| | | if (nextCantAttackMask.localScale == Vector3.one) |
| | | { |
| | | if (BattleManager.Instance.storyBattleField.IsCanRequestFight()) |
| | | if (BattleManager.Instance.storyBattleField != null && BattleManager.Instance.storyBattleField.IsCanRequestFight()) |
| | | { |
| | | nextCantAttackMask.localScale = Vector3.zero; |
| | | } |
| | |
| | | using UnityEngine;
|
| | | using System.Collections;
|
| | | using UnityEngine.UI;
|
| | | using Cysharp.Threading.Tasks;
|
| | |
|
| | | using System.Collections.Generic;
|
| | | using System;
|
| | |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | using DG.Tweening; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | //主界面的右边栏缩进功能 |
| | | public class RightFuncInHome : MonoBehaviour |
| | |
| | | m_ServerTipPrepared = true; |
| | | |
| | | #if UNITY_EDITOR |
| | | m_ContainerGM.SetActive(VersionConfig.Get().debugVersion); |
| | | m_ContainerGM.SetActive(VersionConfig.config.debugVersion); |
| | | #else |
| | | m_ContainerGM.SetActive(false); |
| | | #endif |
| | |
| | | using LitJson; |
| | | using System; |
| | | using System.Linq; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | |
| | | public class MinggeManager : GameSystemManager<MinggeManager> |
| | |
| | | using System.Collections.Generic;
|
| | | using System;
|
| | | using LitJson;
|
| | | using Cysharp.Threading.Tasks; |
| | |
|
| | |
|
| | |
|
| | |
| | | using UnityEngine; |
| | | using System.Collections; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | using UnityEngine.UI; |
| | | using UnityEngine.Events; |
| | |
| | | using System.Linq; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | |
| | | ////开服盛典 |
| | |
| | | } |
| | | |
| | | |
| | | protected override void OpenSubUIByTabIndex() |
| | | protected override async void OpenSubUIByTabIndex() |
| | | { |
| | | switch (functionOrder) |
| | | { |
| | | case 0: |
| | | currentSubUI = UIManager.Instance.OpenWindowAsync<OSGalaMissionWin>().Forget(); |
| | | currentSubUI = await UIManager.Instance.OpenWindowAsync<OSGalaMissionWin>(); |
| | | break; |
| | | case 1: |
| | | currentSubUI = UIManager.Instance.OpenWindowAsync<OSGalaChangeWin>().Forget(); |
| | | currentSubUI = await UIManager.Instance.OpenWindowAsync<OSGalaChangeWin>(); |
| | | break; |
| | | case 2: |
| | | currentSubUI = UIManager.Instance.OpenWindowAsync<OSGalaGiftWin>().Forget(); |
| | | currentSubUI = await UIManager.Instance.OpenWindowAsync<OSGalaGiftWin>(); |
| | | break; |
| | | } |
| | | } |
| | |
| | | using System.Linq; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | public class OSGalaChangeCell : CellView |
| | | { |
| | |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | |
| | | ////开服活动-武将招募活动 |
| | |
| | | } |
| | | |
| | | |
| | | protected override void OpenSubUIByTabIndex() |
| | | protected override async void OpenSubUIByTabIndex() |
| | | { |
| | | switch (functionOrder) |
| | | { |
| | | case 0: |
| | | RankModel.Instance.ResetQueryParam(); |
| | | RankModel.Instance.QueryRankByPage(4, watchID: (int)PlayerDatas.Instance.baseData.PlayerID); |
| | | currentSubUI = UIManager.Instance.OpenWindowAsync<OSRankWin>(4).Forget(); |
| | | currentSubUI = await UIManager.Instance.OpenWindowAsync<OSRankWin>(4); |
| | | break; |
| | | case 1: |
| | | currentSubUI = UIManager.Instance.OpenWindowAsync<OSRankHeroCallAwardWin>().Forget(); |
| | | currentSubUI = await UIManager.Instance.OpenWindowAsync<OSRankHeroCallAwardWin>(); |
| | | break; |
| | | case 2: |
| | | currentSubUI = UIManager.Instance.OpenWindowAsync<OSRankHeroCallGiftWin>().Forget(); |
| | | currentSubUI = await UIManager.Instance.OpenWindowAsync<OSRankHeroCallGiftWin>(); |
| | | break; |
| | | } |
| | | } |
| | |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | |
| | | ////开服活动-主线关卡活动 |
| | |
| | | } |
| | | } |
| | | |
| | | protected override void OpenSubUIByTabIndex() |
| | | protected override async void OpenSubUIByTabIndex() |
| | | { |
| | | switch (functionOrder) |
| | | { |
| | | case 0: |
| | | RankModel.Instance.ResetQueryParam(); |
| | | RankModel.Instance.QueryRankByPage(3, watchID: (int)PlayerDatas.Instance.baseData.PlayerID); |
| | | currentSubUI = UIManager.Instance.OpenWindowAsync<OSRankWin>(3).Forget(); |
| | | currentSubUI = await UIManager.Instance.OpenWindowAsync<OSRankWin>(3); |
| | | break; |
| | | case 1: |
| | | currentSubUI = UIManager.Instance.OpenWindowAsync<OSRankMainLeveAwardWin>().Forget(); |
| | | currentSubUI = await UIManager.Instance.OpenWindowAsync<OSRankMainLeveAwardWin>(); |
| | | break; |
| | | } |
| | | } |
| | |
| | |
|
| | |
|
| | |
|
| | | using System;
|
| | | using System.Collections.Generic;
|
| | | using System.Linq;
|
| | | using UnityEngine;
|
| | | using Cysharp.Threading.Tasks; |
| | |
|
| | | public class OfficialRankManager : GameSystemManager<OfficialRankManager>
|
| | | {
|
| | |
| | | prefab = tmp.gameObject; |
| | | return; |
| | | } |
| | | prefab = await UIUtility.CreateWidget("OfficialTitleCell", "OfficialTitleCell"); |
| | | var inst = await UIUtility.CreateWidget("OfficialTitleCell", "OfficialTitleCell"); |
| | | |
| | | if (this == null) |
| | | { |
| | | if (prefab != null) |
| | | { |
| | | GameObject.DestroyImmediate(prefab); |
| | | } |
| | | if (inst != null) GameObject.DestroyImmediate(inst); |
| | | return; |
| | | } |
| | | |
| | | if (prefab != null) |
| | | { |
| | | GameObject.DestroyImmediate(inst); |
| | | return; |
| | | } |
| | | prefab = inst; |
| | | |
| | | prefab.transform.SetParentEx(this.transform, Vector3.zero, Quaternion.identity, Vector3.one); |
| | | prefab.transform.SetAsFirstSibling(); |
| | |
| | | public async UniTask InitUI(int offcialRank, int titleID) |
| | | { |
| | | await LoadPrefab(); //存在被卸载的可能,重新加载 |
| | | if (this == null) return; |
| | | if (!TitleConfig.HasKey(titleID)) |
| | | { |
| | | officialRankObj.SetActive(true); |
| | |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | public class OtherEquipCardItem : MonoBehaviour |
| | | { |
| | |
| | | //非对比的显示 |
| | | if (i < HeroUIManager.Instance.normalGiftMaxCnt) |
| | | { |
| | | giftBaseCells[i].Init(0, 0); |
| | | giftBaseCells[i].Init(0, 0).Forget(); |
| | | } |
| | | else |
| | | { |
| | | giftBaseCells[i].Init(-1, 0, 0, heroID, i); |
| | | giftBaseCells[i].Init(-1, 0, 0, heroID, i).Forget(); |
| | | } |
| | | } |
| | | return; |
| | |
| | | int giftID = talentIDList[i]; |
| | | int giftLV = talentLvList[i]; |
| | | int state = 0; //0:不显示 1:新增 2:提升 |
| | | giftBaseCells[i].Init(giftID, giftLV, state, heroID, i, awakeLevel); |
| | | giftBaseCells[i].Init(giftID, giftLV, state, heroID, i, awakeLevel).Forget(); |
| | | } |
| | | else |
| | | { |
| | | //非对比的显示 |
| | | if (i < HeroUIManager.Instance.normalGiftMaxCnt) |
| | | { |
| | | giftBaseCells[i].Init(0, 0); |
| | | giftBaseCells[i].Init(0, 0).Forget(); |
| | | } |
| | | else |
| | | { |
| | | giftBaseCells[i].Init(-1, 0, 0, heroID, i); |
| | | giftBaseCells[i].Init(-1, 0, 0, heroID, i).Forget(); |
| | | } |
| | | } |
| | | |
| | |
| | | public async UniTask Init(int heroID, int skinID, int breakLevel = 0, int star = 0, int awakelv = 0, int lv = 0, bool isShowLock = false) |
| | | { |
| | | await LoadPrefab(); //存在被卸载的可能,重新加载 |
| | | if (this == null) return; |
| | | var heroConfig = HeroConfig.Get(heroID); |
| | | |
| | | heroModel.Create(skinID, 1.2f); |
| | |
| | | } |
| | | if (cellContainer == null) |
| | | { |
| | | cellContainer = await UIUtility.CreateWidget("OtherNpcHeroCell", "Container_HeroShow"); |
| | | var inst = await UIUtility.CreateWidget("OtherNpcHeroCell", "Container_HeroShow"); |
| | | |
| | | if (this == null) |
| | | { |
| | | if (null != cellContainer) |
| | | { |
| | | DestroyImmediate(cellContainer); |
| | | } |
| | | if (null != inst) DestroyImmediate(inst); |
| | | return; |
| | | } |
| | | |
| | | if (cellContainer != null) |
| | | { |
| | | DestroyImmediate(inst); |
| | | return; |
| | | } |
| | | cellContainer = inst; |
| | | |
| | | if (cellContainer != null) |
| | | { |
| | | cellContainer.transform.SetParentEx(this.transform, Vector3.zero, Quaternion.identity, Vector3.one); |
| | | cellContainer.transform.SetAsFirstSibling(); |
| | | } |
| | |
| | | using UnityEngine; |
| | | using LitJson; |
| | | using System.Linq; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | |
| | | //查看其他玩家的简短信息, 该模块处理数据,其他由各自功能模块处理 通过OnRevPackage |
| | |
| | | {
|
| | | if (m_button == null)
|
| | | {
|
| | | LoadPrefab();
|
| | | m_button = this.GetComponent<ButtonEx>("AvatarCell/Img_FaceBG");
|
| | | }
|
| | | return m_button;
|
| | |
| | | {
|
| | | if (m_FaceBGImage == null)
|
| | | {
|
| | | LoadPrefab();
|
| | | m_FaceBGImage = this.GetComponent<ImageEx>("AvatarCell/Img_FaceBG");
|
| | | }
|
| | | return m_FaceBGImage;
|
| | |
| | | {
|
| | | if (m_FaceMask == null)
|
| | | {
|
| | | LoadPrefab();
|
| | | m_FaceMask = this.GetComponent<EllipseMask>("AvatarCell/Img_FaceBG/Mask_Face");
|
| | | }
|
| | | return m_FaceMask;
|
| | |
| | | {
|
| | | if (m_FaceUIFrame == null)
|
| | | {
|
| | | LoadPrefab();
|
| | | m_FaceUIFrame = this.GetComponent<UIFrame>("AvatarCell/Img_FaceBG/Mask_Face/Img_Face");
|
| | | }
|
| | | return m_FaceUIFrame;
|
| | |
| | | {
|
| | | if (m_FaceImage == null)
|
| | | {
|
| | | LoadPrefab();
|
| | | m_FaceImage = this.GetComponent<ImageEx>("AvatarCell/Img_FaceBG/Mask_Face/Img_Face");
|
| | | }
|
| | | return m_FaceImage;
|
| | |
| | | {
|
| | | if (m_faceSpine == null)
|
| | | {
|
| | | LoadPrefab();
|
| | | m_faceSpine = this.GetComponent<UIEffectPlayer>("AvatarCell/Img_FaceBG/Mask_Face/Img_Face/Spine_Face");
|
| | | }
|
| | | return m_faceSpine;
|
| | |
| | | {
|
| | | if (m_FacePicImage == null)
|
| | | {
|
| | | LoadPrefab();
|
| | | m_FacePicImage = this.GetComponent<ImageEx>("AvatarCell/Img_FaceBG/Img_FacePic");
|
| | | }
|
| | | return m_FacePicImage;
|
| | |
| | | {
|
| | | if (m_FacePicUIFrame == null)
|
| | | {
|
| | | LoadPrefab();
|
| | | m_FacePicUIFrame = this.GetComponent<UIFrame>("AvatarCell/Img_FaceBG/Img_FacePic");
|
| | | }
|
| | | return m_FacePicUIFrame;
|
| | |
| | | {
|
| | | if (m_facePicSpine == null)
|
| | | {
|
| | | LoadPrefab();
|
| | | m_facePicSpine = this.GetComponent<UIEffectPlayer>("AvatarCell/Img_FaceBG/Img_FacePic/Spine_FacePic");
|
| | | }
|
| | | return m_facePicSpine;
|
| | |
| | | {
|
| | | if (m_redpoint == null)
|
| | | {
|
| | | LoadPrefab();
|
| | | m_redpoint = this.GetComponent<RedpointBehaviour>("AvatarCell/Img_FaceBG/RedPoint");
|
| | | }
|
| | | return m_redpoint;
|
| | |
| | |
|
| | | private void Awake()
|
| | | {
|
| | | LoadPrefab();
|
| | | LoadPrefab().Forget();
|
| | | }
|
| | |
|
| | | public void SetOnLoaded(Action _onloaded)
|
| | |
| | | prefab = tmp.gameObject;
|
| | | return;
|
| | | }
|
| | | prefab = await UIUtility.CreateWidget("AvatarCell", "AvatarCell");
|
| | | var inst = await UIUtility.CreateWidget("AvatarCell", "AvatarCell");
|
| | |
|
| | | if (this == null)
|
| | | {
|
| | | if (prefab != null)
|
| | | {
|
| | | GameObject.DestroyImmediate(prefab);
|
| | | return;
|
| | | }
|
| | | if (inst != null) GameObject.DestroyImmediate(inst);
|
| | | return;
|
| | | }
|
| | |
|
| | | if (prefab != null)
|
| | | {
|
| | | GameObject.DestroyImmediate(inst);
|
| | | return;
|
| | | }
|
| | | prefab = inst;
|
| | |
|
| | | prefab.transform.SetParentEx(this.transform, Vector3.zero, Quaternion.identity, Vector3.one);
|
| | | prefab.transform.SetAsFirstSibling();
|
| | |
|
| | |
| | | using UnityEngine; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | public class PhantasmPavilionWin : FunctionsBaseWin |
| | | { |
| | |
| | | tabButtons[2].redpoint.redpointId = manager.GetRedpointId(PhantasmPavilionRepointType.Title); |
| | | } |
| | | |
| | | protected override void OpenSubUIByTabIndex() |
| | | protected override async void OpenSubUIByTabIndex() |
| | | { |
| | | imgModelBG.SetActive(functionOrder == 0); |
| | | switch (functionOrder) |
| | | { |
| | | case 0: |
| | | //形象 |
| | | currentSubUI = UIManager.Instance.OpenWindowAsync<PhantasmPavilionModelWin>().Forget(); |
| | | currentSubUI = await UIManager.Instance.OpenWindowAsync<PhantasmPavilionModelWin>(); |
| | | manager.nowType = PhantasmPavilionType.Model; |
| | | break; |
| | | case 1: |
| | | //头像 |
| | | currentSubUI = UIManager.Instance.OpenWindowAsync<PhantasmPavilionFaceWin>().Forget(); |
| | | currentSubUI = await UIManager.Instance.OpenWindowAsync<PhantasmPavilionFaceWin>(); |
| | | manager.nowType = PhantasmPavilionType.Face; |
| | | break; |
| | | case 2: |
| | | //称号 |
| | | currentSubUI = UIManager.Instance.OpenWindowAsync<PhantasmPavilionTitleWin>().Forget(); |
| | | currentSubUI = await UIManager.Instance.OpenWindowAsync<PhantasmPavilionTitleWin>(); |
| | | manager.nowType = PhantasmPavilionType.Title; |
| | | break; |
| | | default: |
| | |
| | | { |
| | | [SerializeField] InputField input; |
| | | [SerializeField] Button receiveBtn; |
| | | const string exchangeUrl = "http://xssgcenter.secondworld.net.cn:53003/Coupon/CouponCode.php?"; |
| | | const string exchangeUrl = "http://gamecenter.secondworld.net.cn:53003/Coupon/CouponCode.php?"; |
| | | bool isCool = false; |
| | | float time = 0; |
| | | |
| | |
| | | { |
| | | isCool = true; |
| | | var tables = new Dictionary<string, string>(); |
| | | tables["channel"] = VersionConfig.Get().appId; |
| | | tables["channel"] = VersionConfig.config.appId; |
| | | tables["code"] = passward; |
| | | #if UNITY_EDITOR |
| | | tables["accid"] = LoginManager.Instance.accountBuf; |
| | |
| | | #endif |
| | | tables["sid"] = ServerListCenter.Instance.currentServer.region_flag.ToString(); |
| | | tables["pushurl"] = ServerListCenter.Instance.currentServer.region_domain; |
| | | tables["spid"] = VersionConfig.Get().SpID; |
| | | tables["spid"] = VersionConfig.config.SpID; |
| | | tables["roleid"] = UIHelper.ServerStringTrim(PlayerDatas.Instance.baseData.PlayerName); |
| | | tables["level"] = PlayerDatas.Instance.baseData.LV.ToString(); |
| | | tables["viplevel"] = PlayerDatas.Instance.baseData.VIPLv.ToString(); |
| | |
| | | using System; |
| | | using UnityEngine; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | public class PlayerProfileWin : UIBase |
| | | { |
| | |
| | | #if UNITY_EDITOR
|
| | | orderInfoToCTGID[configs[i].OrderInfo] = configs[i].CTGID;
|
| | | #else
|
| | | if (configs[i].AppId == VersionConfig.Get().appId)
|
| | | if (configs[i].AppId == VersionConfig.config.appId)
|
| | | {
|
| | | orderInfoToCTGID[configs[i].OrderInfo] = configs[i].CTGID;
|
| | | }
|
| | |
| | | return false;
|
| | | }
|
| | | List<OrderInfoConfig> list;
|
| | | if (m_OrderInfoDict.TryGetValue(VersionConfig.Get().appId, out list))
|
| | | if (m_OrderInfoDict.TryGetValue(VersionConfig.config.appId, out list))
|
| | | {
|
| | | for (int i = 0; i < list.Count; i++)
|
| | | {
|
| | |
| | | return result;
|
| | | }
|
| | | List<OrderInfoConfig> list;
|
| | | if (m_OrderInfoDict.TryGetValue(VersionConfig.Get().appId, out list))
|
| | | if (m_OrderInfoDict.TryGetValue(VersionConfig.config.appId, out list))
|
| | | {
|
| | | for (int i = 0; i < list.Count; i++)
|
| | | {
|
| | |
| | | {
|
| | | config = null;
|
| | | List<OrderInfoConfig> list;
|
| | | if (m_OrderInfoDict.TryGetValue(VersionConfig.Get().appId, out list))
|
| | | if (m_OrderInfoDict.TryGetValue(VersionConfig.config.appId, out list))
|
| | | {
|
| | | for (int i = 0; i < list.Count; i++)
|
| | | {
|
| | |
| | |
|
| | | public float GetOnSalePayRmb(int _id)
|
| | | {
|
| | | var appid = VersionConfig.Get().appId;
|
| | | var appid = VersionConfig.config.appId;
|
| | | appid = m_CTGConfigDict.ContainsKey(appid) ? appid : m_CTGConfigDict.Keys.Last();
|
| | | var configs = OrderInfoConfig.GetValues();
|
| | | for (int i = 0; i < configs.Count; i++)
|
| | |
| | |
|
| | | public float GetOrgPayRmb(int _id)
|
| | | {
|
| | | var appid = VersionConfig.Get().appId;
|
| | | var appid = VersionConfig.config.appId;
|
| | | appid = m_CTGConfigDict.ContainsKey(appid) ? appid : m_CTGConfigDict.Keys.Last();
|
| | | var configs = OrderInfoConfig.GetValues();
|
| | | for (int i = 0; i < configs.Count; i++)
|
| | |
| | | return;
|
| | | }
|
| | | var rechargeConfig = CTGConfig.Get(config.CTGID);
|
| | | if (!VersionConfig.Get().appId.Equals(config.AppId))
|
| | | if (!VersionConfig.config.appId.Equals(config.AppId))
|
| | | {
|
| | | return;
|
| | | }
|
| | |
| | | // {
|
| | | // return;
|
| | | // }
|
| | | // var list = GetCTGConfigs(VersionConfig.Get().appId);
|
| | | // var list = GetCTGConfigs(VersionConfig.config.appId);
|
| | | // var config = CTGConfig.Get(list[0]);
|
| | | // if (m_RechargeCountDict.ContainsKey(config.RecordID))
|
| | | // {
|
| | |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | //战场结算界面,存在多个的情况 |
| | | public class BattleFailWin : UIBase |
| | |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | //战场结算界面,存在多个的情况 |
| | | public class BoneBattleFailWin : UIBase |
| | |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | //战场结算界面,存在多个的情况 |
| | | public class WarlordPavilionFailWin : UIBase |
| | |
| | | return; |
| | | } |
| | | |
| | | cellContainer = await UIUtility.CreateWidget("SkillBaseCell", "Container_SkillCell"); |
| | | var inst = await UIUtility.CreateWidget("SkillBaseCell", "Container_SkillCell"); |
| | | |
| | | if (this == null) |
| | | { |
| | | if (null != cellContainer) DestroyImmediate(cellContainer); |
| | | if (null != inst) DestroyImmediate(inst); |
| | | return; |
| | | } |
| | | |
| | | if (cellContainer != null) |
| | | { |
| | | DestroyImmediate(inst); |
| | | return; |
| | | } |
| | | cellContainer = inst; |
| | | |
| | | if (cellContainer != null) |
| | | { |
| | | cellContainer.transform.SetParentEx(this.transform, Vector3.zero, Quaternion.identity, Vector3.one); |
| | | cellContainer.transform.SetAsFirstSibling(); |
| | | } |
| | |
| | | public async UniTask Init(int skillID, UnityAction onclick = null, bool showType = false) |
| | | { |
| | | await LoadPrefab(); //存在被卸载的可能,重新加载 |
| | | if (this == null) return; |
| | | var config = SkillConfig.Get(skillID); |
| | | if (config == null) |
| | | { |
| | |
| | | } |
| | | if (cellContainer == null) |
| | | { |
| | | cellContainer = await UIUtility.CreateWidget("SkillWordCell", "Container_SkillCell"); |
| | | var inst = await UIUtility.CreateWidget("SkillWordCell", "Container_SkillCell"); |
| | | |
| | | if (this == null) |
| | | { |
| | | if (null != cellContainer) |
| | | { |
| | | DestroyImmediate(cellContainer); |
| | | } |
| | | if (null != inst) DestroyImmediate(inst); |
| | | return; |
| | | } |
| | | |
| | | if (cellContainer != null) |
| | | { |
| | | DestroyImmediate(inst); |
| | | return; |
| | | } |
| | | cellContainer = inst; |
| | | |
| | | if (cellContainer != null) |
| | | { |
| | | cellContainer.transform.SetParentEx(this.transform, Vector3.zero, Quaternion.identity, Vector3.one); |
| | | cellContainer.transform.SetAsFirstSibling(); |
| | | } |
| | |
| | | using System.Collections.Generic; |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | public class StoreBaseWin : OneLevelWin |
| | | { |
| | | |
| | | |
| | | protected override void OpenSubUIByTabIndex() |
| | | protected override async void OpenSubUIByTabIndex() |
| | | { |
| | | switch (functionOrder) |
| | | { |
| | | case 0: |
| | | UIManager.Instance.OpenWindowAsync<StoreWin>().ContinueWith(w => currentSubUI = w).Forget(); |
| | | currentSubUI = await UIManager.Instance.OpenWindowAsync<StoreWin>(); |
| | | break; |
| | | case 1: |
| | | // 充值界面 |
| | | UIManager.Instance.OpenWindowAsync<RechargeWin>().ContinueWith(w => currentSubUI = w).Forget(); |
| | | currentSubUI = await UIManager.Instance.OpenWindowAsync<RechargeWin>(); |
| | | break; |
| | | default: |
| | | Debug.LogWarning("未知的标签索引: " + functionOrder); |
| | |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | |
| | | public class StoreCell : MonoBehaviour |
| | |
| | | using System; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using UnityEngine; |
| | |
| | | Refresh(); |
| | | } |
| | | |
| | | protected override void OpenSubUIByTabIndex() |
| | | protected override async void OpenSubUIByTabIndex() |
| | | { |
| | | transRank.SetActive(functionOrder == 0); |
| | | transAward.SetActive(functionOrder == 1); |
| | |
| | | using System.Collections.Generic; |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | public class TimeRushTipWin : UIBase |
| | | { |
| | |
| | | return; |
| | | } |
| | | |
| | | prefab = await UIUtility.CreateWidget("TimingGiftCell", "TimingGiftCell"); |
| | | var inst = await UIUtility.CreateWidget("TimingGiftCell", "TimingGiftCell"); |
| | | |
| | | if (this == null) |
| | | { |
| | | if (null != prefab) DestroyImmediate(prefab); |
| | | if (null != inst) DestroyImmediate(inst); |
| | | return; |
| | | } |
| | | |
| | | if (prefab != null) |
| | | { |
| | | DestroyImmediate(inst); |
| | | return; |
| | | } |
| | | prefab = inst; |
| | | |
| | | prefab.transform.SetParentEx(this.transform, Vector3.zero, Quaternion.identity, Vector3.one); |
| | | prefab.transform.SetAsFirstSibling(); |
| | | } |
| | |
| | | using UnityEngine; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | using System; |
| | | using Cysharp.Threading.Tasks; |
| | |
| | | isComponentReady = true; |
| | | } |
| | | |
| | | protected override void OpenSubUIByTabIndex() |
| | | protected override async void OpenSubUIByTabIndex() |
| | | { |
| | | } |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | Debug.LogError($"{uiName}界面的InitComponentInternal报错: {e.StackTrace}"); |
| | | Debug.LogError($"{uiName}界面的InitComponentInternal报错: message: {e.Message} \nStackTrace: {e.StackTrace}"); |
| | | } |
| | | |
| | | try |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | Debug.LogError($"{uiName}界面的InitComponent报错: {e.StackTrace}"); |
| | | Debug.LogError($"{uiName}界面的InitComponent报错: message: {e.Message} \nStackTrace: {e.StackTrace}"); |
| | | } |
| | | |
| | | // 保存原始值用于动画 |
| | |
| | | { |
| | | if (Screen.height / Screen.width > 1.8)//宽屏需要适配 |
| | | { |
| | | //上下各间隔SafeWidth |
| | | _rectTransform.offsetMax = new Vector2(0, -SafeHeightUp); //上 |
| | | _rectTransform.offsetMin = new Vector2(0, SafeHeightDown); //下 |
| | | _rectTransform.offsetMax = new Vector2(0, -SafeHeightUp); //上 |
| | | _rectTransform.offsetMin = new Vector2(0, SafeHeightDown); //下 |
| | | } |
| | | originalPosition = _rectTransform.anchoredPosition; |
| | | } |
| | |
| | | |
| | | btnClickEmptyClose.enabled = false; |
| | | } |
| | | |
| | | |
| | | protected async void ExecuteNextFrame(Action _action) |
| | | { |
| | |
| | | // 设置UI层级 |
| | | public void SetSortingOrder(int order) |
| | | { |
| | | canvas.sortingOrder = order; |
| | | if (canvas == null) |
| | | canvas = GetComponent<Canvas>(); |
| | | if (canvas != null) |
| | | canvas.sortingOrder = order; |
| | | } |
| | | |
| | | protected virtual void OnPreOpen() |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | Debug.LogError($"{uiName}界面的OnPreOpen报错: {e.StackTrace}"); |
| | | Debug.LogError($"{uiName}界面的OnPreOpen报错: message: {e.Message} \nStackTrace: {e.StackTrace}"); |
| | | } |
| | | |
| | | StopCurrentAnimation(); |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | Debug.LogError($"{uiName}界面的OnOpen报错: {e.StackTrace}"); |
| | | Debug.LogError($"{uiName}界面的OnOpen报错: message: {e.Message} \nStackTrace: {e.StackTrace}"); |
| | | } |
| | | |
| | | ApplyClickEmptySpaceClose(); |
| | | ApplyClickEmptySpaceClose().Forget(); |
| | | |
| | | #if UNITY_WEBGL |
| | | // WebGL 诊断:检测 Image 组件的 sprite 是否为 null |
| | | DiagCheckImageSprites(); |
| | | #endif |
| | | |
| | | ExecuteNextFrame(() => |
| | | { |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | Debug.LogError($"{uiName}界面的NextFrameAfterOpen报错: {e.StackTrace}"); |
| | | Debug.LogError($"{uiName}界面的NextFrameAfterOpen报错: message: {e.Message} \nStackTrace: {e.StackTrace}"); |
| | | } |
| | | }); |
| | | } |
| | |
| | | { |
| | | |
| | | } |
| | | |
| | | #if UNITY_WEBGL |
| | | /// <summary> |
| | | /// WebGL 诊断:检测所有 Image 子组件的 sprite 状态。 |
| | | /// 用于排查 WebGL 构建中 Image 资源丢失的问题。 |
| | | /// </summary> |
| | | private void DiagCheckImageSprites() |
| | | { |
| | | var images = GetComponentsInChildren<Image>(true); |
| | | int nullCount = 0; |
| | | int totalCount = images.Length; |
| | | var sb = new System.Text.StringBuilder(); |
| | | |
| | | foreach (var img in images) |
| | | { |
| | | if (img.sprite == null && img.overrideSprite == null) |
| | | { |
| | | // 跳过 Color-only 或 mask 用途的 Image(无需 sprite) |
| | | if (img.type == Image.Type.Simple && img.color.a < 0.01f) |
| | | continue; |
| | | |
| | | nullCount++; |
| | | string path = GetTransformPath(img.transform); |
| | | sb.AppendLine($" [NULL sprite] {path} (type={img.type}, raycast={img.raycastTarget})"); |
| | | } |
| | | } |
| | | |
| | | var rawImages = GetComponentsInChildren<RawImage>(true); |
| | | int rawNullCount = 0; |
| | | foreach (var ri in rawImages) |
| | | { |
| | | if (ri.texture == null) |
| | | { |
| | | rawNullCount++; |
| | | string path = GetTransformPath(ri.transform); |
| | | sb.AppendLine($" [NULL texture] RawImage: {path}"); |
| | | } |
| | | } |
| | | |
| | | if (nullCount > 0 || rawNullCount > 0) |
| | | { |
| | | Debug.LogWarning($"[UIBase][SpriteDiag] {uiName}: {nullCount}/{totalCount} Image sprites NULL, {rawNullCount} RawImage textures NULL\n{sb}"); |
| | | } |
| | | else |
| | | { |
| | | Debug.Log($"[UIBase][SpriteDiag] {uiName}: All {totalCount} Image sprites OK"); |
| | | } |
| | | |
| | | // 检查 Canvas 状态 |
| | | if (canvas != null) |
| | | { |
| | | Debug.Log($"[UIBase][SpriteDiag] {uiName} Canvas: renderMode={canvas.renderMode}, worldCamera={(canvas.worldCamera != null ? canvas.worldCamera.name : "NULL")}, sortingOrder={canvas.sortingOrder}"); |
| | | } |
| | | } |
| | | |
| | | private string GetTransformPath(Transform t) |
| | | { |
| | | string path = t.name; |
| | | Transform parent = t.parent; |
| | | int depth = 0; |
| | | while (parent != null && parent != transform && depth < 10) |
| | | { |
| | | path = parent.name + "/" + path; |
| | | parent = parent.parent; |
| | | depth++; |
| | | } |
| | | return path; |
| | | } |
| | | #endif |
| | | |
| | | // 关闭UI - 修改后的方法 |
| | | public void HandleClose() |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | Debug.LogError($"{uiName}界面的OnPreClose报错: {e.StackTrace}"); |
| | | Debug.LogError($"{uiName}界面的OnPreClose报错: message: {e.Message} \nStackTrace: {e.StackTrace}"); |
| | | } |
| | | |
| | | StopCurrentAnimation(); |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | Debug.LogError($"{uiName}界面的OnClose报错: {e.StackTrace}"); |
| | | Debug.LogError($"{uiName}界面的OnClose报错: message: {e.Message} \nStackTrace: {e.StackTrace}"); |
| | | } |
| | | |
| | | if (closeAnimationType == UIAnimationType.None) |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | Debug.LogError($"{uiName}界面的CompleteClose报错: {e.StackTrace}"); |
| | | Debug.LogError($"{uiName}界面的CompleteClose报错: message: {e.Message} \nStackTrace: {e.StackTrace}"); |
| | | } |
| | | } |
| | | // 否则在动画完成后禁用游戏对象(在PlayCloseAnimation中处理) |
| | |
| | | } |
| | | catch (System.Exception e) |
| | | { |
| | | Debug.LogError($"播放打开动画时出错: {e.StackTrace}"); |
| | | Debug.LogError($"播放打开动画时出错: message: {e.Message} \nStackTrace: {e.StackTrace}"); |
| | | |
| | | // 出错时确保UI可见并可交互 |
| | | if (canvasGroup != null) |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | Debug.LogError($"{uiName}界面的CompleteClose报错: {e.StackTrace}"); |
| | | Debug.LogError($"{uiName}界面的CompleteClose报错: message: {e.Message} \nStackTrace: {e.StackTrace}"); |
| | | } |
| | | } |
| | | }); |
| | |
| | | } |
| | | catch (System.Exception e) |
| | | { |
| | | Debug.LogError($"播放关闭动画时出错: {e.StackTrace}"); |
| | | Debug.LogError($"播放关闭动画时出错: message: {e.Message} \nStackTrace: {e.StackTrace}"); |
| | | |
| | | // 出错时直接完成关闭 |
| | | isAnimating = false; |
| | |
| | | |
| | | if (!UIManager.Instance.IsOpened(config.WinName)) |
| | | { |
| | | UIManager.Instance.OpenWindow(config.WinName, config.TabIndex).Forget(); |
| | | UIManager.Instance.OpenWindowAsync(config.WinName, config.TabIndex).Forget(); |
| | | } |
| | | else |
| | | { |
| | |
| | | using System; |
| | | using System; |
| | | using UnityEngine; |
| | | using UnityEngine.Video; |
| | | using UnityEngine.UI; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | /// <summary> |
| | | /// UI视频播放器组件 - 支持WebM格式透明视频播放 |
| | |
| | | using UnityEngine; |
| | | using UnityEngine; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | public class TowerBaseWin : OneLevelWin |
| | | { |
| | | [SerializeField] Transform WarlordPavilionWinTop; |
| | | protected override void OpenSubUIByTabIndex() |
| | | protected override async void OpenSubUIByTabIndex() |
| | | { |
| | | WarlordPavilionWinTop.SetActive(functionOrder == 0); |
| | | switch (functionOrder) |
| | | { |
| | | case 0: |
| | | UIManager.Instance.OpenWindowAsync<WarlordPavilionWin>().ContinueWith(w => currentSubUI = w).Forget(); |
| | | currentSubUI = await UIManager.Instance.OpenWindowAsync<WarlordPavilionWin>(); |
| | | break; |
| | | default: |
| | | Debug.LogWarning("未知的标签索引: " + functionOrder); |
| | |
| | | return; |
| | | } |
| | | |
| | | cellContainer = await UIUtility.CreateWidget("GiftBaseCell", "Container_GiftCell"); |
| | | var inst = await UIUtility.CreateWidget("GiftBaseCell", "Container_GiftCell"); |
| | | |
| | | if (this == null) |
| | | { |
| | | if (null != cellContainer) DestroyImmediate(cellContainer); |
| | | if (null != inst) DestroyImmediate(inst); |
| | | return; |
| | | } |
| | | |
| | | if (cellContainer != null) |
| | | { |
| | | DestroyImmediate(inst); |
| | | return; |
| | | } |
| | | cellContainer = inst; |
| | | |
| | | if (cellContainer != null) |
| | | { |
| | | cellContainer.transform.SetParentEx(this.transform, Vector3.zero, Quaternion.identity, Vector3.one); |
| | | cellContainer.transform.SetAsFirstSibling(); |
| | | } |
| | |
| | | return; |
| | | } |
| | | |
| | | cellContainer = await UIUtility.CreateWidget("GiftBaseCell", "Container_GiftCell"); |
| | | var inst = await UIUtility.CreateWidget("GiftBaseCell", "Container_GiftCell"); |
| | | |
| | | if (this == null) |
| | | { |
| | | if (null != cellContainer) DestroyImmediate(cellContainer); |
| | | if (null != inst) DestroyImmediate(inst); |
| | | return; |
| | | } |
| | | |
| | | if (cellContainer != null) |
| | | { |
| | | DestroyImmediate(inst); |
| | | return; |
| | | } |
| | | cellContainer = inst; |
| | | |
| | | if (cellContainer != null) |
| | | { |
| | | cellContainer.transform.SetParentEx(this.transform, Vector3.zero, Quaternion.identity, Vector3.one); |
| | | cellContainer.transform.SetAsFirstSibling(); |
| | | } |
| | |
| | | using System.Net.Sockets; |
| | | using System.IO; |
| | | using System.Text.RegularExpressions; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | #if UNITY_IOS |
| | | using UnityEngine.iOS; |
| | |
| | | |
| | | static string ipPattern = "[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}"; |
| | | static string ip = string.Empty; |
| | | public static string GetIp() |
| | | public static async UniTask<string> GetIp() |
| | | { |
| | | try |
| | | { |
| | |
| | | WebRequest wRequest = WebRequest.Create(url); |
| | | wRequest.Method = "GET"; |
| | | wRequest.ContentType = "text/html;charset=UTF-8"; |
| | | WebResponse wResponse = wRequest.GetResponse(); |
| | | WebResponse wResponse = await wRequest.GetResponseAsync(); |
| | | Stream stream = wResponse.GetResponseStream(); |
| | | StreamReader reader = new StreamReader(stream, System.Text.Encoding.Default); |
| | | string str = reader.ReadToEnd(); |
| | | string str = await reader.ReadToEndAsync(); |
| | | |
| | | reader.Close(); |
| | | wResponse.Close(); |
| | |
| | | ip = match.Value; |
| | | } |
| | | } |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Debug.Log(ex); |
| | | } |
| | | |
| | | return ip; |
| | | } |
| | | |
| | |
| | | using UnityEngine;
|
| | | using Cysharp.Threading.Tasks; |
| | |
|
| | | public class GMCommand : SingletonMonobehaviour<GMCommand>
|
| | | {
|
| | |
| | | using UnityEngine;
|
| | | using System;
|
| | | using LitJson;
|
| | | using Cysharp.Threading.Tasks;
|
| | |
|
| | |
|
| | | public class OperationLogCollect : Singleton<OperationLogCollect>
|
| | |
| | | // {
|
| | | // return;
|
| | | // #if !UNITY_EDITOR
|
| | | // if (VersionConfig.Get().versionAuthority == VersionAuthority.Release)
|
| | | // if (config.versionAuthority == VersionAuthority.Release)
|
| | | // {
|
| | | // var tables = new Dictionary<string, string>();
|
| | | // tables["OperatorID"] = VersionConfig.Get().appId;
|
| | | // tables["OperatorID"] = config.appId;
|
| | | // tables["RegionName"] = "data";
|
| | | // tables["EventID"] = 9001.ToString();
|
| | | // tables["ProductID"] = VersionConfig.Get().gameId;
|
| | | // tables["ProductID"] = config.gameId;
|
| | | // tables["Device"] = SystemInfo.deviceName;
|
| | | // tables["DeviceFlag"] = ynmbxxjUtil.Instance.Device.uniqueID;
|
| | | // tables["IP"] = DeviceUtility.GetIp();
|
| | |
| | | // {
|
| | | // return;
|
| | | // #if !UNITY_EDITOR
|
| | | // if (VersionConfig.Get().versionAuthority == VersionAuthority.Release)
|
| | | // if (config.versionAuthority == VersionAuthority.Release)
|
| | | // {
|
| | | // var tables = new Dictionary<string, string>();
|
| | | // tables["OperatorID"] = VersionConfig.Get().appId;
|
| | | // tables["OperatorID"] = config.appId;
|
| | | // tables["RegionName"] = "data";
|
| | | // tables["AccountID"] = ynmbxxjUtil.Instance.FreePlatformInfo == null ? "" : ynmbxxjUtil.Instance.FreePlatformInfo.account;
|
| | | // tables["EventID"] = 9001.ToString();
|
| | | // tables["ProductID"] = VersionConfig.Get().gameId;
|
| | | // tables["ProductID"] = config.gameId;
|
| | | // tables["Device"] = SystemInfo.deviceName;
|
| | | // tables["IP"] = DeviceUtility.GetIp();
|
| | | // tables["DeviceFlag"] = ynmbxxjUtil.Instance.Device.uniqueID;
|
| | | // tables["Flag"] = VersionConfig.Get().clientPackageFlag;
|
| | | // tables["Flag"] = config.clientPackageFlag;
|
| | | // tables["Time"] = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
| | | // tables["Step"] = _step.ToString();
|
| | |
|
| | |
| | | // {
|
| | | // return;
|
| | | // #if !UNITY_EDITOR
|
| | | // if (VersionConfig.Get().versionAuthority != VersionAuthority.Release)
|
| | | // if (config.versionAuthority != VersionAuthority.Release)
|
| | | // {
|
| | | // return;
|
| | | // }
|
| | |
| | | // if (!recordedDeviceDetail)
|
| | | // {
|
| | | // var tables = new Dictionary<string, string>();
|
| | | // tables["OperatorID"] = VersionConfig.Get().appId;
|
| | | // tables["OperatorID"] = config.appId;
|
| | | // tables["RegionName"] = StringUtility.Concat("s" + ServerListCenter.Instance.currentServer.region_flag);
|
| | | // tables["EventID"] = 1102.ToString();
|
| | | // tables["ProductID"] = VersionConfig.Get().gameId;
|
| | | // tables["ProductID"] = config.gameId;
|
| | | // tables["Time"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
| | | // tables["IP"] = DeviceUtility.GetIp();
|
| | | // tables["AccountID"] = ModelCenter.Instance.GetModel<LoginModel>().sdkLoginResult.account;
|
| | |
| | | // var runtime = new Dictionary<string, string>();
|
| | | // runtime["os_version"] = DeviceUtility.GetDeviceOSLevel();
|
| | | // tables["Runtime"] = JsonMapper.ToJson(runtime);
|
| | | // tables["Version"] = StringUtility.Concat(VersionConfig.Get().version, "_", VersionConfig.Get().buildIndex);
|
| | | // tables["Version"] = StringUtility.Concat(config.version, "_", config.buildIndex);
|
| | |
|
| | | // HttpRequest.Instance.RequestHttpGet(StringUtility.Concat(url, HttpRequest.HashtablaToString(tables)), HttpRequest.defaultHttpContentType);
|
| | | // }
|
| | |
| | | // }
|
| | |
|
| | |
|
| | | const string bugReportUrl = "http://xssgcenter.secondworld.net.cn:11000/center/eventreport.php?";
|
| | | const string bugReportUrl = "http://gamecenter.secondworld.net.cn:11000/center/eventreport.php?";
|
| | |
|
| | | public void BugReport(string _title, string _content)
|
| | | {
|
| | | var tables = new Dictionary<string, string>();
|
| | | tables["OperatorID"] = VersionConfig.Get().appId;
|
| | | tables["RegionName"] = "data";
|
| | | tables["RegionID"] = ServerListCenter.Instance.currentServer.region_flag.ToString();
|
| | | tables["EventID"] = 9002.ToString();
|
| | | tables["ProductID"] = VersionConfig.Get().gameId;
|
| | | tables["Time"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
| | | tables["IP"] = DeviceUtility.GetIp();
|
| | | tables["AccountID"] = LoginManager.Instance.sdkLoginResult.account;
|
| | | tables["Level"] = PlayerDatas.Instance.baseData.LV.ToString();
|
| | | tables["RoleID"] = PlayerDatas.Instance.baseData.PlayerName;
|
| | | tables["VIPLevel"] = PlayerDatas.Instance.baseData.VIPLv.ToString();
|
| | | tables["DeviceFlag"] = SDKUtils.Instance.Device.uniqueID;
|
| | |
|
| | | var contentPrefix = StringUtility.Concat("IMEI:", DeviceUtility.GetDeviceUniquenessIdentify(), ";");
|
| | | contentPrefix = StringUtility.Concat(contentPrefix, "Version:", StringUtility.Concat(VersionConfig.Get().version, "_", |
| | | VersionConfig.Get().buildIndex.ToString(), "-", LoginManager.Instance.hotVersion), Language.Id, ";");
|
| | | contentPrefix = StringUtility.Concat(contentPrefix, "Brand:", DeviceUtility.GetDeviceName(), ";");
|
| | | contentPrefix = StringUtility.Concat(contentPrefix, "MI5:", DeviceUtility.GetDeviceModel(), ";");
|
| | | contentPrefix = StringUtility.Concat(contentPrefix, "os_version:", DeviceUtility.GetDeviceOSLevel(), ";");
|
| | | var config = VersionConfig.config;
|
| | | DeviceUtility.GetIp().ContinueWith(ip =>
|
| | | {
|
| | | var gameId = config.gameId;
|
| | |
|
| | | tables["Title"] = _title;
|
| | | tables["Content"] = _content;
|
| | | tables["ClientInfo"] = contentPrefix;
|
| | | var tables = new Dictionary<string, string>();
|
| | | tables["OperatorID"] = config.appId;
|
| | | tables["RegionName"] = "data";
|
| | | tables["RegionID"] = ServerListCenter.Instance.currentServer.region_flag.ToString();
|
| | | tables["EventID"] = 9002.ToString();
|
| | | tables["ProductID"] = config.gameId;
|
| | | tables["Time"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
| | | tables["IP"] = ip;
|
| | | tables["AccountID"] = LoginManager.Instance.sdkLoginResult.account;
|
| | | tables["Level"] = PlayerDatas.Instance.baseData.LV.ToString();
|
| | | tables["RoleID"] = PlayerDatas.Instance.baseData.PlayerName;
|
| | | tables["VIPLevel"] = PlayerDatas.Instance.baseData.VIPLv.ToString();
|
| | | tables["DeviceFlag"] = SDKUtils.Instance.Device.uniqueID;
|
| | |
|
| | | HttpRequest.Instance.RequestHttpGet(StringUtility.Concat(bugReportUrl, HttpRequest.HashtablaToString(tables)), HttpRequest.defaultHttpContentType);
|
| | | var contentPrefix = StringUtility.Concat("IMEI:", DeviceUtility.GetDeviceUniquenessIdentify(), ";");
|
| | | contentPrefix = StringUtility.Concat(contentPrefix, "Version:", StringUtility.Concat(config.version, "_", |
| | | config.buildIndex.ToString(), "-", LoginManager.Instance.hotVersion), Language.Id, ";");
|
| | | contentPrefix = StringUtility.Concat(contentPrefix, "Brand:", DeviceUtility.GetDeviceName(), ";");
|
| | | contentPrefix = StringUtility.Concat(contentPrefix, "MI5:", DeviceUtility.GetDeviceModel(), ";");
|
| | | contentPrefix = StringUtility.Concat(contentPrefix, "os_version:", DeviceUtility.GetDeviceOSLevel(), ";");
|
| | |
|
| | | tables["Title"] = _title;
|
| | | tables["Content"] = _content;
|
| | | tables["ClientInfo"] = contentPrefix;
|
| | |
|
| | | HttpRequest.Instance.RequestHttpGet(StringUtility.Concat(bugReportUrl, HttpRequest.HashtablaToString(tables)), HttpRequest.defaultHttpContentType);
|
| | |
|
| | | }).Forget();
|
| | |
|
| | |
|
| | | }
|
| | |
|
| | |
| | | #if !UNITY_EDITOR
|
| | | try
|
| | | {
|
| | | var tables = new Dictionary<string, string>();
|
| | | tables["OperatorID"] = VersionConfig.Get().appId;
|
| | | tables["RegionName"] = "data";
|
| | | tables["RegionID"] = "10000";
|
| | | tables["EventID"] = 9002.ToString();
|
| | | tables["ProductID"] = VersionConfig.Get().gameId;
|
| | | tables["Time"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
| | | tables["IP"] = DeviceUtility.GetIp();
|
| | | tables["AccountID"] = "system";
|
| | | tables["Level"] = "1";
|
| | | tables["RoleID"] = "system";
|
| | | tables["VIPLevel"] = "1";
|
| | | tables["DeviceFlag"] = SDKUtils.Instance.Device.uniqueID;
|
| | |
|
| | | var contentPrefix = StringUtility.Concat("IMEI:", DeviceUtility.GetDeviceUniquenessIdentify(), ";");
|
| | | contentPrefix = StringUtility.Concat(contentPrefix, "Version:", StringUtility.Concat(VersionConfig.Get().version, "_",
|
| | | VersionConfig.Get().buildIndex.ToString(), "-", LoginManager.Instance.hotVersion), Language.Id, ";");
|
| | | contentPrefix = StringUtility.Concat(contentPrefix, "Brand:", DeviceUtility.GetDeviceName(), ";");
|
| | | contentPrefix = StringUtility.Concat(contentPrefix, "MI5:", DeviceUtility.GetDeviceModel(), ";");
|
| | | contentPrefix = StringUtility.Concat(contentPrefix, "os_version:", DeviceUtility.GetDeviceOSLevel(), ";");
|
| | |
|
| | | tables["Title"] = "system";
|
| | | _content = _content.Replace("0000", "");
|
| | | if (ConfigManager.Instance.isLoadFinished && DTC0102_tagCDBPlayer.playerIdBuf != 0 && LoginManager.Instance.sdkLoginResult != null && !string.IsNullOrEmpty(LoginManager.Instance.sdkLoginResult.account))
|
| | | DeviceUtility.GetIp().ContinueWith(ip =>
|
| | | {
|
| | | _content = StringUtility.Concat(LoginManager.Instance.sdkLoginResult.account, "@", ServerListCenter.Instance.currentServer.region_flag.ToString(), " ", _content);
|
| | | }
|
| | | |
| | | tables["Content"] = _content.Substring(0, Math.Min(800, _content.Length));
|
| | | tables["ClientInfo"] = contentPrefix;
|
| | | var config = VersionConfig.config;
|
| | | var tables = new Dictionary<string, string>();
|
| | | tables["OperatorID"] = config.appId;
|
| | | tables["RegionName"] = "data";
|
| | | tables["RegionID"] = "10000";
|
| | | tables["EventID"] = 9002.ToString();
|
| | | tables["ProductID"] = config.gameId;
|
| | | tables["Time"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
| | | tables["IP"] = ip;
|
| | | tables["AccountID"] = "system";
|
| | | tables["Level"] = "1";
|
| | | tables["RoleID"] = "system";
|
| | | tables["VIPLevel"] = "1";
|
| | | tables["DeviceFlag"] = SDKUtils.Instance.Device.uniqueID;
|
| | |
|
| | | HttpRequest.Instance.RequestHttpGet(StringUtility.Concat(bugReportUrl, HttpRequest.HashtablaToString(tables)), HttpRequest.defaultHttpContentType);
|
| | | var contentPrefix = StringUtility.Concat("IMEI:", DeviceUtility.GetDeviceUniquenessIdentify(), ";");
|
| | | contentPrefix = StringUtility.Concat(contentPrefix, "Version:", StringUtility.Concat(config.version, "_",
|
| | | config.buildIndex.ToString(), "-", LoginManager.Instance.hotVersion), Language.Id, ";");
|
| | | contentPrefix = StringUtility.Concat(contentPrefix, "Brand:", DeviceUtility.GetDeviceName(), ";");
|
| | | contentPrefix = StringUtility.Concat(contentPrefix, "MI5:", DeviceUtility.GetDeviceModel(), ";");
|
| | | contentPrefix = StringUtility.Concat(contentPrefix, "os_version:", DeviceUtility.GetDeviceOSLevel(), ";");
|
| | |
|
| | | tables["Title"] = "system";
|
| | | _content = _content.Replace("0000", "");
|
| | | if (ConfigManager.Instance.isLoadFinished && DTC0102_tagCDBPlayer.playerIdBuf != 0 && LoginManager.Instance.sdkLoginResult != null && !string.IsNullOrEmpty(LoginManager.Instance.sdkLoginResult.account))
|
| | | {
|
| | | _content = StringUtility.Concat(LoginManager.Instance.sdkLoginResult.account, "@", ServerListCenter.Instance.currentServer.region_flag.ToString(), " ", _content);
|
| | | }
|
| | | |
| | | tables["Content"] = _content.Substring(0, Math.Min(800, _content.Length));
|
| | | tables["ClientInfo"] = contentPrefix;
|
| | |
|
| | | HttpRequest.Instance.RequestHttpGet(StringUtility.Concat(bugReportUrl, HttpRequest.HashtablaToString(tables)), HttpRequest.defaultHttpContentType);
|
| | | }).Forget();
|
| | |
|
| | | }
|
| | | catch (System.Exception ex)
|
| | | {
|
| | |
| | | }
|
| | |
|
| | |
|
| | | const string chatReportUrl = "http://xssgcenter.secondworld.net.cn:11000/center/eventreport.php?";
|
| | | public void ChatReport(string content, string channelName, string toPlayer, int chatType)
|
| | | const string chatReportUrl = "http://gamecenter.secondworld.net.cn:11000/center/eventreport.php?";
|
| | | public async void ChatReport(string content, string channelName, string toPlayer, int chatType)
|
| | | {
|
| | | #if !UNITY_EDITOR
|
| | | bool isFairy = chatType == 3;
|
| | | var tables = new Dictionary<string, string>();
|
| | | tables["ProductID"] = VersionConfig.Get().gameId;
|
| | | tables["OperatorID"] = VersionConfig.Get().appId;
|
| | | var config = VersionConfig.config;
|
| | | tables["ProductID"] = config.gameId;
|
| | | tables["OperatorID"] = config.appId;
|
| | | tables["OperatorName"] = string.Empty;
|
| | | tables["RegionName"] = StringUtility.Concat("s", ServerListCenter.Instance.currentServer.region_flag.ToString());
|
| | | tables["RegionID"] = ServerListCenter.Instance.currentServer.region_flag.ToString();
|
| | | tables["EventID"] = 9003.ToString();
|
| | | tables["Time"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
| | | tables["IP"] = DeviceUtility.GetIp();
|
| | | tables["IP"] = await DeviceUtility.GetIp();
|
| | | tables["ChatChannel"] = channelName;
|
| | | var sdkLoginResult = LoginManager.Instance.sdkLoginResult;
|
| | | tables["AccountID"] = sdkLoginResult == null ? LoginManager.Instance.accountBuf : sdkLoginResult.account;
|
| | |
| | | public static void WarmUpAll() |
| | | { |
| | | // US2: Sync AB loading removed. Use WarmUpAllAsync instead. |
| | | #if !UNITY_EDITOR |
| | | Shader.WarmupAllShaders(); |
| | | #endif |
| | | } |
| | | |
| | | /// <summary> |
| | | /// US2: Async shader warm up via YooAsset. Temporary API — will be replaced by preload+cache in T044. |
| | | /// US2: Async shader warm up via YooAsset. |
| | | /// PackDirectory 规则下所有 shader 在同一个 bundle, |
| | | /// 通过 tag="shader" 拿到任意一个有效地址传给 LoadAllAssetsAsync 即可加载整包。 |
| | | /// 前提:Collector 的 Asset Tags 填写 "shader" 并重新打 AB。 |
| | | /// </summary> |
| | | public static async UniTask WarmUpAllAsync() |
| | | { |
| | | if (AssetSource.isUseAssetBundle) |
| | | { |
| | | await YooAssetService.Instance.LoadAllAssetsAsync<Shader>("Assets/ResourcesOut/Shader"); |
| | | // 通过 tag 找到 shader bundle 内任意一个有效地址 |
| | | var infos = YooAssetService.Instance.GetAssetInfosByTag("shader"); |
| | | if (infos != null && infos.Length > 0) |
| | | { |
| | | // PackDirectory:所有 shader 在同一 bundle,传任意地址即可加载整包 |
| | | await YooAssetService.Instance.LoadAllAssetsAsync<Shader>(infos[0].Address); |
| | | } |
| | | else |
| | | { |
| | | Debug.LogWarning("[ShaderUtility] No asset infos found for tag 'shader'. " + |
| | | "Please set Asset Tags = 'shader' on the Shader collector in YooAsset and rebuild AB."); |
| | | } |
| | | } |
| | | #if !UNITY_EDITOR |
| | | Shader.WarmupAllShaders(); |
| | | #endif |
| | | } |
| | | |
| | | |
| | |
| | | return content; |
| | | } |
| | | |
| | | //复制到剪贴板 |
| | | // TODO 暂不支持web后续补充 |
| | | |
| | | |
| | | public static void CopyToClipboard(string text) |
| | | { |
| | | #if UNITY_WEBGL && !UNITY_EDITOR |
| | | LaunchUtility.UIHelper_CopyToClipboard(text); |
| | | #else |
| | | GUIUtility.systemCopyBuffer = text; |
| | | #endif |
| | | Debug.Log("文字已复制到剪贴板: " + text); |
| | | } |
| | | |