- Home /
Attempt to access a method failed
Hello again commmunity ! :)
I got the following line in the log files (considering i'm working with the webplayer):
MethodAccessException: Attempt to access a private/protected method failed. at System.Security.SecurityManager.ThrowException (System.Exception ex) [0x00000] in :0 at DrawGUI.Execute (System.String exe, System.String arguments) [0x00000] in :0
I've been looking at: http://answers.unity3d.com/questions/49048/unity-31-webplayer-access-method-failed.html
But I can't find a solution...
Here's the code:
public void CreateExec()
{
Execute(@"Assets/CreateWebplayer.bat" ,"");
}
public static void Execute(string exe, string arguments)
{
System.Diagnostics.Process myProc = new System.Diagnostics.Process();
myProc.StartInfo.FileName = exe;
myProc.StartInfo.Arguments = arguments;
myProc.Start();
}
The goal of this code is to launch a .bat/.sh script that would look like:
Unity.exe -quit -batchmode -executeMethod ExecCreator.BuildOffline
Doing this would allow the application to create assetbundles (it is a necessary step in the project).
The .bat/.sh script is located on the server, it got no permission restriction... any ideas ?
I'm sorry if the question looks stupid to you, i'm not much of a Unity Hero at the moment :D
Answer by Kryptos · Jul 31, 2012 at 08:55 AM
You cannot access the system inside a webplayer build due to the sandbox protection policy.
The webplayer is executed on the client side, so you cannot access distant file that way. You need to use the WWW class and send a request to a script (for example PHP, Perl...).
edit: It seams that creating a process is authorized (at least it is supported in the .Net subset used in webplayer). But I would not recommend it. Anyway, in your case this is not what you want.
So how is it technically possible to use the unityeditor functionnalities (like creating assetbundles) with the webplayer ? Let me explain the context, maybe I didn't explain it clearly enough, and i feel bad asking questions everytime i got troubles :(
I'm looking for a way to create a webplayer dynamically, so that the user could create his webplayer (and the associated bundles) while using the application. To do this i need to access several classes within the unityeditor library like buildpipeline(mainly).
I did use PHP to solve my last trouble (thanks to your expert advice), and i'll use PHP again to solve this one ? I used to hate PHP but now i guess we'll be friends...
Thank you again for the quick help ! :)
You cannot use the editor functionnalities outside of the editor. The UnityEditor assembly is not shipped in any build.