yyl
2025-05-19 284d53f23b058c650749f03f0079a76dce7f4347
18 子 2D卡牌客户端搭建 / 2D卡牌客户端搭建
2个文件已修改
2个文件已添加
150 ■■■■■ 已修改文件
Main/Login/ClientVersion/VersionUtility.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/Manager/ResManager.cs 134 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/Manager/ResManager.cs.meta 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/Manager/StageManager.cs 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/Login/ClientVersion/VersionUtility.cs
@@ -71,7 +71,7 @@
        //versionUrl = url;
        //Debug.Log("http地址:versionUrl  " + url);
        //HttpRequest.Instance.RequestHttpGet(url, HttpRequest.defaultHttpContentType, 1, OnVersionCheckResult);
        OnVersionCheckResult(true, ResManager.versionUrlResult);
        OnVersionCheckResult(true, LocalResManager.versionUrlResult);
    }
    private void OnVersionCheckResult(bool _ok, string _result)
Main/Manager/ResManager.cs
New file
@@ -0,0 +1,134 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using Cysharp.Threading.Tasks;
using System;
using UnityEngine.U2D;
using LitJson;
using System.IO;
using UnityEngine.Networking;
#if UNITY_EDITOR
using UnityEditor;
#endif
using LaunchCommon;
public class ResManager : Singleton<ResManager>
{
    //不下载时本地安卓测试路径
    // public string assetBundlesPath = Application.dataPath + "/../AssetBundles/Android/";
    // public static string bytesFolderName = "logicbytes/";
    public string StreamingAssetPath
    {
        get
        {
            return ResourcesPath.Instance.StreamingAssetPath;
        }
    }
    public string ExternalStorePath
    {
        get
        {
            return ResourcesPath.Instance.ExternalStorePath;
        }
    }
    //用于editor 下的资源路径
    public string ResourcesOutPath
    {
        get
        {
            return ResourcesPath.ResourcesOutPath;
        }
    }
    public string CONFIG_FODLER
    {
        get
        {
            return ResourcesPath.CONFIG_FODLER;
        }
    }
    public string ResourcesOutAssetPath
    {
        get
        {
            return ResourcesPath.ResourcesOutAssetPath;
        }
    }
    public void Init()
    {
    }
    public void Release()
    {
    }
    private string GetExtension(Type type)
    {
        if (type == typeof(GameObject))
            return ".prefab";
        else if (type == typeof(Sprite))
            return ".png";
        else if (type == typeof(Texture2D))
            return ".png";
        else if (type == typeof(Shader))
            return ".shader";
        else if (type == typeof(TextAsset))
            return ".txt";
        else if (type == typeof(AudioClip))
            return ".wav";
        else if (type == typeof(Font))
            return ".ttf";
        else if (type == typeof(Material))
            return ".mat";
        else
        {
            Debug.LogErrorFormat("GetExtension() => 不支持的资源类型: {0}.", type.Name);
            return "";
        }
    }
    public T LoadAsset<T> (string directory, string name) where T : UnityEngine.Object
    {
        T asset = null;
#if UNITY_EDITOR
        var path = string.Concat($"Assets/ResourcesOut/{directory}/{name}", GetExtension(typeof(T)));
        asset = UnityEditor.AssetDatabase.LoadAssetAtPath<T>(path);
#else
        if (prefabBundle == null)
        {
            // string _path = GetAssetFilePath("builtin/prefabs");
            string _path = GetAssetFilePath($"builtin/{directory}");
            prefabBundle = AssetBundle.LoadFromFile(_path);
        }
        asset = prefabBundle.LoadAsset(name) as t;
#endif
        if (asset == null)
        {
            Debug.LogErrorFormat("LoadBuiltInPrefab() => 加载不到资源: {0}.", name);
        }
        return asset;
    }
    public void UnloadAsset(string assetBundleName)
    {
    }
}
Main/Manager/ResManager.cs.meta
New file
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: bc3c737470ea4ee43956edd5249aa939
MonoImporter:
  externalObjects: {}
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData:
  assetBundleName:
  assetBundleVariant:
Main/Manager/StageManager.cs
@@ -26,7 +26,8 @@
    public void Release()
    {
        AfterEnterGame = null;
        BeforeEnterGame = null;
    }
    public async UniTaskVoid ToLoginScene()