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 adrenak · Mar 25, 2012 at 03:20 AM · textureuvatlascombinechildren

flickering textures on using combinechildren

Hi! I have a texture atlas, which has several window textures. I wanted to have a single FBX plane which can display a rectangular part of the atlas, so as to show a single window. So I wrote this script :

 var ulX : float;
 var ulY : float;
 var lrX : float;
 var lrY : float;
 
 function Start () {
         
     var dmesh : Mesh = GetComponent(MeshFilter).mesh;
     var dvertices : Vector3[]  = dmesh.vertices;
         
     var uvs : Vector2[] = new Vector2[dvertices.Length];
     
     uvs[0] = Vector2(ulX,ulY);
     uvs[1] = Vector2(ulX,lrY);
     uvs[2] = Vector2(lrX,lrY);
     uvs[3] = Vector2(lrX, ulY);
     
     dmesh.uv = uvs;
     
 }

This script worked fine, until I thought that since they all are using the same material, they can be combined to get better performance. I created an empty gameobject and made all the meshes its children, and used combinechildren. But the meshes continued to show the original atlas texture instead of the rectangular parts that they were supposed to show.

I noticed that the meshRenderer of the meshed were getting disabled on runtime. So while the game was still playing in the editor I enabled it, but then, as the camera moved, the texture flickered between the atlas and the part that they were supposed to show.

Thanks for reading. -Vatsal

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

Answer by AtomicHippo · Mar 25, 2012 at 11:33 AM

If you're running combine children in Start(), there's a fair chance that it's executing before your above script has applied the new mesh uvs, thus displaying the original texture coordinates.

As for the disabled mesh renderers on your original objects, that's intended behavior. Combine children duplicates all child meshes into a larger mesh, then disables the mesh renderer on all original objects (though leaving the gameobject active, and still alowing them to be remapped via your script). When you reactivate one of these mesh renderers during runtime, you get 2 objects in the same place which will flicker on the screen as unity doesn't know which one to render ontop, the combined mesh with the original uvs, or the single object with the modified ones.

If this is the problem, putting a small delay/yield in the start function of your combine children script should work, to make sure that your objects are remapped before they're combined.

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 adrenak · Mar 28, 2012 at 09:49 AM 0
Share

Thanks a lot, that worked! I made added all the meshes into an empty gameobject and added the combine children script during runtime.

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

Assigning UV Map to model at runtime 0 Answers

Assigning UV coords, from texture atlas. Losing texture uv accuracy at distance. 0 Answers

Automatic mesh combine and texture atlasing 4 Answers

How to get correct UVs for sprite in a Unity Sprite Packer-packed atlas? 0 Answers

SkinnedMeshRenderer offset UVs to match texture atlas? 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