18 子 2D卡牌客户端搭建 / 2D卡牌客户端搭建 去掉AssetSource下的resFromEditor 添加了IsUseAssetBundle UIBase添加了防呆的InitComponentIneteral
11个文件已修改
85 ■■■■■ 已修改文件
Main/Core/GameEngine/Launch/AssetBundleInitTask.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/Core/GameEngine/Launch/BuiltInAssetCopyTask.cs 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/Core/SFX/SFXPlayUtility.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/Manager/UIManager.cs 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/ResModule/BuiltInLoader.cs 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/ResModule/ResManager.cs 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Debug/DebugAsset.cs 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Sound/SoundPlayer.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Tip/PopConfirmWin.cs 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/UIBase/UIBase.cs 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/Utility/ShaderUtility.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/Core/GameEngine/Launch/AssetBundleInitTask.cs
@@ -15,7 +15,7 @@
        LaunchInHot.m_CurrentStage = LaunchStage.AssetBundleInit;
        duration = Mathf.Max(0.5f, expectTime);
        if (!AssetSource.allFromEditor)
        if (AssetSource.isUseAssetBundle)
        {
            AssetBundleUtility.Instance.Initialize();
            done = false;
Main/Core/GameEngine/Launch/BuiltInAssetCopyTask.cs
@@ -50,7 +50,7 @@
    public override void End()
    {
        if (!AssetSource.builtInFromEditor)
        if (AssetSource.isUseAssetBundle)
        {
            AssetBundleUtility.Instance.InitBuiltInAsset();
        }
@@ -248,10 +248,10 @@
    private void EditorCopyAsset()
    {
        if (!AssetSource.allFromEditor)
        if (AssetSource.isUseAssetBundle)
        {
            // FileExtersion.DirectoryCopy(ResourcesPath.CONFIG_FODLER, ResourcesPath.Instance.StreamingAssetPath + "config");
            // FileExtersion.DirectoryCopy(ResourcesPath.ResourcesOutPath + "BuiltIn", ResourcesPath.Instance.StreamingAssetPath + "builtin");
            FileExtersion.DirectoryCopy(ResourcesPath.CONFIG_FODLER, ResourcesPath.Instance.StreamingAssetPath + "config");
            FileExtersion.DirectoryCopy(ResourcesPath.ResourcesOutPath + "BuiltIn", ResourcesPath.Instance.StreamingAssetPath + "builtin");
        }
    }
Main/Core/SFX/SFXPlayUtility.cs
@@ -14,7 +14,7 @@
    {
        var config = EffectConfig.Get(id);
        var bundleName = StringUtility.Contact(ResourcesPath.EFFECT_Folder_Name, config.packageName);
        if (AssetSource.effectFromEditor || AssetBundleUtility.Instance.JudgeExistAsset(bundleName, config.fxName))
        if (!AssetSource.isUseAssetBundle || AssetBundleUtility.Instance.JudgeExistAsset(bundleName, config.fxName))
        {
            return PlayBattleEffect(id, parent, scale);
        }
@@ -59,7 +59,7 @@
    {
        var config = EffectConfig.Get(id);
        var bundleName = StringUtility.Contact(ResourcesPath.EFFECT_Folder_Name, config.packageName);
        if (AssetSource.effectFromEditor || AssetBundleUtility.Instance.JudgeExistAsset(bundleName, config.fxName))
        if (!AssetSource.isUseAssetBundle || AssetBundleUtility.Instance.JudgeExistAsset(bundleName, config.fxName))
        {
            return PlayBattleEffect(id, position, forward, scale);
        }
Main/Manager/UIManager.cs
@@ -543,6 +543,8 @@
            ui.SetSortingOrder(sortingOrder);
            // 更新当前最高排序顺序
            currentHighestSortingOrder += 10;
            // Debug.Log(ui.uiName + " order is " + sortingOrder + " " + currentHighestSortingOrder);
        }
    }
    
Main/ResModule/BuiltInLoader.cs
@@ -14,7 +14,7 @@
    public static Sprite LoadSprite(string name)
    {
        Sprite sprite = null;
        if (AssetSource.builtInFromEditor)
        if (!AssetSource.isUseAssetBundle)
        {
#if UNITY_EDITOR
            if (excludePngs.Contains(StringUtility.Contact(name, SPRITE_EXTENSION)))
@@ -52,7 +52,7 @@
    public static GameObject LoadPrefab(string name)
    {
        GameObject prefab = null;
        if (AssetSource.builtInFromEditor)
        if (!AssetSource.isUseAssetBundle)
        {
#if UNITY_EDITOR
            var path = StringUtility.Contact("Assets/ResourcesOut/BuiltIn/Prefabs/", name, PREFAB_EXTENSION);
@@ -75,7 +75,7 @@
    public static void UnLoadPrefab(string name)
    {
        if (!AssetSource.builtInFromEditor)
        if (AssetSource.isUseAssetBundle)
        {
            AssetBundleUtility.Instance.UnloadAsset("builtin/prefabs", name);
        }
@@ -84,7 +84,7 @@
    public static AudioClip LoadMusic(string name)
    {
        AudioClip audioClip = null;
        if (AssetSource.builtInFromEditor)
        if (!AssetSource.isUseAssetBundle)
        {
#if UNITY_EDITOR
            var path = StringUtility.Contact("Assets/ResourcesOut/BuiltIn/Musics/", name, AUDIO_EXTENSION);
@@ -108,7 +108,7 @@
    public static AnimationClip LoadAnimationClip(string name)
    {
        AnimationClip clip = null;
        if (AssetSource.builtInFromEditor)
        if (!AssetSource.isUseAssetBundle)
        {
#if UNITY_EDITOR
            var path = StringUtility.Contact("Assets/ResourcesOut/BuiltIn/AnimationClips/", name, ".anim");
@@ -132,7 +132,7 @@
    public static Material LoadMaterial(string name)
    {
        Material material = null;
        if (AssetSource.builtInFromEditor)
        if (!AssetSource.isUseAssetBundle)
        {
#if UNITY_EDITOR
            var path = StringUtility.Contact("Assets/ResourcesOut/BuiltIn/Materials/", name, ".mat");
@@ -157,7 +157,7 @@
    {
        T config = null;
        if (AssetSource.builtInFromEditor)
        if (!AssetSource.isUseAssetBundle)
        {
#if UNITY_EDITOR
            var resourcePath = StringUtility.Contact(ResourcesPath.ResourcesOutAssetPath,
@@ -183,7 +183,7 @@
    public static Font LoadFont(string fontName)
    {
        Font font = null;
        if (AssetSource.builtInFromEditor)
        if (!AssetSource.isUseAssetBundle)
        {
#if UNITY_EDITOR
            var path = StringUtility.Contact(ResourcesPath.ResourcesOutAssetPath,
Main/ResModule/ResManager.cs
@@ -142,7 +142,7 @@
        T asset = null;
        var path = ($"Assets/ResourcesOut/{directory}/{name}" + GetExtension(typeof(T))).Replace("//", "/").Trim().Replace("\\", "/");
        if (AssetSource.uiFromEditor)
        if (!AssetSource.isUseAssetBundle)
        {
#if UNITY_EDITOR
            //  TODO YYL 还是要找到字符串问题
@@ -209,7 +209,7 @@
    {
        var path = string.Concat($"Assets/ResourcesOut/{directory}/{name}", GetExtension(typeof(T))).Replace("//", "/");
        if (AssetSource.uiFromEditor)
        if (!AssetSource.isUseAssetBundle)
        {
#if UNITY_EDITOR
            var asset = UnityEditor.AssetDatabase.LoadAssetAtPath<T>(path);
@@ -225,7 +225,7 @@
    public void UnloadAsset(string assetBundleName, string assetName)
    {
        if (AssetSource.uiFromEditor)
        if (!AssetSource.isUseAssetBundle)
            return;
        AssetBundleUtility.Instance.UnloadAsset(assetBundleName, assetName);
@@ -233,7 +233,7 @@
    public void UnloadAssetBundle(string assetBundleName, bool unloadAllLoadedObjects, bool includeDependenice)
    {
        if (AssetSource.uiFromEditor)
        if (!AssetSource.isUseAssetBundle)
            return;
        AssetBundleUtility.Instance.UnloadAssetBundle(assetBundleName, unloadAllLoadedObjects, includeDependenice);
    }
Main/System/Debug/DebugAsset.cs
@@ -17,16 +17,6 @@
    private void OnEnable()
    {
        m_AllAsset.isOn = AssetSource.allFromEditor;
        m_Audio.isOn = AssetSource.audioFromEditor;
        m_Effect.isOn = AssetSource.effectFromEditor;
        m_Scene.isOn = AssetSource.sceneFromEditor;
        m_Mob.isOn = AssetSource.mobFromEditor;
        m_Refdata.isOn = AssetSource.refdataFromEditor;
        m_Shader.isOn = AssetSource.shaderFromEditor;
        m_UI.isOn = AssetSource.uiFromEditor;
        m_BuiltIn.isOn = AssetSource.builtInFromEditor;
        m_AllAsset.AddListener(OnAllAssetValueChange);
        m_Audio.AddListener(OnAudioValueChange);
        m_Effect.AddListener(OnEffectValueChange);
@@ -52,7 +42,6 @@
    private void OnAllAssetValueChange(bool _value)
    {
        AssetSource.allFromEditor = _value;
        m_Audio.isOn = _value;
        m_Effect.isOn = _value;
@@ -65,42 +54,34 @@
    private void OnAudioValueChange(bool _value)
    {
        AssetSource.audioFromEditor = _value;
    }
    private void OnEffectValueChange(bool _value)
    {
        AssetSource.effectFromEditor = _value;
    }
    private void OnSceneValueChange(bool _value)
    {
        AssetSource.sceneFromEditor = _value;
    }
    private void OnMobValueChange(bool _value)
    {
        AssetSource.mobFromEditor = _value;
    }
    private void OnRefdataValueChange(bool _value)
    {
        AssetSource.refdataFromEditor = _value;
    }
    private void OnShaderValueChange(bool _value)
    {
        AssetSource.shaderFromEditor = _value;
    }
    private void OnUIValueChange(bool _value)
    {
        AssetSource.uiFromEditor = _value;
    }
    private void OnBuildInValueChange(bool _value)
    {
        AssetSource.builtInFromEditor = _value;
    }
}
Main/System/Sound/SoundPlayer.cs
@@ -125,7 +125,7 @@
    public void UnLoadMusic(int _exclude)
    {
        if (!AssetSource.audioFromEditor && DeviceUtility.IsLowMemory())
        if (AssetSource.isUseAssetBundle && DeviceUtility.IsLowMemory())
        {
            foreach (var key in musicAudioClipDict.Keys)
            {
Main/System/Tip/PopConfirmWin.cs
@@ -18,6 +18,7 @@
    [SerializeField] Button closeBtn;
    protected override void InitComponent()
    {
        base.InitComponent();
        popConfirmBtn.onClick.AddListener(OnPopConfirmOkBtn);
        popCancelBtn.onClick.AddListener(OnPopConfirmCancelBtn);
        closeBtn.onClick.AddListener(OnPopConfirmCancelExBtn);
@@ -25,6 +26,7 @@
    protected override void OnPreOpen()
    {
        base.OnPreOpen();
        popCancelBtn.SetActive(!ConfirmCancel.IsSingleConfirm);
        popConfirmTitle.text = ConfirmCancel.popConfirmTitle;
@@ -42,14 +44,17 @@
    protected override void OnOpen()
    {
        base.OnOpen();
    }
    protected override void OnPreClose()
    {
        base.OnPreClose();
    }
    protected override void OnClose()
    {
        base.OnClose();
    }
Main/System/UIBase/UIBase.cs
@@ -95,6 +95,8 @@
        // 确保 DOTween 已初始化
        DOTween.SetTweensCapacity(500, 50);
        //  防止有人不写base.InitComponent引发错误 所以拆分
        InitComponentInternal();
        // 在Awake中进行基本初始化
        InitComponent();
@@ -158,8 +160,7 @@
    #region 初始化方法
    // 获取必要的组件
    protected virtual void InitComponent()
    private void InitComponentInternal()
    {
        // 获取或添加Canvas组件
        canvas = GetComponent<Canvas>();
@@ -190,6 +191,11 @@
        rectTransform = GetComponent<RectTransform>();
    }
    // 获取必要的组件
    protected virtual void InitComponent()
    {
    }
    #endregion
    #region UI操作方法
@@ -197,10 +203,7 @@
    // 设置UI层级
    public void SetSortingOrder(int order)
    {
        if (canvas != null)
        {
            canvas.sortingOrder = order;
        }
        canvas.sortingOrder = order;
    }
    protected virtual void OnPreOpen()
Main/Utility/ShaderUtility.cs
@@ -17,9 +17,9 @@
    public static void WarmUpAll()
    {
        if (!AssetSource.shaderFromEditor)
        if (AssetSource.isUseAssetBundle)
        {
            AssetBundleUtility.Instance.Sync_LoadAllAssets("graphic/shader");
            AssetBundleUtility.Instance.Sync_LoadAllAssets("Shader");
            Shader.WarmupAllShaders();
        }
    }