- Home /
Gizmo wont change color in certain project
I created a gizmo script that has a public color variable then in the ondrawgizmos I set the color to that variable. The intention is to have a color picker in the inspector to change the gizmo color. For some reason this does not work in my current project, I can set the gizmo color in my script to an exact color using Color.yellow etc and it will work. The weird thing is if I create a new empty project using the exact same script it works just fine, just not in the project I already have in progress. Any ideas on why this may be?
public class CubeGizmo : MonoBehaviour
{
public Vector3 centerOffset = new Vector3(0, 0, 0);
public Vector3 cubeSize = new Vector3(1.0f, 1.0f, 1.0f);
public Color color;
Vector3 origin;
public void OnDrawGizmosSelected()
{
Gizmos.color = color;
origin = transform.position + centerOffset;
Gizmos.DrawCube(origin, cubeSize);
}
}
Can you share the code where the change to Gizmos.color is applied?
When this is not working, what color is it using? Just white?
It will default to black in the editor and so will appear invisible for in the editor. I can then select different colors but it doesnt detect the color change at all. And again it is so strange if I put this exact same script in a new project it works just fine, i dont understand what is preventing it from working in my current project.
Answer by Adam-Mechtley · Jan 08, 2017 at 10:43 AM
In your comments above you stated
It will default to black in the editor and so will appear invisible for in the editor.
Do you mean it is just showing nothing in the scene then? The default value for a color field with no initialized value is (0, 0, 0, 0), which is of course transparent. Can you verify you have also set a non-zero alpha value when you use the color picker?
oh wow, yah the alpha was all the way down, so strange that it was defaulting to all the way up when I would bring that same script into a new project, any ideas why it would do that? Thank you again for your help!!! :)
Answer by mostlyhuman · Jan 08, 2017 at 10:24 AM
I guess we ran out of reply space, so I hadnt actually but I just now set it from black to red and when debugging it still shows black is assigned. [edit] actually red was assigned but red was not reflecting in the scene view of course.
Your answer
Follow this Question
Related Questions
Gizmos icons 0 Answers
Is it possible to change the implementation for the built-in move gizmo? 0 Answers
Drawing Ellipsoid 1 Answer
Why are my gizmos so dark? 1 Answer
Disable GUI controls without greying 0 Answers