Unity中,保存在OnInspectorGUI中改变的值

using UnityEngine;
using System.Collections;
using UnityEditor;

[CustomEditor( typeof( MessageLog ) )]
public class MessageLogEditor : Editor {
    public override void OnInspectorGUI() {
        MessageLog msgLog = (MessageLog)target;

        msgLog.IsLogC2SMessage = EditorGUILayout.Toggle( "Print C2S message", msgLog.IsLogC2SMessage );
        msgLog.IsLogS2CMessage = EditorGUILayout.Toggle( "Print S2C message", msgLog.IsLogS2CMessage );
     // 保存上面Toggle设置值 if ( GUI.changed ) { EditorUtility.SetDirty( target ); } } }

 

posted @ 2017-03-08 14:25  Mr. Oy  阅读(2533)  评论(0)    收藏  举报