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 /
This question was closed Feb 01, 2021 at 02:34 PM by eraban for the following reason:

Other

avatar image
0
Question by eraban · Jan 29, 2021 at 12:16 PM · exporting

Export Function

Is it possible to add a exporting function to a game in unity. Just like blender has which asks the format and the address and name for exporting. If so then how should I implement this in my game.

Comment
Add comment · Show 10
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 Llama_w_2Ls · Jan 29, 2021 at 12:23 PM 0
Share

What are you trying to export? You could use the UI element called 'dropdown', fill it with items containing the different formats etc, and run the right method depending on what the user chose.

avatar image Bunny83 · Jan 29, 2021 at 12:23 PM 0
Share

Sorry but this question is way to vague. What exactly do you want to export from your game?

Of course in general everything is possible, it's just a matter of how much efford it takes. Unity is a game engine and as such does not have any direct support for generating asset files with just a couple of exceptions. For example Unity can generate png or jpeg files out of a texture. However Unity does not have any support for model files. So you need a third party library that can generate your desired file format or code it yourself.


Without more information about what you want to export, nobody can answer this question and we are going to close it. Please ask clear and detailed questions.

avatar image Llama_w_2Ls Bunny83 · Jan 29, 2021 at 12:31 PM 0
Share

@Bunny83 This might be a basic question but are there different levels of moderators? How do you close a question that made it through moderation, but seems to be very vague or a duplicate etc.

avatar image Bunny83 Llama_w_2Ls · Jan 29, 2021 at 01:00 PM 1
Share

Yes there are. At the end of the FAQs there's a list of what rights you have at which karma level. I'm not sure if that list is actually up to date. Though I passed the 10k a long time ago ^^.


ps: If you spot actual unrelated spam / advertisement Please make sure you report the post as such. Posts in the reported list can be easily removed which will also revert the bumping and we can easily suspend the user.

Show more comments
Show more comments
avatar image eraban · Jan 29, 2021 at 12:34 PM 0
Share

Sorry I wasn't clear before. I want to export models. $$anonymous$$y game is basically a model making software but unlike blender the user will get premade parts and can join them to make a whole model. I haven't made this yet, just wanted to get the export function out of the way.

avatar image Llama_w_2Ls eraban · Jan 29, 2021 at 12:43 PM 0
Share

Programs like blender can export in user-chosen formats such as .obj, .stl etc. These file formats take vertices, tris and normals and convert it into a file containing that data. Unless you have knowledge of how to create these files, you shouldn't step any further.


If you do know how to format your data into a widely accepted file format for meshes, you can get the data of your model by accessing the tris, verts, normals, and text coords of your mesh through the mesh filter. For example:

 Vector3[] verts = GetComponent<$$anonymous$$eshFilter>().mesh.vertices;

etc. @eraban I did write a program a while ago that converts a mesh into an stl file, but I wouldn't recommend writing your own algorithms to do that.

avatar image eraban Llama_w_2Ls · Jan 29, 2021 at 12:54 PM 0
Share

Okay thanks for the advice. Looks like I have too less knowledge about this.

avatar image Bunny83 eraban · Jan 29, 2021 at 12:53 PM 2
Share

Well exporting models isn't that simple depending on the target format. Watch out when you use premade parts. If you got those parts from the assetstore, the assetstore license does not allow any usage of the assets outside of a Unity project. So if you let users export things you don't have a full-rights licence on you could get into legal trouble.


You should update your question with more details instead of posting comments. You still haven'T mentioned any concrete target format. How you would export files also highly depends on your target platform, WebGL, Android, iOS and standalone builds work vastly different when it comes to file handling and exporting. Again, more details.

We've written collectively about 3 times as much as you have in your question ^^.

2 Replies

  • Sort: 
avatar image
1

Answer by BastianUrbach · Jan 29, 2021 at 03:48 PM

It depends on your requirements. Generating a basic .obj file from a Unity mesh is actually remarkably simple:

 void ExportObj(Mesh mesh, string path) {
     var actualCulture = System.Threading.Thread.CurrentThread.CurrentCulture;
     var thread = System.Threading.Thread.CurrentThread;
     thread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
 
     var stream = new System.IO.FileStream(path, FileMode.CreateNew);
     var writer = new System.IO.StreamWriter(stream, System.Text.Encoding.UTF8);
 
     writer.WriteLine($"o {mesh.name}");
 
     foreach (var vertex in mesh.vertices) {
         writer.WriteLine($"v {vertex.x} {vertex.y} {vertex.z}");
     }
 
     foreach (var uv in mesh.uv) {
         writer.WriteLine($"vt {uv.x} {uv.y}");
     }
 
     foreach (var normal in mesh.normals) {
         writer.WriteLine($"vn {normal.x} {normal.y} {normal.z}");
     }
 
     var triangles = mesh.triangles;
 
     for (int i = 0; i < triangles.Length; i += 3) {
         var a = triangles[i + 0] + 1;
         var b = triangles[i + 1] + 1;
         var c = triangles[i + 2] + 1;
 
         writer.WriteLine($"f {a}/{a}/{a} {b}/{b}/{b} {c}/{c}/{c}");
     }
 
     writer.Flush();
     writer.Close();
 
     thread.CurrentCulture = actualCulture;
 }
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
avatar image
0

Answer by wolfgraphicsLLC · Jan 29, 2021 at 01:11 PM

hello I was just reading and I have to say yes unity doe have function to export models. in the package manager is an fbx pack so far thats the only one I know of.

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

Follow this Question

Answers Answers and Comments

113 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image 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 hide the c#/js code from my asset on the market? 1 Answer

Why won't my exported FBX file work in Unity? 2 Answers

Exporting terrain objects with FBX?,Is there a way to export a terrain object to FBX format? 1 Answer

Can't correctly expot MagicaVoxel object to Unity 0 Answers

exporting sdk from unity3d 2 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