Unity精灵在运​​行时被损坏

问题描述

在我们的项目中,我们有一些预制件是从流媒体资产捆绑中加载的。它最近开始在编辑器(而不是内部版本)中加载损坏的精灵。

如果将预制件拖到场景中,它将起作用并且看起来不错。

如果从流媒体资产中加载了它,则它已损坏。

enter image description here

我尝试删除和重建我的流媒体资源以及库,但是它仍然损坏了。我还在项目设置中重置了图形着色器

您还有其他建议可能会导致这种情况吗?

请注意,除了背景之外,还有更多的元素变形。当图像放大时,会出现子文本对象,它们也会变形。

此问题也开始在每个人的计算机上发生,因此它不是本地问题(例如,不是库或资产捆绑包的修复错误)。

enter image description here

这是我的资产捆绑管理器,它为我的ScriptableObjects和Prefabs对象类型创建资产捆绑

{
    private static AssetBundle _scriptableObjectsBundle;
    private static AssetBundle _prefabsBundle;

    public static T LoadScriptableObject<T>(string assetName) where T : ScriptableObject
    {
        if (_scriptableObjectsBundle == null)
        {
            AssetBundle.UnloadAllAssetBundles(true); // Required for editor editing which loads this (or you get a duplicate asset bundle load error)
            _scriptableObjectsBundle = AssetBundle.LoadFromFile(Application.streamingAssetsPath + "/scriptableobjects");
            if (_scriptableObjectsBundle == null)
            {
                Debug.Log("Failed to load 'scriptableobjects' AssetBundle!");
                return null;
            }
        }

        if (!_scriptableObjectsBundle.Contains(assetName))
        {
            Debug.LogError("scriptableobjects asset bundle does not contain: " + assetName);
        }

 
        return _scriptableObjectsBundle.LoadAsset<T>(assetName);
    }

    /// <summary>
    /// Loads the base prefab. Don't use this to edit objects,other objects must use this objects clone via the Prefabs class.
    /// </summary>
    /// <param name="assetName"></param>
    /// <returns></returns>
    public static GameObject LoadBasePrefab(string assetName)
    {
        if (_prefabsBundle == null)
        {
            _prefabsBundle = AssetBundle.LoadFromFile(Application.streamingAssetsPath + "/prefabs");
            if (_prefabsBundle == null)
            {
                Debug.Log("Failed to load 'prefabs' AssetBundle!");
                return null;
            }
        }

        if (!_prefabsBundle.Contains(assetName))
        {
            Debug.LogError("prefabs asset bundle does not contain: " + assetName);
        }

        GameObject baseGameObject = _prefabsBundle.LoadAsset<GameObject>(assetName);
        return baseGameObject;
    }
}

然后,我有一个Prefabs类,该类专门处理实例化的预制件副本(因为我的可脚本编写的对象只是我从地图读取的数据)。这是相关的加载代码:

    public static GameObject LoadPrefab(T_Prefabs type)
    {
        if (_MAP == null)
        {
            init();
        }

        if (!_MAP.ContainsKey(type) || _MAP[type] == null)
        {
            Debug.LogError("Missing prefab type: " + type + " did you add the 'prefabs' asset tag!?");
        }

        GameObject obj = Object.Instantiate(MAP[type]);
        if (obj.GetComponent<S_SerializedMonoBehaviour>())
        {
            obj.GetComponent<S_SerializedMonoBehaviour>().ResetState();
        }
        return obj;
    }

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...