{"id":2301,"date":"2024-04-10T09:20:50","date_gmt":"2024-04-10T01:20:50","guid":{"rendered":"https:\/\/courtship.top\/?p=2301"},"modified":"2024-04-10T09:24:41","modified_gmt":"2024-04-10T01:24:41","slug":"%e8%ae%b0%e5%bd%95%e7%82%b9%e4%b9%8b%e5%89%8d%e6%b2%a1%e8%ae%b0%e8%bf%87%e7%9a%84ue-c%e5%a5%87%e6%8a%80%e6%b7%ab%e5%b7%a73","status":"publish","type":"post","link":"https:\/\/courtship.top\/index.php\/2024\/04\/10\/%e8%ae%b0%e5%bd%95%e7%82%b9%e4%b9%8b%e5%89%8d%e6%b2%a1%e8%ae%b0%e8%bf%87%e7%9a%84ue-c%e5%a5%87%e6%8a%80%e6%b7%ab%e5%b7%a73\/","title":{"rendered":"\u8bb0\u5f55\u70b9\u4e4b\u524d\u6ca1\u8bb0\u8fc7\u7684UE C++\u5947\u6280\u6deb\u5de73"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u4e0d\u4e3a\u4eba\u77e5\u7684UE\u6280\u5de7<\/h2>\n\n\n\n<p><a href=\"http:\/\/\u6709\u54ea\u4e9b\u4e0d\u4e3a\u4eba\u77e5\u7684UE4\uff08\u865a\u5e7b\u5f15\u64ce\uff09\u6280\u5de7\uff1f - \u6084\u6084\u6478\u9c7c\u4e2d\u7684\u56de\u7b54 - \u77e5\u4e4e https:\/\/www.zhihu.com\/question\/351992572\/answer\/2616546771\" target=\"_blank\" rel=\"noreferrer noopener\" rel=\"nofollow\" >\u6709\u54ea\u4e9b\u4e0d\u4e3a\u4eba\u77e5\u7684<em>UE<\/em>4\uff08\u865a\u5e7b\u5f15\u64ce\uff09\u6280\u5de7\uff1f<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4f7f\u7528\u5b8f\u81ea\u52a8\u751f\u6210Get&amp;Set\u51fd\u6570<\/h2>\n\n\n\n<p>GAS\u7684Attribute\u4f7f\u7528\u4e86\u8fd9\u4e00\u6280\u5de7\uff0c\u76f4\u63a5\u4f7f\u7528\u5b8f\u6dfb\u52a0\u5230\u5934\u6587\u4ef6\uff0c\u5728\u5b9a\u4e49Atribute\u65f6\u4f7f\u7528\u5b8f\uff0c\u5c31\u53ef\u4ee5\u751f\u6210\u9759\u6001\u7684Get&amp;Set\u51fd\u6570\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ Uses macros from AttributeSet.h\n#define ATTRIBUTE_ACCESSORS(ClassName, PropertyName) \\\n\tGAMEPLAYATTRIBUTE_PROPERTY_GETTER(ClassName, PropertyName) \\\n\tGAMEPLAYATTRIBUTE_VALUE_GETTER(PropertyName) \\\n\tGAMEPLAYATTRIBUTE_VALUE_SETTER(PropertyName) \\\n\tGAMEPLAYATTRIBUTE_VALUE_INITTER(PropertyName)\n\n#define GAMEPLAYATTRIBUTE_PROPERTY_GETTER(ClassName, PropertyName) \\\n\tstatic FGameplayAttribute Get##PropertyName##Attribute() \\\n\t{ \\\n\tstatic FProperty* Prop = FindFieldChecked&lt;FProperty&gt;(ClassName::StaticClass(), GET_MEMBER_NAME_CHECKED(ClassName, PropertyName)); \\\n\t\treturn Prop; \\\n\t}\n\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>public:\n\tUGSAmmoAttributeSet();\n\n\tUPROPERTY(BlueprintReadOnly, Category = \"Ammo\", ReplicatedUsing = OnRep_RifleReserveAmmo)\n\tFGameplayAttributeData RifleReserveAmmo;\n\tATTRIBUTE_ACCESSORS(UGSAmmoAttributeSet, RifleReserveAmmo)\n\n\tUPROPERTY(BlueprintReadOnly, Category = \"Ammo\", ReplicatedUsing = OnRep_MaxRifleReserveAmmo)\n\tFGameplayAttributeData MaxRifleReserveAmmo;\n\tATTRIBUTE_ACCESSORS(UGSAmmoAttributeSet, MaxRifleReserveAmmo)\n\n\tUPROPERTY(BlueprintReadOnly, Category = \"Ammo\", ReplicatedUsing = OnRep_RocketReserveAmmo)\n\tFGameplayAttributeData RocketReserveAmmo;\n\tATTRIBUTE_ACCESSORS(UGSAmmoAttributeSet, RocketReserveAmmo)\n...<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u4f7f\u7528DefaultObject<\/h2>\n\n\n\n<p>\u5728 Unreal Engine \u4e2d\uff0c\u6bcf\u4e2a\u7ee7\u627f\u81ea&nbsp;<code>UObject<\/code>&nbsp;\u7c7b\u7684\u7c7b\u90fd\u6709\u4e00\u4e2a\u9ed8\u8ba4\u5bf9\u8c61\uff0c\u53ef\u4ee5\u901a\u8fc7&nbsp;<code>GetDefaultObject<\/code>&nbsp;\u6216&nbsp;<code>GetMutableDefault<\/code>&nbsp;\u51fd\u6570\u83b7\u53d6\u3002\u5176\u4e2d\uff0c<code>GetDefaultObject<\/code>&nbsp;\u51fd\u6570\u8fd4\u56de\u4e00\u4e2a\u5e38\u91cf\u5bf9\u8c61\u6307\u9488\uff0c\u4e0d\u80fd\u4fee\u6539\u8be5\u5bf9\u8c61\u7684\u5c5e\u6027\u503c\uff0c\u800c&nbsp;<code>GetMutableDefault<\/code>&nbsp;\u51fd\u6570\u8fd4\u56de\u4e00\u4e2a\u53ef\u4fee\u6539\u7684\u5bf9\u8c61\u6307\u9488\uff0c\u53ef\u4ee5\u4fee\u6539\u8be5\u5bf9\u8c61\u7684\u5c5e\u6027\u503c\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>FORCEINLINE T* GetDefaultObject() const\n{\n    UObject* Result = nullptr;\n    if (Class)\n    {\n\tResult = Class->GetDefaultObject();\n\tcheck(Result &amp;&amp; Result->IsA(T::StaticClass()));\n    }\n    return (T*)Result;\n}\n\nUAIAgentSettings* const settings = GetMutableDefault&lt;UAIAgentSettings>();\nif (nullptr == settings)\n{\n    return;\n}<\/code><\/pre>\n\n\n\n<p>\/\/\u83b7\u53d6\u8bbe\u7f6e\u7c7b\u7684\u9ed8\u8ba4\u503c\uff0c\u51e0\u4e4e\u6ca1\u6709\u635f\u8017<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e0d\u4e3a\u4eba\u77e5\u7684UE\u6280\u5de7 \u6709\u54ea\u4e9b\u4e0d\u4e3a\u4eba\u77e5\u7684UE4\uff08\u865a\u5e7b\u5f15\u64ce\uff09\u6280\u5de7\uff1f \u4f7f\u7528\u5b8f\u81ea\u52a8\u751f\u6210Get&amp;Set\u51fd\u6570 GAS\u7684Attribute &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"emotion":"","emotion_color":"","title_style":"","license":"","footnotes":""},"categories":[6,12],"tags":[],"class_list":["post-2301","post","type-post","status-publish","format-standard","hentry","category-engine","category-ue"],"_links":{"self":[{"href":"https:\/\/courtship.top\/index.php\/wp-json\/wp\/v2\/posts\/2301","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/courtship.top\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/courtship.top\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/courtship.top\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/courtship.top\/index.php\/wp-json\/wp\/v2\/comments?post=2301"}],"version-history":[{"count":12,"href":"https:\/\/courtship.top\/index.php\/wp-json\/wp\/v2\/posts\/2301\/revisions"}],"predecessor-version":[{"id":2339,"href":"https:\/\/courtship.top\/index.php\/wp-json\/wp\/v2\/posts\/2301\/revisions\/2339"}],"wp:attachment":[{"href":"https:\/\/courtship.top\/index.php\/wp-json\/wp\/v2\/media?parent=2301"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courtship.top\/index.php\/wp-json\/wp\/v2\/categories?post=2301"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courtship.top\/index.php\/wp-json\/wp\/v2\/tags?post=2301"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}