Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by buntu · Jun 11, 2011 at 06:40 AM · webplayerexceptionbce0055

RunTime Eval JS on WebPlayer

Hi all. I'm trying to modify my GUI ( iGUI) with JS at runtime. I used to do that with lua on my former engine...

 var textAsset : TextAsset;
          textAsset   =  Resources.Load("GUIScripts/bouton_repeter");  
         eval ( textAsset.text );

Everything works fine on the Editor. On the webPlayer is quite strange.

I can do stuff like that :

 var instance ; 
 instance =GameObject.Find("iGUI Root").GetComponent("iGUICode_POC_Neutre2_5");
 instance.getInstance().winDocInfo_WIN.setEnabled(true);

But calling set function are not working such as that :

 instance.getInstance().winDocInfo_WIN.label.text="Répeter la dernière consigne";

So it's quite strange , because if i add a TestButton on a JS MonoBehaviour, i can call the set method (but of course it's compiled code and not runtime code here).

The Error on the WebPlayerLog is :

  Exception caught : CompilationErrorsException: script(2,49): BCE0055: Boo.Lang.Compiler.CompilerError: Internal compiler error: Attempt to access a private/protected method failed.. ---> System.MethodAccessException: Attempt to access a private/protected method failed.

Any idea how can i handle that? May i can only use function and not setter on dynamic JS eval code? Thanks

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

6 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by BernieRoehl · Aug 10, 2011 at 06:29 PM

I've run into exactly the same problem. If I try to access my variables from within an eval'd piece of code, it tells me I'm trying to access private/protected method:

CompilationErrorsException: script(1,30): BCE0055: Boo.Lang.Compiler.CompilerError: Internal compiler error: Attempt to access a private/protected method failed.. ---> System.MethodAccessException: Attempt to access a private/protected method failed.

Anyone have any suggestions?

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image MountDoomTeam · May 10, 2013 at 08:16 AM 0
Share

try making all things accessed by eval, public...

avatar image
0

Answer by BernieRoehl · Aug 11, 2011 at 03:28 AM

I've simplified things down to the script below. I have a scene with just a camera, and I drop the script on it. That's it -- simple as can be.

It works fine in the editor, even with a web player target, but the actual web player throws an exception.

I think this may be an actual Unity bug.

 #pragma strict
 
 var result : String;
 
 function Start()
 {
     var ht = {};
     ht["one"] = 14;
     
     var script = " ht[\"one\"] == 14 ";    
     if (eval(script))
         result = "yes";
     else
         result = "no";
 }
 
 function OnGUI()
 {
     GUILayout.Label("result is " + result);
 }
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by BernieRoehl · Aug 16, 2011 at 12:16 AM

An even simpler illustration of the problem:

 #pragma strict
 
 var result : String = "unrun";
 
 function Start()
 {
   result = ""+eval(" 7 == 12 ");  // works in editor and web player
   result = ""+eval(" \"seven\" == \"twelve\" ");  // works in editor, not in web player
 }
 
 function OnGUI()
 {
     GUILayout.Label("the result is " + result);
 }

Is anyone working on this? Am I posting in the wrong place?

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by daRich · Feb 22, 2013 at 12:44 PM

I also got a problem with the Web-Player and the eval(); I´t seems not possible to access GameObjects and Functions, the only thing works are var : int :/

 #pragma strict
 var cube : GameObject;
 function Start()
 {
   cube = GameObject.Find...;
 }
 function myFunction()
 {
   Debug.Log("yeah");
 }
 function Awake()
 {
   eval("myFunction();"); // Dont work anywhere
   eval("cube.transform.position.x = 1;"); // Don't work in webplayer
 }

Sry I just brought some more Questions and no Answers :/

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image MountDoomTeam · May 10, 2013 at 08:20 AM 0
Share

Functions work, see reply at end for code of working funcion.

avatar image
0

Answer by daRich · Feb 22, 2013 at 12:43 PM

Sry I don´t have a solution – also worked with the eval() http://answers.unity3d.com/questions/403779/i-used-the-eval-function-on-web-player.html

I encountered functions also can not be called by eval().

 function Start()
 {
   eval("MyFunction();");
 }
 function MyFunction()
 {
   Debug.Log("works!"); // NOT
 }

The code above works nowhere!

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image dvidunis · Apr 26, 2013 at 12:40 PM 0
Share

add "static" before "function", in "eval" say "Scriptname.$$anonymous$$yFunction()". eval wont run as it was in the script, atleast for me.

  • 1
  • 2
  • ›

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Webplayer exception when using BufferedStream 0 Answers

Why can't I build Web Player in Unity while I have no problems with building standalone versions? 2 Answers

Determining what is causing an unmanged exception in web builds 0 Answers

Camera not working on webplayer like in editor 0 Answers

WebPlayer propagation 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges