- Home /
Question by
Rustam-Ganeyev · Apr 01, 2013 at 04:13 AM ·
custom editorproperty
Property is being reset in play mode with custom editor
howdy?
I have a class: using UnityEngine; using System.Collections; using UnityArabicSupport;
[ExecuteInEditMode]
public class ArabicTextMesh : MonoBehaviour
{
[SerializeField]
private string text;
public string Text {
get { return text; }
set {
text = value;
if (value != null)
gameObject.GetComponent<TextMesh> ().text = ArabicFixer.Fix (text);
}
}
}
and have custom editor for it:
using UnityEngine;
using UnityEditor;
using System.Collections;
using UnityArabicSupport;
[CustomEditor(typeof(ArabicTextMesh))]
public class ArabicTextMeshEditor : Editor {
private ArabicTextMesh _target;
void OnEnable()
{
_target = (ArabicTextMesh)target;
}
public override void OnInspectorGUI ()
{
_target.Text = EditorGUILayout.TextField("Text", _target.Text);
}
}
It shows ok on inspector, but every time I start playing, unity resets text value. It seems that text field is not being serialized. What's wrong with it? How to fix it?
Comment
Best Answer
Answer by Tarlius · Apr 01, 2013 at 06:12 AM
You are probably looking for EditorUtility.SetDirty
Your answer