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

恶性漏洞通知&解决方案_关于Unity官方插件的兼容性问题

[复制链接]
发表于 2020-12-16 09:41 | 显示全部楼层 |阅读模式
开发者常用Unity的一个标准资源包:Standard Assets
但是最近在Unity2019.3.0a及后续版本中出现了因为弃用方法造成的恶性兼容性漏洞
我们先导入一下包
然后就报错了
控制台给出的错误是
  1. Assets\Standard Assets\Utility\ForcedReset.cs(6,27): error CS0619: 'GUITexture' is obsolete: 'GUITexture has been removed. Use UI.Image instead.'
复制代码
看来问题出现在Standard Assets调用了弃用的GUITexture
找到脚本修改一下
按照我的方式修改SimpleActivatorMenu脚本
  1. using System;
  2. using UnityEngine;
  3. using UnityEngine.UI; //在此处添加
  4. namespace UnityStandardAssets.Utility
  5. {
  6.     public class SimpleActivatorMenu : MonoBehaviour
  7.     {
  8.         // An incredibly simple menu which, when given references
  9.         // to gameobjects in the scene
  10.         public Text camSwitchButton; //在此处修改
  11.         public GameObject[] objects;
  12. ......
复制代码
除此之外还需要修改ForcedReset脚本
  1. using System;
  2. using UnityEngine;
  3. using UnityEngine.SceneManagement;
  4. using UnityStandardAssets.CrossPlatformInput;
  5. using UnityEngine.UI; //在此处添加
  6. [RequireComponent(typeof (Image))] //在此处修改
  7. public class ForcedReset : MonoBehaviour
  8. {
  9.     private void Update()
  10.     {
  11.         // if we have forced a reset ...
  12.         if (CrossPlatformInputManager.GetButtonDown("ResetObject"))
  13.         {
  14.             //... reload the scene
  15.             SceneManager.LoadScene(SceneManager.GetSceneAt(0).name);
  16.         <span class="p">}
  17.     }
  18. }
复制代码
完成!

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×
懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2024-6-3 00:18 , Processed in 0.098487 second(s), 26 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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