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 jeffpk · May 01, 2012 at 01:15 AM · importmaterialsbatchingcollada

Collada Import and shared materails

I'm importing a whole bunch of models that are collada. A lot of them share textures. I set the importer to look in the entire project to find materials. Nonetheless at run time it seems like all models are using instances of the materails rather then the materials themselves and that this is preventing batching.

How can I get Unity to share materials across these imported models??

Comment
Add comment · Show 4
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 jeffpk · May 01, 2012 at 01:21 AM 0
Share

I should add that there are hundreds of them. Individually setting them in the editor is otu of the question. I did try to make prefabs from them via a script-- and it crashed Unity which seemed unable to handle converting such a large number to prefabs.

avatar image Ampler Games · May 01, 2012 at 01:58 AM 0
Share

Is it posible for you to convert those models to FBX files, because I have tried to use collada before and it just doesn't work well. So try that and let me know how it goes:)

avatar image jeffpk · May 01, 2012 at 07:11 PM 0
Share

FBXs show exactly the same symptoms

avatar image Ampler Games · May 01, 2012 at 11:07 PM 0
Share

What program are you using to make all the models?

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by jeffpk · May 01, 2012 at 11:25 PM

I'm not. They are existing data I am ripping and recoding. Im doing the collada trans-coding myself with a program I wrote.

I can modify the collada pretty freely if that would help.

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 jeffpk · May 02, 2012 at 07:01 PM

I ended up having to force the textures to be shared at runtime. As i instance each object I submit it to this class which forces like named materials to be shared. Now dynamic batching works.

 using UnityEngine;
 using System.Collections.Generic;
 
 public static class MaterialsCache  {
     static private Dictionary<string,Material> matDict = new Dictionary<string, Material>();
     public static void UsedSharedMaterials(GameObject obj){
         Renderer[] renderers = obj.GetComponentsInChildren<Renderer>();
         foreach(Renderer rend in renderers){
             Material mat = rend.material;
             if (matDict.ContainsKey(mat.name)){
                 mat = matDict[mat.name];    
             } else {
                 matDict[mat.name] = mat;    
             }
             rend.material=mat;
         }
     }
     
 }
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

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

COLLADA import with textures 3 Answers

Collada import material Main Colors 0 Answers

Shader / Material Refreshing, AssetBundles, and dynamic batching issues 0 Answers

Do I have to manually assign every texture to material? 0 Answers

How I can import SketchUp into Unity with texture? 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