- Home /
The question is answered, right answer was accepted
add c# code from a file outside of assets folder
so i want to add a c# file from Application.persistentDataPath so modding is easier on my game, if there isn't any way for that i guess ill have to make a customizable enemy AI thing.
Answer by Captain_Pineapple · Mar 28 at 09:39 AM
You can do this with runtime compilation but please note here:
Don't blindly execute code from third party sources at runtime. This is a massive security risk. So if you have a game and want to offer modding: Make sure to add a ton of security measures.
That being said, check out the following Link which contains a small code example:
Thanks, guess ill melt my brain now trying to add security
As you are not the first one to add modding to your game there are others who have already done this for you. Just check how others do this. Do not try to unnecessarily reinvent the wheel unless it is for educational purposes because you yourself want to learn how to do it and enjoy the process of searching for a solution.
Answer by xxmariofer · Mar 28 at 06:17 AM
You cant add code from outside of the assets folder
This is not correct. This can be done but can be risky - see my answer.