Getting error “no suitable method to override”

最后都变了- 提交于 2021-02-17 07:16:09

问题


I am trying some stuff with Unity and getting lot of this error where is always "no suitable method to override". For example:

Assets/Standard Assets/Effects/ImageEffects/Scripts/Antialiasing.cs(86,30): error CS0115: `UnityStandardAssets.ImageEffects.Antialiasing.CheckResources()' is marked as an override but no suitable method found to override.

Its look like that error is trivial, but I don't know C#, so don't know what with this. Can you show at this example, how fix this? Thanks!

public override bool CheckResources()
{
    CheckSupport(false);

    materialFXAAPreset2 = CreateMaterial(shaderFXAAPreset2, materialFXAAPreset2);
    materialFXAAPreset3 = CreateMaterial(shaderFXAAPreset3, materialFXAAPreset3);
    materialFXAAII = CreateMaterial(shaderFXAAII, materialFXAAII);
    materialFXAAIII = CreateMaterial(shaderFXAAIII, materialFXAAIII);
    nfaa = CreateMaterial(nfaaShader, nfaa);
    ssaa = CreateMaterial(ssaaShader, ssaa);
    dlaa = CreateMaterial(dlaaShader, dlaa);

    if (!ssaaShader.isSupported)
    {
        NotSupported();
        ReportAutoDisable();
    }

    return isSupported;
}

回答1:


The method in the code example you provided is marked override. This means that the compiler will take the class this method is in and look through the ones it inherits from to find one to override.

See the documentation here.

If you're sure this code is correct, then removing the override keyword from the method definition should get rid of the error.

If you haven't written this code yourself and its part of the Unity files, then you're likely missing some dependencies (read: the files that contain the class with the method that yours should override).




回答2:


The only workaround I found was deleting the entire public class BloomAndFlares : PostEffectsBase. Everything else gave me an error.



来源:https://stackoverflow.com/questions/43901589/getting-error-no-suitable-method-to-override

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!