找回密码
 立即注册
查看: 259|回复: 0

Unity Addressables热更不检测C#脚本变化解决方案

[复制链接]
发表于 2022-7-1 17:14 | 显示全部楼层 |阅读模式
https://forum.unity.com/threads/content-update-preview-bug.1299783/
有人发现Addressables热更有个bug:
    在C#脚本加个空格执行Check For Content Update Restrictions后,就被Addressables检测到发生改变导致:挂上这个脚本的Prefab就当做变化的资源显示到Content Update Preview window了。
    I am using Unity 2019.4.22f1 and Addressables 1.16.19. But I guess this bug happens on every Addressables version and every Unity version. I have a Prefab in a group, the prefab has a MonoBehaviour script attached to it. I execute the New Build option. Then I modify the script without changing the serialized properties and fields, for example, I just add a space somewhere in the script, then run Check For Content Update Restrictions. We will see that the group shows up on the Content Update Preview window. However, the prefab wasn't modified, why is it being regarded as the bundle that will be changed after running Update A Previous Build?

其实解决这个方法很简单,以Addressables1.19.19为例。只需要在 Packages/Addressables/Editor/Build/ContentUpdateScript.cs文件,加几行代码,不检测C#变化即可解决问题。
    [Serializable]    public struct AssetState : IEquatable<AssetState>    {        /// <summary>        /// Check if one asset state is equal to another.        /// </summary>        /// <param name="other">Right hand side of comparision.</param>        /// <returns>Returns true if the Asset States are equal to one another.</returns>        public bool Equals(AssetState other)        {   //剔除C#变化检测 Start if(guid == other.guid && hash == other.hash){    return true;}else{    var assetPath = UnityEditor.AssetDatabase.GUIDToAssetPath(guid.ToString());    if (assetPath == null) {        UnityEngine.Debug.LogError("Can not find Path:" + guid);        return false;    }else if (assetPath.EndsWith(".cs")){        UnityEngine.Debug.LogWarning("C# default is consider equal:" + assetPath);        return true;    }return false;}//剔除C#变化检测 End            //return guid == other.guid && hash == other.hash;        }    }
懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Unity开发者联盟 ( 粤ICP备20003399号 )

GMT+8, 2024-9-22 05:29 , Processed in 0.086975 second(s), 25 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表