Operator '+=' cannot be applied to operands of type 'Action' and 'method group'

Viewed 275

We are developing WebGL games for websites, we use some ad plugins Gamemonetize,Gamedistribution. I used this Plugins before everything its fine, but here in this project When I use this plugins I get this errors. How Can I solve this

Error1; Assets/GameMonetize/Demo/GameManager.cs(11,9): error CS0019: Operator '+=' cannot be applied to operands of type 'Action' and 'method group'

Error2; Assets/GameMonetize/GameMonetize.cs(63,34): error CS1955: Non-invocable member 'GameMonetize.OnResumeGame' cannot be used like a method.

PS1: No problem in different projects

PS2: Im using "Events" in project, But what i don't understand is When I delete the "Events" Still I got Error

using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using UnityEngine;

public class GameMonetize : MonoBehaviour
{
    public static GameMonetize Instance;

    public string GAME_ID = "YOUR_GAME_ID_HERE";

    public static Action OnResumeGame;
    public static Action OnPauseGame;

    [DllImport("__Internal")]
    private static extern void InitApi(string gameKey);

    [DllImport("__Internal")]
    private static extern void ShowBanner();

    void Awake()
    {
        if (GameMonetize.Instance == null)
            GameMonetize.Instance = this;
        else
            Destroy(this);

        DontDestroyOnLoad(this);

        Init();
    }

    void Init()
    {
        try
        {
            InitApi(GAME_ID);
        }
        catch (EntryPointNotFoundException e)
        {
            Debug.LogWarning("Initialization failed. Make sure you are running a WebGL build in a browser");
        }
    }
    
    internal void ShowAd()
    {
        try
        {
            ShowBanner();
        }
        catch (EntryPointNotFoundException e)
        {
            Debug.LogWarning("ShowBanner failed. Make sure you are running a WebGL build in a browser");
        }
    }

    /// <summary>
    /// Resume the game, this method is used when an ad has been showed
    /// </summary>
    void ResumeGame()
    {
       if (OnResumeGame != null) OnResumeGame();
    }

    /// <summary>
    /// Pause the game, this method is used when we show an ad
    /// </summary>
    void PauseGame()
    {
        if(OnPauseGame != null) OnPauseGame();
    }
}

Script 2:


using System;
using UnityEngine;
using UnityEngine.UI;

public class GameManager : MonoBehaviour {

    public Text infoText;

    void Awake()
    {
        GameMonetize.OnResumeGame += ResumeGame;
        GameMonetize.OnPauseGame += PauseGame;
    }

    public void ResumeGame()
    {
        // RESUME MY GAME
        infoText.text = "RESUME GAME";
    }

    public void PauseGame()
    {
        // PAUSE MY GAME
        infoText.text = "GAME PAUSED";
    }


    public void ShowAd()
    {
        GameMonetize.Instance.ShowAd();
    }
 }

Errors Came From Scrpit1:

void ResumeGame()
{
    if (OnResumeGame != null) OnResumeGame();
}

/// <summary>
/// Pause the game, this method is used when we show an ad
/// </summary>
void PauseGame()
{
    if(OnPauseGame != null) OnPauseGame();
}

Errors Came From Scrpit2:

void Awake()
{
    GameMonetize.OnResumeGame += ResumeGame;
    GameMonetize.OnPauseGame += PauseGame;
}
0 Answers
Related