{"id":126,"date":"2014-04-28T20:52:03","date_gmt":"2014-04-28T11:52:03","guid":{"rendered":"http:\/\/naochang.me\/?p=126"},"modified":"2021-10-17T18:52:21","modified_gmt":"2021-10-17T09:52:21","slug":"propertydrawer","status":"publish","type":"post","link":"https:\/\/stacstar.jp\/blog\/?p=126","title":{"rendered":"PropertyDrawer"},"content":{"rendered":"<p>\u30a4\u30f3\u30b9\u30da\u30af\u30bf\u306b\u72ec\u81ea\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u5c5e\u6027\u3092\u4f5c\u308c\u308b\u6a5f\u80fd\u3092\u8a66\u3057\u3066\u307f\u305f\u3002<br \/>\n\u30b9\u30af\u30ea\u30d7\u30c8\u5358\u4f4d\u3067\u62e1\u5f35\u3059\u308bCustomEditor\u3068\u3001\u30d7\u30ed\u30d1\u30c6\u30a3\u5358\u4f4d\u3067\u62e1\u5f35\u3059\u308bPropertyDrawer\u304c\u3042\u308b\u3089\u3057\u3044\u3002<\/p>\n<p>\u4eca\u56de\u306f\u4e0b\u8a18\u306e\u30b5\u30a4\u30c8\u306ePropertyDrawer\u3067\u3084\u308b\u3084\u308a\u65b9\u3092\u3084\u3063\u3066\u307f\u305f\u3002\u3068\u304f\u306b\u30a2\u30ec\u30f3\u30b8\u306f\u306a\u304f\u305d\u306e\u307e\u307e\u3067\u3059\u3002\u3002<br \/>\n<a href=\"http:\/\/qiita.com\/kyusyukeigo\/items\/8be4cdef97496a68a39d\" title=\"Qiita | \u81ea\u5206\u3060\u3051\u306ePropertyDrawer\u3092\u4f5c\u308d\u3046\uff01\" target=\"_blank\" rel=\"noopener noreferrer\">Qiita | \u81ea\u5206\u3060\u3051\u306ePropertyDrawer\u3092\u4f5c\u308d\u3046\uff01<\/a><\/p>\n<p>\u3082\u3046\u5c11\u3057\u8a73\u3057\u3044\u5185\u5bb9\u306f\u3053\u3061\u3089\u306e\u30b9\u30e9\u30a4\u30c9\u306b\u3042\u308a\u307e\u3059\u3002<br \/>\n<iframe loading=\"lazy\" src=\"http:\/\/www.slideshare.net\/slideshow\/embed_code\/32294734\" width=\"597\" height=\"486\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\" style=\"border:1px solid #CCC; border-width:1px 1px 0; margin-bottom:5px; max-width: 100%;\" allowfullscreen> <\/iframe> <\/p>\n<div style=\"margin-bottom:5px\"> <strong> <a href=\"https:\/\/www.slideshare.net\/shotababa359\/unity-32294734\" title=\"\u77e5\u3063\u3066\u5f97\u3059\u308bUnity \u30a8\u30c7\u30a3\u30bf\u62e1\u5f35\u7de8\" target=\"_blank\" rel=\"noopener noreferrer\">\u77e5\u3063\u3066\u5f97\u3059\u308bUnity \u30a8\u30c7\u30a3\u30bf\u62e1\u5f35\u7de8<\/a> <\/strong> from <strong><a href=\"http:\/\/www.slideshare.net\/shotababa359\" target=\"_blank\" rel=\"noopener noreferrer\">Shota Baba<\/a><\/strong> <\/div>\n<p><!--more--><br \/>\nPropertyAttribute\u3068\u3044\u3046\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u8868\u3059\u30af\u30e9\u30b9\u3092\u7d99\u627f\u3055\u305b\u3066\u5b9a\u7fa9\u3092\u62e1\u5f35\u3055\u305b\u308b\u3002<br \/>\n\u305d\u308c\u3092PropertyDrawer\u3068\u3044\u3046\u30af\u30e9\u30b9\u3092\u62e1\u5f35\u3055\u305b\u305f\u3082\u306e\u3067\u30a4\u30f3\u30b9\u30da\u30af\u30bf\u30fc\u4e0a\u306e\u8868\u793a\u3092\u62e1\u5f35\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3002<\/p>\n<p>\u5b9a\u7fa9<\/p>\n<pre class=\"brush: unitycsharp; title: ; notranslate\" title=\"\">\r\nusing UnityEngine;\r\n#if UNITY_EDITOR \/\/ Editor\u30d5\u30a9\u30eb\u30c0\u306b\u683c\u7d0d\u3059\u308b\u304b#if UNITY_EDITOR\u3067\u56f2\u307e\u306a\u3044\u3068\u30d3\u30eb\u30c9\u6642\u30a8\u30e9\u30fc\u3068\u306a\u308b\r\nusing UnityEditor;\r\n#endif\r\n\r\n\/**\r\n * \u30aa\u30ea\u30b8\u30ca\u30eb\u30a4\u30f3\u30b9\u30da\u30af\u30bf\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u5c5e\u6027\u3002\r\n *\/\r\npublic class CustomAttribute : PropertyAttribute {\r\n\t\/**\r\n\t * \u6570\u5024\u3002\r\n\t *\/\r\n\tpublic int value;\r\n\r\n\t\/**\r\n\t * \u6700\u5c0f\/\u6700\u5927\u306e\u5024\u3002\r\n\t *\/\r\n\tpublic int min;\r\n\tpublic int max;\r\n\r\n\t\/**\r\n\t * \u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u3002\r\n\t *\/\r\n\tpublic CustomAttribute(int min, int max) {\r\n\t\tthis.min = min;\r\n\t\tthis.max = max;\t\t\r\n\t}\r\n}\r\n\r\n#if UNITY_EDITOR\r\n\/**\r\n * \u30aa\u30ea\u30b8\u30ca\u30eb\u30a4\u30f3\u30b9\u30da\u30af\u30bf\u306e\u63cf\u753b\u3002\r\n *\/\r\n&#x5B;CustomPropertyDrawer(typeof(CustomAttribute))]\r\npublic class CustomDrawer : PropertyDrawer {\r\n\t\/**\r\n\t * OnGUI.\r\n\t *\/\r\n\tpublic override void OnGUI(Rect position, SerializedProperty property, GUIContent label) {\r\n\t\tCustomAttribute customAttr = (CustomAttribute)attribute;\r\n\r\n\t\tDebug.Log(property.name + &quot; : &quot; + property.intValue);\r\n\r\n\t\tEditorGUI.IntSlider(position, property, customAttr.min, customAttr.max);\r\n\t}\r\n}\r\n#endif\r\n<\/pre>\n<p>\u5b9f\u88c5<\/p>\n<pre class=\"brush: unitycsharp; title: ; notranslate\" title=\"\">\r\nusing UnityEngine;\r\n\r\n\/**\r\n * \u30aa\u30ea\u30b8\u30ca\u30eb\u306e\u30a4\u30f3\u30b9\u30da\u30af\u30bf\u30fc\u306e\u30c6\u30b9\u30c8\u3002\r\n *\/\r\npublic class OriginalInspectorTest : MonoBehaviour {\r\n\t\/**\r\n\t * \u30aa\u30ea\u30b8\u30ca\u30eb\u306e\u5c5e\u6027\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u3002\r\n\t *\/\r\n\t&#x5B;CustomAttribute(0, 10)]\r\n\tpublic int val = 5;\r\n\r\n\t&#x5B;CustomAttribute(10, 20)]\r\n\tpublic int val2 = 15;\r\n}\r\n<\/pre>\n<p><a href=\"\/blog\/wp-content\/entries\/140428_OriginalInspector\/original_inspector.zip\">&gt;&gt;\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u30d5\u30a1\u30a4\u30eb\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u30a4\u30f3\u30b9\u30da\u30af\u30bf\u306b\u72ec\u81ea\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u5c5e\u6027\u3092\u4f5c\u308c\u308b\u6a5f\u80fd\u3092\u8a66\u3057\u3066\u307f\u305f\u3002 \u30b9\u30af\u30ea\u30d7\u30c8\u5358\u4f4d\u3067\u62e1\u5f35\u3059\u308bCustomEditor\u3068\u3001\u30d7\u30ed\u30d1\u30c6\u30a3\u5358\u4f4d\u3067\u62e1\u5f35\u3059\u308bPropertyDrawer\u304c\u3042\u308b\u3089\u3057\u3044\u3002 \u4eca\u56de\u306f\u4e0b\u8a18\u306e\u30b5\u30a4\u30c8\u306ePropertyD [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-126","post","type-post","status-publish","format-standard","hentry","category-unity"],"_links":{"self":[{"href":"https:\/\/stacstar.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts\/126","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/stacstar.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/stacstar.jp\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/stacstar.jp\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/stacstar.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=126"}],"version-history":[{"count":5,"href":"https:\/\/stacstar.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts\/126\/revisions"}],"predecessor-version":[{"id":1964,"href":"https:\/\/stacstar.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts\/126\/revisions\/1964"}],"wp:attachment":[{"href":"https:\/\/stacstar.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=126"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/stacstar.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=126"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/stacstar.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=126"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}