• 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 ovechkin1308 · Jun 07, 2011 at 08:48 PM · meshobjectmeshfilterfilter

Mesh Filter

I want to change the mesh of my object by script. I have different object that the player will can choose with a menu.

How I can change the mesh filter by script. Like if the player press B change the mesh filter by Ball 2 instead of ball 1

Comment
Add comment · Show 3
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 Chris D · Jun 09, 2011 at 10:11 PM 0
Share

@ovechkin1308 and @Retribution : try to keep your comments out of the answer area or attached to the answer that they're referencing. If you need to change the body of an answer, you can edit it.

At the moment this question's thread is very tough to follow and that is likely to hamper anyone else trying to understand what's going on.

avatar image Retribution · Jun 10, 2011 at 02:15 PM 0
Share

Sorry ChrisD. I'm new to Unity Answers, but I'll try to keep the posts cleaner in the future.

avatar image Chris D · Jun 10, 2011 at 03:12 PM 0
Share

No worries. Everyone was new at some point and, unfortunately, there isn't really a FAQ or guide to posting up for the new site yet :(

8 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by ovechkin1308 · Jun 09, 2011 at 09:45 PM

I don't very understand your last answer.

If I understood well, I make a script for my menu that contain that :

var targetSphere : gameObject; var meshToUse : MeshFilter;

targetSphere = GameObject.Find(" ")

// on button click targetSphere.GetComponent(MeshFilter).mesh = meshToUse;

After I use dontdestroyonload for what ?

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 Retribution · Jun 09, 2011 at 10:00 PM

You can use DontDestroyOnLoad(gameObject) to specify a gameObject to save when you load your next level. So you can use DontDestroyOnLoad(--your gameObject that holds your menu script--) so you can transfer your saved variables to the next scene.

Alternatively, you can use something like DontDestroyOnLoad(rememberScript.gameObject) and make a gameObject called 'rememberScript' with a script attached that only holds the MeshFilter you've selected.

No matter how you go about it, you're going to want to do this:

  • Save your selected MeshFilter in a variable

  • Use DontDestroyOnLoad(gameObject) to save the gameObject that has your script attached that is holding onto your MeshFilter choice

  • Once your next scene loads, you'll want to select your saved gameObject and access the MeshFilter

  • Place your MeshFilter you selected from your menu onto the gameObject you desire

Check the script reference page I posted for DontDestroyOnLoad to see how its used. You can simply call it from a Start() or Awake() function to be sure it won't be deleted.

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 simar88 · Jul 07, 2012 at 03:46 PM

Hi everybody! I'm an italian student and i'm using the mesh filter in my script to change the mesh of my object. Now i've a simple object with the mesh of the Cylinder, present in the unity's library. I've understood that if I want to change the mesh i've to use this process:

 var mesh : Mesh = new Mesh();
     GetComponent(MeshFilter).mesh = mesh;

In this case my object will disappear because variable mesh is empty. This is ok.

My 2 questions are:

1-How i can set my mesh value equal to the cube that is in unity's default mesh?

2-How i can pass to my mesh variable the mesh of a 3DS model that i've imported in my assets folder? I suppose that i've to use `Resources.Load("name.path")`, but i'm not sure of this.

I hope that my english will be understandable. Thanks in advance, Simone

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
  • ‹
  • 1
  • 2

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Generated Mesh is partially rendered, but shown correctly in scene view 1 Answer

Combine multiple mesh entities to be exported as obj 1 Answer

Unity won't show my programatically created Mesh(A Simple Triangle) 2 Answers

how do i make that only triggers a specific object 1 Answer

How do I export GameObject (including child sub-object) to .obj file? 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