Somehow I am missing the preview colors

Hello everyone,

So I followed the lecture a few times over and went into the GitLab repository to find where I may have gone wrong, but I can’t seem to find it. Even after copy/pasting in a last ditch effort I still don’t seem to be getting the green/red preview colors being displayed. Aside from that, the logic for where a building can and cannot be placed seems to be working properly. Any recommendations would be greatly appreciated!

Hi there, can you please share a picture of what is happening? The building preview’s are not changing colour when you can or cannot place the building? This is most likely do to something in the editor. Are you using the same assets as the lecturer? Maybe show the building preview setup in the hierarchy and the inspector. Try and trace if it’s getting hold of the right renderer and successfully changing it’s colour.

Sorry I didn’t include a photo in the original post. What I’m referring to is that my buildings (which are using a blue material) do not turn red/green at all, but the logic for where is a valid building spawn point is correct. The assets being used should be the same as the lectures instructed. I have also double checked to see that the the script is indeed tracing to the buildingRendererInstance and “should” change the color to red/green accordingly.

Whatever the issue is, it seems to hold true with the following lecture for team colors.

Hi there,
Are there any errors in the console when it tries to change the colour?

I think just upload your project here and I can take look if you’d like. This seems like it’s going to take some debugging.
https://gdev.tv/projectupload

I just uploaded my project from the link you provided, thank you! I hate to make it into a debugging hassle. The only errors I am getting in the console are ones relating to the player that have been there for several lectures and are said to be addressed once we create the lobby. Thank you for your time!

Hi there, thanks for uploading your project.

Fortunately, the mistake was not yours at all.

In the BuildingButton.cs script we set the color of the renderer using a string:
buildingRendererInstance.material.SetColor("_BaseColor", color);

Depending on the version of unity you are using this will need to be changed from “_BaseColor” to just “_Color”. When I made this change in your project on my computer it worked. Let me know if it works for you.
buildingRendererInstance.material.SetColor("_Color", color);

This works perfectly! Thank you so much for taking the time to look into this for me! I’m not sure when my unity may have updated if that is indeed the case but using “_Color” works for me.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms