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 /
avatar image
1
Question by secondry2 · Feb 22, 2014 at 01:58 PM · functionaccessing from any script

OBJ runtime import

Hello! I am looking to import an obj file at runtime so my game users can make their own maps.

I am not looking to spend a cent on this, I have found one on the wiki (http://wiki.unity3d.com/index.php?title=ObjImporter)

So if someone would be able to show me how to use this script from javascript, it would be greatly appreciated

I have tried already using SendMessage but to no avail. I simply do not know where to start to achieve this.

Thanks!

EDIT: The code I have tried is this: var existing : GameObject;

 function Start () {
     
     var newGO : Mesh;
     
     var sc = gameObject.GetComponent("ObjImporter");
 
     existing.GetComponent(MeshFilter).mesh = sc.SendMessage("ImportFile", "test.obj");
 }

where existing is the gameobject i want to change the mesh, but it gives me a cannot convert void to unityengine.mesh.

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
1

Answer by whydoidoit · Feb 22, 2014 at 02:01 PM

So firstly you need to put that ObjImporter code in the Plugins folder for the project.

Next:

       var objImporter = new ObjImporter();
       existing.GetComponent(MeshFilter).mesh = objImporter.ImportFile("SomeFile");
Comment
Add comment · Show 3 · 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 secondry2 · Feb 23, 2014 at 12:47 AM 0
Share

Thanks for the reply! I seem to be getting pink models, in the project view they appear textured and if i drag them on to the scene they are textured, but with the importer they are pink, would you $$anonymous$$d giving it a shot at trying to import them? Do you reckon Im doing something wrong or the importer just doesnt support textures.

avatar image whydoidoit · Feb 23, 2014 at 05:53 AM 0
Share

Obj format doesn't support texturing. You would have to handle the materials yourself.

avatar image secondry2 · Feb 23, 2014 at 06:24 AM 0
Share

Ah ok thanks!

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

20 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

Related Questions

Using a function from another script 1 Answer

Acsessing a script in the project folder 1 Answer

making changes to 2dgameplay jumpfunctions 0 Answers

Call a function repeatedly while a boolean is true 3 Answers

Using Variables from Parent Class (And Instantiate) 1 Answer


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