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 Louis-N-D · Feb 17, 2015 at 05:31 PM · editoruvuvsleak

UV shifting script "leaks meshes" in editor

So, I'm using an edited version of a UV shifting script in order to shift UVs from within the editor. The idea is to use this script in order to recolour level features by shifting their UVs to other spots on an atlas containing many colour variations. The problem is the editor is telling me that I'm "leaking meshes" when using the script. Any ideas of how I could implement this differently in order to avoid the errors?

Here is the script:

 #pragma strict
 @script ExecuteInEditMode() 
 
 public var uOffset : float = 0.25f;
 public var vOffset : float = 0.25f;
 
 public var AddU : boolean = false;
 public var SubU : boolean = false;
 public var AddV : boolean = false;
 public var SubV : boolean = false;
 
 function Start()
 {
     this.enabled = false;
 }
 
     function Update()
     {
         if (AddU)
         {
             SetUVs(uOffset,0.0f);
             AddU = false;
         }
         if (SubU)
         {
             SetUVs(-uOffset,0.0f);
             SubU = false;
         }
         if (AddV)
         {
             SetUVs(0.0f,vOffset);
             AddV = false;
         }
         if (SubV)
         {
             SetUVs(0.0f,-vOffset);
             SubV = false;
         }
     }
 
 function SetUVs(u : float , v : float)
 {
     // Build the uvs 
     var uvs : Vector2[] = new Vector2[(GetComponent(MeshFilter) as MeshFilter).mesh.vertices.Length]; 
     uvs = (GetComponent(MeshFilter) as MeshFilter).mesh.uv; // Take the existing UVs 
 
 
     for (var i = 0 ; i < uvs.Length; i++) uvs[i] = Vector2 (uvs[i].x + u, uvs[i].y + v); // Offset all the UV's 
 
    // Apply the modded UV's 
     (GetComponent(MeshFilter) as MeshFilter).mesh.uv = uvs; 
 
 }
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
0

Answer by tanoshimi · Feb 17, 2015 at 05:38 PM

It would be helpful if you gave the exact error message but, according to http://www.west-racing.com/mf/?wp_super_faq=i-get-an-error-message-about-sharedmesh-leaking-when-i-add-a-modifier

"This is a false error that Unity gives to any system that alters a mesh in Edit Mode, so all systems that build or alter meshes while not in run mode will produce the error eg RageSpline, ezGUI etc. Rest assured there are no leaked meshes and nothing is actually wrong. The error does not happen during runtime."

Comment
Add comment · Show 2 · 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 Louis-N-D · Feb 17, 2015 at 09:59 PM 0
Share

"Instantiating mesh due to calling $$anonymous$$eshFilter.mesh during edit mode. This will leak meshes. Please use $$anonymous$$eshFilter.shared$$anonymous$$esh ins$$anonymous$$d. UnityEngine.$$anonymous$$eshFilter:get_mesh() ShiftUVs:SetUVs(Single, Single) (at Assets/Louis Assets/Scripts/ShiftUVs.js:46) ShiftUVs:Update() (at Assets/Louis Assets/Scripts/ShiftUVs.js:22)"

is the error I get in the editor. Also, the name of the mesg on which I use the UV shift changes to "NA$$anonymous$$E Instance". And if I remove the "this.enable = false" from the Start() function, then entering play mode and back and subsequently using the UV shift edit mode causes the word "Instance" to keep getting added on over and over, like : "NA$$anonymous$$E Instance Instance Instance" etc.

I get that it's "Not a real error" but it really does seem to be re-instantiating the mesh every time. At least every time I use it again after exiting play mode.

avatar image Louis-N-D · Feb 17, 2015 at 10:02 PM 0
Share

Oh, also, looks like I get this error when saving the scene "Cleaning up leaked objects in scene since no game object, component or manager is referencing them $$anonymous$$esh Block_4x2x4 Instance Instance has been leaked 1 times."

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

UV Image Map Animation 1 Answer

Memory Leak Adventures in Editor (3.4, lot of instantiated objects) 1 Answer

Voxel retexture problem 0 Answers

asking for uvs edit as u can see in console 0 Answers

Create planar UVs on procedurally generated mesh 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