- Home /
Question by
thendricks · Sep 19, 2014 at 08:45 PM ·
c#javascripteventsdelegate
C# and JavaScript Event system causing
I'm having problem with my event system. I set it up in C# like this public delegate void FirePressed(); public static event FirePressed Fire;
public delegate void AimPressed();
public static event AimPressed Aim;
public delegate void ActionPressed();
public static event ActionPressed Action;
public void ButtonPressed(string ActiveButton)
{
switch(ActiveButton)
{
case "Fire":
if(Fire != null)
Fire();
break;
case "Aim":
if(Aim != null)
Aim();
break;
case "Action":
if(Action != null)
Action();
break;
}
}
and my javascript code contains this in it
ButtonControl.Aim += ADS;
but unity keeps saying that ButtonControl (the name of the c# script) is an unknown identifier. Does anyone know how to get the JS script to recognize the c# script
FYI I followed all of the compiler procedures.
Comment
Answer by Slev · Sep 19, 2014 at 09:13 PM
According to this post you need to place the C# file you wish to access in the "Plugins" folder so that it is accessible during compilation. However, I am not clear as to why you would be combining JS and C#, if you're already using C# you might be better served rewriting any lingering JS as C# code.