- Home /
Assigning material color with GetPixelBilinear iOS
I'm trying to make a color picker to change a GameObject's material color in a iOS app. From what I've gathered the best way to do this would be to grab a color from a texture and assign it to the material of the GameObject I want to modify.
I found this code block which will sample a color from clicking on a texture using GetPixelBilinear..
if (GUI.RepeatButton(new Rect(beginX, beginY, dimX, dimY), colorSpectrumTexture, GUI.skin.GetStyle("ColorPickerStyle"))) {
Vector2 pickpos = Event.current.mousePosition;
Vector2 coords = new Vector2((pickpos.x - beginX) / dimX, -(pickpos.y - beginY) / dimY);
Color color = colorSpectrum.GetPixelBilinear(coords.x, coords.y);
}
I need to convert this to be iOS friendly still, which I may have some struggle with but I should post that as a seperate question.
My question is how to assign the value sampled from the above code block to a GameObject's material.
Your answer
Follow this Question
Related Questions
Material doesn't have a color property '_Color' 4 Answers
Changing two different objects renderer colour 1 Answer
Color wrong on IOS device 1 Answer
iOS simple shader does not work 1 Answer
Change skybox color via script? 0 Answers