Custom Editor not working :(

I’m started to work with custom editors for a class called StoryEvent. each StoryEvent needs to have a Category. As the Editor intro ( Unite 2011 - Intro to Editor Scripting - YouTube) advised, I use SerializedObject. However, the script doesn’t work. I know have a custom editor with only a category field. but when I drag my category it will not be added. what do I do wrong?

using UnityEditor;
using System.Collections;

[CustomEditor(typeof(StoryEvent))]
public class StoryEventEditor : Editor
{
		private SerializedObject _object;
		private SerializedProperty _category;

		void OnEnable ()
		{
				_object = new SerializedObject (target);
				_category = _object.FindProperty ("category");
		}
	
		// Update is called once per frame
		public override void OnInspectorGUI ()
		{
				_object.Update ();
				Category c = (Category)_category.objectReferenceValue;
				EditorGUILayout.ObjectField ("Category", c, typeof(Category), false);
				if (GUI.changed) {
						_category.objectReferenceValue = c;
				}
				//EditorUtility.SetDirty (_object);
				_object.ApplyModifiedProperties ();
		}
}

You are not assigning the value returned to anything when you call EditorGUILayout.ObjectField.

But since it’s a SerializedProperty you can use EditorGUILayout.PropertyField instead:

EditorGUILayout.PropertyField(_category);

It will pick an appropriate field for the type.

On another note, why call Update() directly? If you want the object to update while in editor you can use ExecuteInEditMode

Ha…

how you edit whene your editor not working?

Only restart your computer or log off it!!!it works.