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
0
Question by Myhijim · Jul 26, 2012 at 10:53 AM · meshresources.loadmeshfilter

Assigning a mesh through script

Hey all i have a problem with my assigning mesh script, the idea is that on awake it will change the mesh to the appropriate 'weapon' mesh, however there is something wrong.

This script is run on awake

 switch(pickupName)
  {
  case "XM8": 
  var mesh : Mesh = Resources.Load("Plane002",Mesh);
  GetComponent(MeshFilter).mesh = mesh;
  break;
  }

However it will only make the mesh invisible and when the gameobject is viewed in the inspector the MeshFilter is set to "None".

I am certain that "Plane002" is a mesh, so what is going wrong?

Any help is greatly appreciated ~Myhijim

Comment
Add comment · Show 7
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 Kryptos · Jul 26, 2012 at 11:48 AM 0
Share

Did you make sure that the mesh Plane002 is inside a resource folder (i.e. a folder named "Resources")?

avatar image Myhijim · Jul 26, 2012 at 11:58 AM 0
Share

I have it within a folder named "Weapons" in the project panel... Am I just being thick?

avatar image Myhijim · Jul 26, 2012 at 12:12 PM 0
Share

Ah indeed I am bein thick, it needs to be within a folder in the assets called "Resources" thank you for pointing that out..... Is there any way to load from a different fder?

avatar image Meltdown · Jul 26, 2012 at 12:15 PM 0
Share

It is possible but loading from Resources folder is easiest and the recommended way to do so.

avatar image Kryptos · Jul 26, 2012 at 12:20 PM 1
Share

Yes you can ;) The path will then be "FolderName/AssetName".

For example, if your hierarchy is like that :

 - Resources
     |- Props
         |- Weapons
             |- Plane002.asset

Then the path is "Props/Weapons/Plane002".

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by Kryptos · Jul 26, 2012 at 12:36 PM

You have to make sure that mesh Plane002 is inside a resource folder (i.e. a folder named "Resources")?

Can I load from folders within the resource folders?

Yes you can ;-) The path will then be "FolderName/AssetName".

For example, if your hierarchy is like that :

 - Resources
     |- Props
         |- Weapons
             |- Plane002.asset

Then the path is "Props/Weapons/Plane002". Thus the correct code would be:

 var mesh : Mesh = Resources.Load("Props/Weapons/Plane002", Mesh);

Comment
Add comment · Show 1 · 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 KEric · Feb 20, 2014 at 03:02 PM 0
Share

And what if within the model file (modo's *.lxo) I have several meshes and I want to fetch particular one? Triggering Resources.Load("XXX", $$anonymous$$esh) returns the first submesh of XXX model. Adding "XXX/submesh" returns no mesh at all

ANSWER: Those sub-meshes that I've created in $$anonymous$$odo Luxology ('n' keyboard shortcut) can be accessed in the following way:

 Transform model = Resources.Load<GameObject>("$$anonymous$$odel").transform;
 Transform sub$$anonymous$$esh = rocketRes.FindChild("Sub$$anonymous$$esh01"); // etc...

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

10 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

Related Questions

Procedural array of meshes problem / solved 1 Answer

Using MeshFilter.mesh with static ground plane makes object turn into a plane. 0 Answers

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

How to convert UV position to texture atlas pos and reapply to UV 0 Answers

Convex volumetric 3d object from points (vertices) 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