{"id":1571,"date":"2016-07-27T01:07:24","date_gmt":"2016-07-26T17:07:24","guid":{"rendered":"http:\/\/www.clonefactor.com\/wordpress\/?p=1571"},"modified":"2016-07-27T01:27:16","modified_gmt":"2016-07-26T17:27:16","slug":"editor-notes","status":"publish","type":"post","link":"https:\/\/www.clonefactor.com\/wordpress\/program\/unity3d\/1571\/","title":{"rendered":"\u4fbf\u689d\u7d19, editor notes"},"content":{"rendered":"<p>\u60f3\u5230\u4e00\u500b\u6709\u8da3\u7684\u5beb\u6cd5, \u4f86\u628a\u7269\u4ef6\u4e0a\u7684\u63d0\u793a\u5f04\u5f97\u7f8e\u89c0\u4e00\u9ede.<br \/>\n\u76f4\u63a5\u628a Unity3D \u7684 Hotkey \u62ff\u4f86\u73a9\u4e86.<\/p>\n<p>Result:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-1572\" src=\"http:\/\/www.clonefactor.com\/wordpress\/wp-content\/uploads\/2016\/07\/note_editor.gif\" alt=\"note_editor\" width=\"498\" height=\"646\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>Note.cs<\/p>\n<pre class=\"brush:csharp\">using UnityEngine;\r\n\r\nnamespace Kit\r\n{\r\n\tpublic class Note : MonoBehaviour\r\n\t{\r\n\t\tprivate enum eMessageType\r\n\t\t{\r\n\t\t\tNone = 0,\r\n\t\t\tInfo = 1,\r\n\t\t\tWarning = 2,\r\n\t\t\tError = 3\r\n\t\t}\r\n\t\t[SerializeField] eMessageType type = eMessageType.Info;\r\n\t\t[SerializeField] string note;\r\n\t}\r\n}<\/pre>\n<p>NoteEditor.cs<\/p>\n<pre class=\"brush:csharp\">using UnityEngine;\r\nusing UnityEditor;\r\n\r\nnamespace Kit\r\n{\r\n\t[CustomEditor(typeof(Note))]\r\n\tpublic class NoteEditor : Editor\r\n\t{\r\n\t\tSerializedProperty noteProp, typeProp;\r\n\t\tvoid OnEnable()\r\n\t\t{\r\n\t\t\tnoteProp = serializedObject.FindProperty(\"note\");\r\n\t\t\ttypeProp = serializedObject.FindProperty(\"type\");\r\n\t\t}\r\n\t\tpublic override void OnInspectorGUI()\r\n\t\t{\r\n\t\t\tif (string.IsNullOrEmpty(noteProp.stringValue))\r\n\t\t\t\tEditorGUILayout.HelpBox(\"Modify : Ctrl + Shift + A\", MessageType.Info);\r\n\t\t\telse\r\n\t\t\t\tEditorGUILayout.HelpBox(noteProp.stringValue, (MessageType)typeProp.enumValueIndex);\r\n\r\n\t\t\tif (!((Component)target).gameObject.activeSelf)\r\n\t\t\t{\r\n\t\t\t\tEditorGUI.BeginChangeCheck();\r\n\t\t\t\tEditorGUILayout.PropertyField(typeProp);\r\n\t\t\t\tnoteProp.stringValue = EditorGUILayout.TextArea(noteProp.stringValue, GUILayout.MinHeight(100f), GUILayout.ExpandHeight(true));\r\n\t\t\t\tif (EditorGUI.EndChangeCheck())\r\n\t\t\t\t{\r\n\t\t\t\t\tserializedObject.ApplyModifiedProperties();\r\n\t\t\t\t\tserializedObject.Update();\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u60f3\u5230\u4e00\u500b\u6709\u8da3\u7684\u5beb\u6cd5, \u4f86\u628a\u7269\u4ef6\u4e0a\u7684\u63d0\u793a\u5f04\u5f97\u7f8e\u89c0\u4e00\u9ede. \u76f4\u63a5\u628a Unity3D \u7684 Hotkey \u62ff\u4f86 &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[20,43],"class_list":["post-1571","post","type-post","status-publish","format-standard","hentry","category-unity3d","tag-editor","tag-unity3d-2"],"_links":{"self":[{"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/posts\/1571","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/comments?post=1571"}],"version-history":[{"count":0,"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/posts\/1571\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/media?parent=1571"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/categories?post=1571"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/tags?post=1571"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}