- Home /
System.Action is not working for WebGL build
Hi guys,
so I'm using System.Action for some kind of event manager where I subscribe to one action with other scripts. Then when I trigger the action, the subscribed scripts will react to it.
This works fine in the editor and I used it before for mobile games but now that I try to use it within a WebGL build, it throws an error when I try to trigger the action like Action() because it says the method is not defined.
Do you know if System.Action is not supported for WebGL builds or do I need to do something different?
Thanks
Answer by Pangamini · Jan 06 at 01:49 PM
System.Action is just a delegate type defined in a .net library. It is possible that the event you're subscribing to is not defined in WebGL. Perhaps you could share some bit of the related code
So what I want to do is in one class define
public class ClassWithAction : Monobehaviour{
public static Action genericAction;
}
Then, in another class I do the following:
private void OnEnable(){
ClassWithAction.genericAction += HandlingMethod; //I understand this as subscribing to the action
}
public void HandlingMethod(){
//handle stuff
}
Then again, in the first class if I just call genericAction(); I expect each instance that is subscribed to the action to trigger the subscribed method. This workes fine in the editor and also for mobile builds but doesn't work for WebGL.
Maybe I'm understanding this whole thing wrong?
Does it build, but the HandlingMethod is not being called, or does it throw an error during the build?
It builds and loads but then when the HandlingMethod needs to be called I get an error saying "null function or function signature mismatch". This is probably because it is looking for the genericAction() method but can't find it instead of executing the HandlingMethod
Your answer
Follow this Question
Related Questions
2 click - defferent actions 1 Answer
Unet - adding [Command] function to Action C# 0 Answers
When Unity3D finally supports WebGL? 2 Answers
Unity 4 compatibility to Unity 5 WebGL 1 Answer
GL build won't run on Chrome 1 Answer