Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 SavvaMadar · Jul 02, 2014 at 07:26 PM · runtimeruntime-generationhacking

Allowing users to import their own UnityScript/JavaScript into the game at run time

I want to make a game where players can hack to beat the game, it's possible to beat fairly but its absurdly hard. I want players to be able to write their own UnityScript/JavaScript and import it into the game and attach it to any gameObject they want. I know I can let them write some code in a text field and then use eval() to run the code, but that's not what I want, I want them to be able to attach said script to a gameObject in run time. Is there anyway to do this? They don't need to write it in run time, simply so that they can import the .js file and have the game recognize it as a script. If so how would I do that?

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

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by rutter · Jul 02, 2014 at 07:34 PM

Short answer: that's theoretically possible, but so difficult that it might as well be impossible.

Unity's editor ships with compiler tools, but the built player does not. You would need to embed a compiler and/or interpreter with your game, just to get the code to a point where it could process new code at runtime.

How will the user input code? You may need an elaborate UI system.

How will the code be compiled? You may need an elaborate compiler/interpreter. You may need to devise your own programming language. You may need to make sure that the user isn't able to perform dangerous operations (like deleting or corrupting files, including the game itself and other files on their system).

How will the code be run? Will you bind to a DLL that's compiled while the game is running? That sort of binding is only available in Unity Pro. Will you run a separate application, and connect to it via sockets and RPCs? Then you'd need to put together a framework by which your applications can communicate.

Comment
Add comment · Show 2 · 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 SavvaMadar · Jul 02, 2014 at 07:45 PM 0
Share

No the user will write the code any way they want as long as its compatible with unity (free) ( they can test this with the free version of unity, the users who don't know how to program can just download solutions/code provided by other people). I will just be importing the .js file, if the code is bad the game should crash because its failed code. As for compiling I thought JS, doesn't need compiling... That's the reason web browsers use it. Also what about the eval() function, how does that work, it can't be compiling the JS code, isn't it just running it?

avatar image SavvaMadar · Jul 02, 2014 at 07:53 PM 0
Share

How does the eval() function work then in unityScript? It can't be compiling the code can it? I thought it just runs it on the spot. And for now I just want the user to be able to import .js files and attach them to a gameObject, that's all that matters for now.

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

22 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Why does this script make my camera upside down? 0 Answers

How to toggle a key for a car to go forward or backward? 1 Answer

Error whit c# code 'UnityEngine.Transform.position' because it is not a variable. 1 Answer

Apply low gravity only for specific object. 1 Answer


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