Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Resolved UnityEvents not working properly

Discussion in 'Editor & General Support' started by METALWORKS, Nov 9, 2023.

  1. METALWORKS

    METALWORKS

    Joined:
    Oct 29, 2018
    Posts:
    3
    Hello everyone. When I add a script with a UnityEvent component to a gameobject I can't seem to link the event to a method of another script. I am able to choose the script, but it doesn't allow me to access anything except for MonoScript.name. It makes no difference which script I pick in the component, it only shows monoscript.
    At first I encountered this issue on version 2021.3.5f1 so I upgraded to 2022.3.13f1 but the issue still persists. Is there something I miss? unity1.PNG
     

    Attached Files:

  2. METALWORKS

    METALWORKS

    Joined:
    Oct 29, 2018
    Posts:
    3
    Don't mind "Off" in the first pic. It makes no difference if I set Runtime only.
     
  3. METALWORKS

    METALWORKS

    Joined:
    Oct 29, 2018
    Posts:
    3
    Nevermind. It appears you have to drag not the script but the object it's attached to. It works.
     
  4. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    8,370
    Yes, scripts are just text files. Quite literally, they just inherit from TextAsset: https://docs.unity3d.com/ScriptReference/MonoScript.html

    They don't represent actual instances of objects of anything in your project.