- Home /
Can I access the color preset by code?
Is there a way I can choose the color preset that can be found in the inspector (at the bottom when you click on the material's color) by code?
On windows they are stored in at file at location:
C:\Users\&USERNA$$anonymous$$E&\AppData\Roa$$anonymous$$g\Unity\Editor-x.x\Preferences\Presets
you can then use a YA$$anonymous$$L parser (I think) to get what you want my file looks like this:
%YA$$anonymous$$L 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &1
$$anonymous$$onoBehaviour:
m_ObjectHideFlags: 4
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 1
m_Script: {fileID: 12323, guid: 0000000000000000e000000000000000, type: 0}
m_Name:
m_EditorClassIdentifier:
m_Presets:
- m_Name:
m_Color: {r: 1, g: 1, b: 1, a: 1}
- m_Name:
m_Color: {r: .397058845, g: .0759083107, b: .0759083107, a: 1}
Oh its good to know that there is a way to access it... But I don't know what yaml parser is our any of the code above or how to get it :(
Answer by Mudman2999 · Dec 05, 2013 at 10:44 PM
If you are talking about what I think you are then you just create a new script(this is in C#) with gameObject.renderer.material.color = Color.your color; inside the main function or if you want to change it using letters then you can put it in update. the color must be a valid color though, so they don't all work.
Your answer
Follow this Question
Related Questions
Recoloring animated sprites [Solved] 2 Answers
How to change color of collider 1 Answer
2D Animation does not start 1 Answer
How to alternate images in 2d unity 0 Answers