{"id":666,"date":"2019-11-02T22:31:07","date_gmt":"2019-11-02T14:31:07","guid":{"rendered":"http:\/\/blog.coolcoding.cn\/?p=666"},"modified":"2020-09-27T17:05:02","modified_gmt":"2020-09-27T09:05:02","slug":"unity%e8%87%aa%e5%ae%9a%e4%b9%89inspector%e5%ad%97%e6%ae%b5%e6%98%be%e7%a4%ba%e5%90%8d%e7%a7%b0","status":"publish","type":"post","link":"https:\/\/blog.coolcoding.cn\/?p=666","title":{"rendered":"[Unity]\u81ea\u5b9a\u4e49Inspector\u5b57\u6bb5\u663e\u793a\u540d\u79f0"},"content":{"rendered":"\n<p>\u4e00\u3001\u65b0\u5efa\u8fd0\u884c\u65f6TitleAttribute.cs\u811a\u672c<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>using UnityEngine;\n\npublic class TitleAttribute : PropertyAttribute\n{\n    public string newTitle { get ; private set; }    \n    public TitleAttribute( string title )\n    {\n        newTitle = title ;\n    }\n}\n<\/code><\/pre>\n\n\n\n<p>\u4e8c\u3001\u65b0\u5efaEditor\u76ee\u5f55\u4e2d\u7684\u811a\u672c<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>using UnityEngine;\nusing UnityEditor;\n\n[CustomPropertyDrawer(typeof(TitleAttribute))]\npublic class TitleAttributeDrawer : PropertyDrawer\n{\n    public override void OnGUI( Rect position, SerializedProperty property, GUIContent label )\n    {\n        EditorGUI.PropertyField(position, property, new GUIContent( (attribute as TitleAttribute).newTitle ));\n    }\n}<\/code><\/pre>\n\n\n\n<p>\u4e09\u3001\u4f7f\u7528<\/p>\n\n\n\n<p>\u5728\u9700\u8981\u7528\u7684\u5730\u65b9\u6dfb\u52a0[Title]\u6807\u8bb0\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>    [Title(\"\u89d2\u8272ID\")]\n    public string actorId;<\/code><\/pre>\n\n\n\n<p>\u56db\u3001\u6548\u679c<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"323\" height=\"28\" src=\"http:\/\/blog.coolcoding.cn\/wp-content\/uploads\/2019\/11\/15727052998027.png\" alt=\"\" class=\"wp-image-671\" srcset=\"https:\/\/blog.coolcoding.cn\/wp-content\/uploads\/2019\/11\/15727052998027.png 323w, https:\/\/blog.coolcoding.cn\/wp-content\/uploads\/2019\/11\/15727052998027-300x26.png 300w\" sizes=\"(max-width: 323px) 100vw, 323px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001\u65b0\u5efa\u8fd0\u884c\u65f6TitleAttribute.cs\u811a\u672c \u4e8c\u3001\u65b0\u5efaEditor\u76ee\u5f55\u4e2d\u7684\u811a\u672c \u4e09\u3001\u4f7f\u7528 \u5728\u9700\u8981\u7528\u7684\u5730 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[18],"_links":{"self":[{"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/posts\/666"}],"collection":[{"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=666"}],"version-history":[{"count":2,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/posts\/666\/revisions"}],"predecessor-version":[{"id":672,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/posts\/666\/revisions\/672"}],"wp:attachment":[{"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=666"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=666"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=666"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}