Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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
2
Question by z0code0z · Jun 02, 2020 at 10:03 PM · outline

Quick Outline does not work with multiple materials

I am using the quick outline material on the unity asset store but it doesn't work with skinned mesh renderers that have multiple materials (only one material will be picked to be outlined)

I'm not totally sure how to fix it and would absolutely love if anyone could offer any guidance, thanks!

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

Answer by z0code0z · Jun 03, 2020 at 12:58 AM

I FOUND THE SOLUTION!

After hours of going through some information and other outline solutions, simply adding the following code in the Awake function of the Outline.cs (at the very top) will fix it, I am not totally sure how well some of the features work but the outline works perfectly from my tests.

         foreach (var skinnedMeshRenderer in GetComponentsInChildren<SkinnedMeshRenderer>())
         {
             if (skinnedMeshRenderer.sharedMesh.subMeshCount > 1)
             {
                 skinnedMeshRenderer.sharedMesh.subMeshCount = skinnedMeshRenderer.sharedMesh.subMeshCount + 1;
                 skinnedMeshRenderer.sharedMesh.SetTriangles(skinnedMeshRenderer.sharedMesh.triangles, skinnedMeshRenderer.sharedMesh.subMeshCount - 1);
             }
 
         }
 
         foreach (var meshFilter in GetComponentsInChildren<MeshFilter>())
         {
             if (meshFilter.sharedMesh.subMeshCount > 1)
             {
                 meshFilter.sharedMesh.subMeshCount = meshFilter.sharedMesh.subMeshCount + 1;
                 meshFilter.sharedMesh.SetTriangles(meshFilter.sharedMesh.triangles, meshFilter.sharedMesh.subMeshCount - 1);
             }
         }
 

Disclaimer, the second portion (involving meshfilter) was not tested but it should work the same as with the skinnedMeshRenderer

Comment
Add comment · Show 11 · 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 xmmikol · Jul 27, 2020 at 09:25 AM 0
Share

This code causes Unity to crash in the build version. Any idea how to fix that?

avatar image unity_gAMhN-EHnIqG0w xmmikol · Nov 13, 2020 at 03:19 PM 0
Share

it crashed also for me on build,I have no idea how to fix it.

avatar image Aspharon unity_gAMhN-EHnIqG0w · Jan 16, 2021 at 05:42 PM 0
Share

Comment out the meshFilter[i].shared$$anonymous$$esh.sub$$anonymous$$eshCount = meshFilter[i].shared$$anonymous$$esh.sub$$anonymous$$eshCount + 1; line, and it should work.

avatar image Balddog123 · Oct 01, 2020 at 12:05 AM 0
Share

I would use a for loop instead:

 Skinned$$anonymous$$eshRenderer[] skinned$$anonymous$$eshRenderer = GetComponentsInChildren<Skinned$$anonymous$$eshRenderer>();
         for (int i = 0; i < skinned$$anonymous$$eshRenderer.Length; i++)
         {
             if (skinned$$anonymous$$eshRenderer[i].shared$$anonymous$$esh.sub$$anonymous$$eshCount > 1)
             {
                 skinned$$anonymous$$eshRenderer[i].shared$$anonymous$$esh.sub$$anonymous$$eshCount = skinned$$anonymous$$eshRenderer[i].shared$$anonymous$$esh.sub$$anonymous$$eshCount + 1;
                 skinned$$anonymous$$eshRenderer[i].shared$$anonymous$$esh.SetTriangles(skinned$$anonymous$$eshRenderer[i].shared$$anonymous$$esh.triangles, skinned$$anonymous$$eshRenderer[i].shared$$anonymous$$esh.sub$$anonymous$$eshCount - 1);
             }
         }
 
         $$anonymous$$eshFilter[] meshFilter = GetComponentsInChildren<$$anonymous$$eshFilter>();
         for (int i = 0; i < meshFilter.Length; i++)
         {
             if (meshFilter[i].shared$$anonymous$$esh.sub$$anonymous$$eshCount > 1)
             {
                 meshFilter[i].shared$$anonymous$$esh.sub$$anonymous$$eshCount = meshFilter[i].shared$$anonymous$$esh.sub$$anonymous$$eshCount + 1;
                 meshFilter[i].shared$$anonymous$$esh.SetTriangles(meshFilter[i].shared$$anonymous$$esh.triangles, meshFilter[i].shared$$anonymous$$esh.sub$$anonymous$$eshCount - 1);
             }
         }
avatar image Ex6tra Balddog123 · Sep 15, 2021 at 06:48 PM 0
Share

Here is the repaired code incase someone needed it in the future

        SkinnedMeshRenderer[] skinnedMeshRenderer = GetComponentsInChildren<SkinnedMeshRenderer>();
          for (int i = 0; i < skinnedMeshRenderer.Length; i++)
          {
              if (skinnedMeshRenderer[i].sharedMesh.subMeshCount > 1)
              {
                  skinnedMeshRenderer[i].sharedMesh.subMeshCount = skinnedMeshRenderer[i].sharedMesh.subMeshCount + 1;
                  skinnedMeshRenderer[i].sharedMesh.SetTriangles(skinnedMeshRenderer[i].sharedMesh.triangles, skinnedMeshRenderer[i].sharedMesh.subMeshCount - 1);
              }
          }
  
          MeshFilter[] meshFilter = GetComponentsInChildren<MeshFilter>();
          for (int i = 0; i < meshFilter.Length; i++)
          {
              if (meshFilter[i].sharedMesh.subMeshCount > 1)
              {
                  meshFilter[i].sharedMesh.subMeshCount = meshFilter[i].sharedMesh.subMeshCount + 1;
                  meshFilter[i].sharedMesh.SetTriangles(meshFilter[i].sharedMesh.triangles, meshFilter[i].sharedMesh.subMeshCount - 1);
              }
          }
avatar image marcusdyrholm Ex6tra · Dec 14, 2021 at 01:37 PM 0
Share

I implemented this code and now every third or so time I hit play in unity, EnterPlaymode() hangs for 20 ish seconds and then Unity crashes. Precomputing outlines doesn't fix the issue. Any idea why this happens?

Show more comments
avatar image InteractivePie · Jun 28, 2021 at 10:55 AM 0
Share

Thanks for this! Really useful

avatar image stian01 · Jul 26, 2021 at 04:33 PM 0
Share

Thank you so much you saved my day

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

138 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 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 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 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 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 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 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

3DText Outline Shader 2 Answers

Drawing an outline around object 1 Answer

Unity's Outline shader - sharp edges 2 Answers

How to use the silhouetted outline shader from the wiki? 1 Answer

Object outline component 0 Answers


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