Jump to content

Changing variable values with dnSpy or hex editing has no effect?


isaiah658

Recommended Posts

This is something that appears to apply to all Unity games, or at least all the Unity games I've played. If I use dnSpy to look at the Assembly-CSharp.dll and change variable values, such as making "public float height = 1f;" instead be "public float height = 20f;", the game still behaves like the value is 1 and not 20. The only workaround I have found is to change the actual code to get the desired result. Using hex editing I'm able to change out token ids meaning I can switch variables and methods for different ones. This of course is a lot harder because you are limited to how you can change it. You can use dnSpy to add or subtract code, but that requires recompiling the dll. To distribute the mods, you would have to distribute modded game files. I would prefer to be able to distribute a small program that hex edits the game instead of giving out game files. Hex edits can often last several updates if that code is never changed.

 

Any idea on why editing variable values doesn't seem to have any affect on the game? My only guess is due to prefabs or something being used the variable is already stored in other locations.

Link to comment
Share on other sites

This is something that appears to apply to all Unity games, or at least all the Unity games I've played. If I use dnSpy to look at the Assembly-CSharp.dll and change variable values, such as making "public float height = 1f;" instead be "public float height = 20f;", the game still behaves like the value is 1 and not 20. The only workaround I have found is to change the actual code to get the desired result. Using hex editing I'm able to change out token ids meaning I can switch variables and methods for different ones. This of course is a lot harder because you are limited to how you can change it. You can use dnSpy to add or subtract code, but that requires recompiling the dll. To distribute the mods, you would have to distribute modded game files. I would prefer to be able to distribute a small program that hex edits the game instead of giving out game files. Hex edits can often last several updates if that code is never changed.

 

Any idea on why editing variable values doesn't seem to have any affect on the game? My only guess is due to prefabs or something being used the variable is already stored in other locations.

 

Using SDX to run patch scripts that modify the DLL is probably the best solution we have at this point.

Link to comment
Share on other sites

Using SDX to run patch scripts that modify the DLL is probably the best solution we have at this point.

 

Do you happen to know why changing the variables has no effect though? I've been able to make do with only using clever hex editing and can continue to do so. I just want to know why it's like that to have a better understanding how things work as a whole and so I have a proper answer if someone asks why I'm modding the game in a seemily strange way. Thanks for any help you can provide!

Link to comment
Share on other sites

Do you happen to know why changing the variables has no effect though? I've been able to make do with only using clever hex editing and can continue to do so. I just want to know why it's like that to have a better understanding how things work as a whole and so I have a proper answer if someone asks why I'm modding the game in a seemily strange way. Thanks for any help you can provide!

 

You are probably changing the default value, but there may be another place that re-assigns it to a new default at another stage. You'd have to right click on the variable, and pick the Analyze option, and look for everywhere else its assigned at.

Link to comment
Share on other sites

You are probably changing the default value, but there may be another place that re-assigns it to a new default at another stage. You'd have to right click on the variable, and pick the Analyze option, and look for everywhere else its assigned at.

 

Hmm...the analyze tool only shows one location for each variable. My only guess at this point is that prefabs are the reason. If anyone else knows anything more please let me know. Thank you for the suggestions!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...