Modify a mesh- or just a txt file- in real time?

I am trying to make a game with deformable terrain, but I do not want to use Unity’s terrain engine but rather a mesh. Is there a way to access and modify a file in the game files while running the game at a text based level?

A simple way to put this is if I were to have a .txt file read out its text and display it, could I have the text in the .txt file edited and then changed in real time?

.Obj files are read in plain text as display the coordinates of the points followed by the connection of the points as faces or lines. That’s easy enough to code something to modify the mesh in-game. A simple square plane looks like this in an obj file:

v 1.000000 0.000000 -1.000000
v 1.000000 0.000000 1.000000
v -1.000000 0.000000 1.000000
v -1.000000 0.000000 -1.000000
usemtl (null)
s off
f 1 4 3 2

My second question, if the first can be answered, is if it is possible to also modify the texture in real time.

Please let me know anything you can, even if it’s about modifying a text file in real-time directly from the game! Thanks!

By the way, I would prefer Javascript if at all possible, but if all you know the answer for is in C# then please share that too. :stuck_out_tongue:

Modifying text can be done by using a TextAsset

Modifying the mesh can be done by editing the vertices as shown in the example on the Mesh reference page.

Modifying a texture can be done by changing the pixel values on the existing Texture2D by using SetPixels().