- Home /
Enum change visible in editor?
I have an object with an enum that has {Red,Green,Blue}
And depending on which enum is picked, the color of the object changes.
It works fine ingame, the object changes color and all.
The problem is that in the editor no matter what enum I pick, the color will not change.
In the update I simply did if enum = green, then material = green.
I tried to use [ExecuteInEditMode] but it didn't seem to work.
I really need to be able to see the changing color in the editor itself, otherwise building the level becomes hard.
using UnityEngine; using System.Collections;
public class colorChanger : MonoBehaviour {
public enum _color
{
red,
green,
blue
}
public _color Colors = _color.red;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Colors == _color.blue)
renderer.material.color = Color.blue;
}
}
Can you edit your post and include your code? (If you actually wrote 'if enum = green', that might be part of the problem.)
No that was an example. The code works 100% fine in the game, just not in the editor.
(edit: tidied up code formatting -- note that is not for code, use the 0110 button to indent with spaces)
Answer by Johan 4 · Mar 04, 2011 at 02:29 AM
Execute in edit mode had to go to very top for it to work, fixed
Your answer

Follow this Question
Related Questions
How to provide custom descriptions for EditorGUI.EnumPopup? 1 Answer
Restrict which types of an Enum can be selected in inspector. 5 Answers
Dynamic serialized fields based on enum 0 Answers
Assigned enum value changes when a new type is added to the enum 2 Answers
Custom editor not editing? 1 Answer