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 · Aug 11, 2017 at 02:03 PM · unity 5renderingmaterialcomponentmaterial renderer

Unity 5.6 error UnityEngine.Component' does not contain a definition for `materials' and no extension method `materials' of type `UnityEngine.Component' could be found. Are you missing an assembly reference?

Here is my script and getting error please give me solution its urgent and I am making AA FPS pls help me

 /*
     SetRenderQueue.cs
  
     Sets the RenderQueue of an object's materials on Awake. This will instance
     the materials, so the script won't interfere with other renderers that
     reference the same materials.
 */
 
 using UnityEngine;
 
 
 [AddComponentMenu("Rendering/SetRenderQueue")]
 
 public class Render : MonoBehaviour {
     
     [SerializeField]
     protected int[] m_queues = new int[]{3000};
     
     protected void Awake() {
          Material [] materials = renderer.materials;
         for (int i = 0; i < materials.Length && i < m_queues.Length; ++i) {
             materials[i].renderQueue = m_queues[i];
         }
     }
 }

error

Assets/Scripts/Render.cs(20,37): error CS1061: Type UnityEngine.Component' does not contain a definition for materials' and no extension method materials' of type UnityEngine.Component' could be found. Are you missing an assembly reference?

Thanks in advance :) Urgent !!!

Comment
Add comment · Show 2
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 tanoshimi · Aug 11, 2017 at 02:50 PM 0
Share

Where are you assigning a value to renderer?

avatar image tanoshimi · Aug 11, 2017 at 03:52 PM 0
Share

$$anonymous$$eans ! :)

1 Reply

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by Bodhid · Aug 11, 2017 at 03:03 PM

change renderer in GetComponent<MeshRenderer> or GetComponent<Renderer>

Comment
Add comment · Show 3 · 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 · Aug 11, 2017 at 03:50 PM 0
Share

Can you give me script I didn`t understand ! Please ...

avatar image Bunny83 · Aug 11, 2017 at 04:20 PM 4
Share

In this line (which is the only one with the word "renderer"):

 $$anonymous$$aterial [] materials = renderer.materials;

replace renderer with GetComponent<Renderer>(). So the line reads:

 $$anonymous$$aterial [] materials = GetComponent<Renderer>().materials;
avatar image Bunny83 · Aug 12, 2017 at 01:09 AM 0
Share

Thanks a lot of .. ! :)

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

147 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Reflection bigger than actual gameobject. 0 Answers

Texture alpha doesn't scroll with offset 1 Answer

How to install new components in unity? 0 Answers

Rendering objects into another camera with a different material in HDRP 0 Answers

How to know if my Shader Graph is supported by the SRP Batcher? 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