Search Unity

GameEventListener

Discussion in 'Scripting' started by Malavia, Sep 25, 2020.

  1. Malavia

    Malavia

    Joined:
    Aug 28, 2019
    Posts:
    10
    I'm tearing my hair out.

    I call the function ChangeValueBob with GameEventListener in the inspector.

    Code (CSharp):
    1. public int bob;
    2. public void ChangeValueBob()
    3. {
    4.          bob = 40;
    5. }
    But nothing is happening, I mean the value bob don't change in the inspector. Bob stays at 0.
    Could you help me; please or ask me questions if it's not clear.

    I helped myself from the following link :
    https://github.com/ErikOverflow/SimpleIncremental/wiki/Creating-a-Scriptable-Object-Event-system
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,909
    First thing to check: "Is my code even running?"

    Easiest way to check: add a Debug.Log statement inside your code:

    Code (CSharp):
    1. public void ChangeValueBob()
    2. {
    3.          Debug.Log("ChangeValueBob is running!");
    4.          bob = 40;
    5. }
    If it's not running, go back to the tutorial and double check you've set everything up properly.
     
  3. Malavia

    Malavia

    Joined:
    Aug 28, 2019
    Posts:
    10
    I copied my file and it does work now.
    Thank you PraetorBlue.