[Pictures Included] Change colour of a blurred Object Issue?
Hi, I created an image using Photoshop Gaussian blur. I am trying to change the colour of it using a script. But whenever I do that, the picture becomes kind of pixelated [Image Included]. The code I am using to change the colour is -
Color[] primaryColor = new Color[1]; Color[] secondaryColor = new Color[1]; primaryColor[0] = new Color(255f,0f,0f,255f); secondaryColor[0] = new Color(255f,255f,255f,255f); topRender.material.color = primaryColor[Random.Range(0, 1)]; bottomRender.material.color = secondaryColor[Random.Range(0, 1)];
Note: When I manually change the colour from the Renderer in Unity, this does not happen.
These are just the snaps of the code. I am putting them in an array because I am trying to randomize the colour of the object.
@dabomb_labs - Please format your code, so it is readable. Use the code icon and paste your code there
Answer by eses · Aug 30, 2018 at 06:04 PM
Hi @dabomb_labs
Check the manual: https://docs.unity3d.com/ScriptReference/Color.html
There it says, that colors go from 0-1. So red 255 is 1, not 255 and so on.
There is also Color32 but you are not using it.
To me it seems like that as you have alpha value, setting color to 255 will just push the pixel values near transparent towards opaque.
So instead of:
var col = new Color(255f,0f,0f,255f);
Do this:
Color col = new Color(1f,0,1f);
Your answer
Follow this Question
Related Questions
Render.material.color doesnt work 1 Answer
OnMouseEnter and OnMouseExit for multiple materials 0 Answers
Renderer error 0 Answers