unit5.6升级到unity2020的错误汇总
猫与操作逻辑
2021年02月07日 00:28
收录于文集
共7篇

花了半天的时间,终于是将自己的游戏引擎从unit5.6升级到unity2020了。

遇到很多错误,汇总一下。完美运行,就是地面的不同材质没有了,要重新刷一下。

unit5.6最近在mac升级后无法运行了。升级到unity2020,开始做移动端,手游。

错误1

error CS0619: ‘GUITexture’ is obsolete: ‘GUITexture has been removed. Use UI.Image instead.’

打开ForcedReset脚本

增加    using UnityEngine.UI;

修改    [RequireComponent(typeof (GUITexture))]为[RequireComponent(typeof(Image))]

错误2

error CS0619: 'GUIText&#​39; is obsolete: 'GUIText has been removed. Use UI.Text instead.'

打开SimpleActivatorMenu脚本。

增加    

修改    public GUIText camSwitchButton; 为 public Text camSwitchButton;

错误3

error CS0246: The type or namespace name 'NetworkManager&#​39; could not be found (are you missing a using directive or an assembly reference?)

error CS0246: The type or namespace name 'NetworkManager&#​39; could not be found (are you missing a using directive or an assembly reference?)

error CS0246: The type or namespace name 'NetworkLobbyManager&#​39; could not be found (are you missing a using directive or an assembly reference?)

error CS0246: The type or namespace name 'NetworkConnection&#​39; could not be found (are you missing a using directive or an assembly reference?)

error CS0246: The type or namespace name 'NetworkMessage&#​39; could not be found (are you missing a using directive or an assembly reference?)

error CS0246: The type or namespace name 'NetworkBehaviour&#​39; could not be found (are you missing a using directive or an assembly reference?)

error CS0246: The type or namespace name 'NetworkTransform&#​39; could not be found (are you missing a using directive or an assembly reference?)

error CS0246: The type or namespace name 'CommandAttribute&#​39; could not be found (are you missing a using directive or an assembly reference?)

error CS0246: The type or namespace name 'Command&#​39; could not be found (are you missing a using directive or an assembly reference?)

error CS0115: 'LobbyManager.OnStartHost()&#​39;: no suitable method found to override

error CS0115: 'LobbyManager.OnMatchCreate(bool, string, MatchInfo)': no suitable method found to override

error CS0115: 'LobbyManager.OnDestroyMatch(bool, string)': no suitable method found to override

error CS0115: 'LobbyManager.OnLobbyServerSceneLoadedForPlayer(GameObject, GameObject)': no suitable method found to override

error CS0115: 'LobbyManager.OnLobbyServerPlayersReady()': no suitable method found to override

error CS0246: The type or namespace name 'MessageBase&#​39; could not be found (are you missing a using directive or an assembly reference?)

error CS0246: The type or namespace name 'MessageBase&#​39; could not be found (are you missing a using directive or an assembly reference?)

error CS0115: 'LobbyPlayer.OnClientEnterLobby()': no suitable method found to override

error CS0115: 'LobbyPlayer.OnStartAuthority()': no suitable method found to override

error CS0115: 'LobbyPlayer.OnClientReady(bool)': no suitable method found to override

error CS0246: The type or namespace name 'SyncVarAttribute&#​39; could not be found (are you missing a using directive or an assembly reference?)

error CS0246: The type or namespace name 'SyncVar&#​39; could not be found (are you missing a using directive or an assembly reference?)

error CS0246: The type or namespace name 'hook&#​39; could not be found (are you missing a using directive or an assembly reference?)

error CS0246: The type or namespace name 'SyncVarAttribute&#​39; could not be found (are you missing a using directive or an assembly reference?)

error CS0246: The type or namespace name 'ClientRpcAttribute&#​39; could not be found (are you missing a using directive or an assembly reference?)

error CS0246: The type or namespace name 'ClientRpc&#​39; could not be found (are you missing a using directive or an assembly reference?)

因为unity已经弃用了自带的Network,所以会报错,建议直接删除原来相关脚本。

如果有不想删除的话。

打开“Window”>“package Manager”,然后在弹出的窗口左上角按+(加号):Add Package from git URL

在加号下面显示的文本框里输入com.unity.multiplayer-hlapi。文本框右侧的add按钮会亮起,点击安装。package Manager界面右侧会显示安装状态,安装完毕上述全部关于Network的错误都消失了。

package Manager

错误4

error CS0619: 'GUIText&#​39; is obsolete: 'GUIText has been removed. Use UI.Text instead.'

打开 DemoBoxesGui脚本

增加 using UnityEngine.UI;

将public GUIText GuiTextForTips修改为public Text GuiTextForTips。

错误5

error CS0619: 'EventType.keyDown&#​39; is obsolete: 'Use KeyDown instead (UnityUpgradable) -> KeyDown'

把小写EventType.keyDown改成大写EventType.KeyDown。首字母大写。

错误6

error CS0165: Use of unassigned local variable 'pixel&#​39;

打开TextureCanvas脚本

修改

Color32 pixel;

pixel.r = (byte)(m_color.r*m_srcAlpha + dst.r*m_dstAlpha);

pixel.g = (byte)(m_color.g*m_srcAlpha + dst.g*m_dstAlpha);

pixel.b = (byte)(m_color.b*m_srcAlpha + dst.b*m_dstAlpha);

pixel.a = (byte)(m_color.a*m_srcAlpha + dst.a*m_dstAlpha);

为

            Color32 pixel = new Color32((byte)(m_color.r * m_srcAlpha + dst.r * m_dstAlpha), (byte)(m_color.g * m_srcAlpha + dst.g * m_dstAlpha), (byte)(m_color.b * m_srcAlpha + dst.b * m_dstAlpha), (byte)(m_color.a * m_srcAlpha + dst.a * m_dstAlpha));

错误7

error CS0619: 'QualitySettings.blendWeights&#​39; is obsolete: 'blendWeights is obsolete. Use skinWeights instead (UnityUpgradable) -> skinWeights'

将QualitySettings.blendWeights修改为QualitySettings.skinWeights

错误8

error CS0619: 'BlendWeights&#​39; is obsolete: 'BlendWeights is obsolete. Use SkinWeights instead (UnityUpgradable) -> SkinWeights'

将BlendWeights.TwoBones修改为:SkinWeights.TwoBones;

错误9

error CS0117: 'Handles&#​39; does not contain a definition for 'DotCap&#​39;

将Handles.DotCap修改为Handles.DotHandleCap,记得补充最后一个参数EventType.Repaint。