Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Game Development Materials in Unity Scripting Materials Animating Emissive Colors

Ericka Marable
Ericka Marable
1,953 Points

Obsolete Code - Need the current code for the Emissive Materials section.

Here is the current error message: DynamicGI.UpdateMaterials (rend); 'UnityEngine.DynamicGI.UpdateMaterials(UnityEngine.Renderer)' is obsolete: 'DynamicGI.UpdateMaterials(Renderer) is deprecated; instead, use extension method from RenderedExtensions: 'renderer.UpdateGIMaterials()' (UnityUpgradable).'

I am assuming that I need to define the class in the top section where using UnityEngine; is located but I don't know what that library is. Please advise.

Hi, Ericka.

The solution is actually quite simple, and I just figured it out. Simply ignore the old UpdateMaterials code; that's obsolete. In the new versions of Unity, they've made it so each -renderer- updates its GI materials. If you read that error message I think you'll get what I mean. Here is the code that fixes it, but try to see if you can figure it out from the error message first.

At the end of the Update() function:

// Use our "Renderer" to call its own "UpdateGIMaterials()" method

rend.UpdateGIMaterials();