Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 inum76 · Apr 28, 2016 at 05:14 AM · scripting problemarraysizerenderer

Mesh Renderer Matereal Aray reduce?

Ok, the problem. The description of it is a long one.

Fist off, all of this is going on in run-time.

I am using a script that uses a boolean operation on two objects, each with their own separate materials.

What it does is something like a CSG subtraction operation, only it cuts into the faces of object 1 in the shape of object 2, but instead of leaving behind the faces of object two to fill in the hole as a solid hole with the material of object 2 and its left over mesh, all of object 2 is removed, leaving an empty hole in the mesh of object 1. This is what I want. And it works great! But with one exception.

Object 1's mesh now shows to have two submeshes (just as the regular CSG subtraction operation would create), and the Mesh Renderer shows to have 2 in the materials array size with two elements in it. One for each material form each object. Even though object 2 is supposed to be subtracted completely.

Problem, the actual mesh to submesh 2 in object 1 is missing and I get a repeating srcIB error in my Console window that counts up quickly.

Now if I go into the the inspector during run time, and set in the Mesh Renderer's element 2 spot to have "None" for material, or just set the Mesh Renderer's material array size to just 1, either option stops the srcIB error.

OK, so what I want to do should be very simple, but I have yet to find an answer. It is to somehow pullout a copy of the Mesh Randerer's material array in object 1, and change it to have only 1 element/ or that is one index, then pass in the copied Mesh Randerer's material array to change it to have just the 1 index to stop the srcIB error I keep getting during run-time.

I just don't know how to do that operation yet?

To pass out a copy of the Mesh Renderer, change/or create the material array index in the copy to just 1, with the material in index 1 still intact, then set object 1's Mesh Renderer to that copy.

How does one do this in a run-time script? It is so easy to change Mesh Renderer material array index count in the inspector, but not easy at all to do in script, as I found.

Does anyone have the very solution to change the array size of the Mesh Renderer's materials list shown in the inspector to a gameobject, but do it with a C# script?

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

0 Replies

· Add your reply
  • Sort: 

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Trying to change character skins at the push of a button. C# 1 Answer

Limiting size of data structures in editor 1 Answer

Weapon switching with an animator and script. 0 Answers

Help with editing array from inside functions for PID controller (C#)[Fixed] 1 Answer

IndexOutOfRange Issue 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