Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Keavon · Jul 06, 2011 at 01:12 AM · meshrealtimedeformationobjmodify

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. :P

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
2
Best Answer

Answer by TaintedLemon · Jul 06, 2011 at 01:26 AM

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().

Comment
Add comment · Show 4 · 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 Keavon · Jul 06, 2011 at 01:33 AM 0
Share

Thanks for your quick reply! I'll check into those. I gave you a thumbs up, but I'll wait a little while longer before giving you a best answer to encourage other answers.

About editing the texture by setting the pixel values, that might not work... I am making a 3D $$anonymous$$ing game, somewhat like $$anonymous$$inecraft, but that uses true terrain and not a ton of blocks. I will have the world generated in a text file, kinda block based, but when you dig, the world will change, but if you dig into a different thing, ie. rock from dirt, then the texture will need to change around your tunnel. If you understand what I mean, do you think "changing the pixel values of an existing Texture2D" is the best approach? Or is there anything more appropriate available? Because, lets say you have a flat piece of ground with a texture. Now you try digging a tunnel into it. You will need a new texture file to add to that surface because it wasn't originally there but was added in a separate spot. Thanks again!

avatar image TaintedLemon · Jul 06, 2011 at 01:39 AM 0
Share

You should definitely have a look at Voxelform then: http://cyclopsframework.org/voxelform/. Costs $100 but might be exactly what you want.

avatar image Keavon · Jul 06, 2011 at 02:07 AM 0
Share

Wow, Voxelform looks like a pretty fun piece of software for Unity. I've been looking for something that can make non-hightmap terrains. But unfortunately that's not 100% what I want, because I also need to have a texture applied somehow, and I'll want to know my own code for that. Oh, and I don't want to have to pay $100 for it. But again, thank you for the link. It was fun playing with the demo!

avatar image Fattie · Oct 14, 2011 at 07:16 AM 0
Share

@$$anonymous$$eavon, even if you don't want to pay $100, perhaps you could tick this excellent answer and it remains the best answer after some 5 years :)

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Using the PaintVertices code from the Procedural Mesh example project, the sphere normals get messed up 0 Answers

Lining up mesh edges for deformation 0 Answers

Modify mesh on load 1 Answer

Import mesh with submeshes from OBJ? 2 Answers

Saving generated meshes at runtime in game 3 Answers


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