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 nikita68 · Mar 27, 2013 at 07:51 PM · in-gameexecute

Execute code which was written in game

Hello everybody!

Is it possible in any way to write a code, in game, and them execute it? The aim is to allow the player to mod the game.

I program in C# and i have already a little experience with Unity (especially multiplayer games).

Thanks, Nikita

Comment
Add comment · Show 2
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 Unitraxx · Mar 27, 2013 at 08:08 PM 0
Share

So any user of your application would be allowed to write code, and immediately execute it on top of your code? Seems quite the security risk, what's your goal?

avatar image nikita68 · Mar 28, 2013 at 07:49 AM 0
Share

Exactly! I know this is a security risk, but i believe it has to be that way, as i want to allow the player to mod the game.

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by $$anonymous$$ · Mar 27, 2013 at 08:12 PM

your looking for possibly a command line library for a console or easy mods, this is no easy task but there is a free library here if you want to get started. It does, however, require a very extensive knowledge of c#. I'm not sure if there is a unityscript( javascript) or boo equivalent. by the way, if your looking to create your own game creator, unity is not the application to do it in.

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 nikita68 · Mar 28, 2013 at 07:48 AM 0
Share

Thanks for the quick answer! The library looks awesome, though it may not be exactly what i need (or maybe i don't get it), as i'm ai$$anonymous$$g to let the person write a piece of code, which then gets inserted into a script, and then that script gets executed later on. Thanks!

avatar image
0

Answer by whydoidoit · Mar 28, 2013 at 08:55 AM

So it depends on your game's platform:

  • Web player/iOS - you would probably have to build your own scripting language that was interpreted and executed by your game engine. You cannot emit or compile code on these platforms.

  • PC/Mac - you can probably get System.Reflection.Emit to create .NET IL assemblies at run time from script typed in - by I doubt the C# compiler services are shipped with Unity by default so you'd probably need to build those in a separate assembly using MonoDevelop and then link it into your game.

  • Console - no idea

It would be pretty hard work - I'd look for a C# open source C# prep/compilation project and try to link with that if you are targeting PC/Mac standalone.

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

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

12 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

Related Questions

How can I execute code in the editor? 1 Answer

Stop Script Completely. Doesn't Execute Another Line Of Code. 1 Answer

How does Unity "read" JavaScript code? 3 Answers

Does unity C# support an exec method? 1 Answer

Executing code from a text file and writing changes to it 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