ApiCompatibilityLevel {获取;设置}错误Unity

时间:2017-11-24 10:09:52

标签: c# unity3d

我有一个小问题,这里是

// Rebuild asset bundle files
        EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Standalone, BuildTarget.StandaloneWindows);
        PlayerSettings.colorSpace = ColorSpace.Linear;
        PlayerSettings.GetApiCompatibilityLevel = PlayerSettings.SetApiCompatibilityLevel(BuildTargetGroup.Standalone,ApiCompatibilityLevel.NET_2_0);

,错误是

  

作业的左侧必须是变量,属性或索引器

第二个是

static void Build_Android_Release(string[] scenes, short eCVC, bool bRelease = true){
    //lets change the platform
    EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Android); 
}

错误说:

  

!“UnityEditor.EditorUserBuilsettings.SwitchActiveBuildTarget(UnityEditor.BuildTarget)”的最佳overloarded方法匹配有一些无效的参数

     

!参数#1' cannot convert UnityEditor.BuildTargetGroup'表达式,键入`UnityEditor.BuildTarget'

1 个答案:

答案 0 :(得分:0)

第一次出错,

PlayerSettings.GetApiCompatibilityLevel = PlayerSettings.SetApiCompatibilityLevel(BuildTargetGroup.Standalone,ApiCompatibilityLevel.NET_2_0);

应替换为

PlayerSettings.SetApiCompatibilityLevel(BuildTargetGroup.Standalone,ApiCompatibilityLevel.NET_2_0);

对于第二个错误,您使用BuildTargetGroup代替BuildTarget(如错误所示)。

您需要使用:

EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTarget.Android);