{"id":1055,"date":"2025-02-27T14:36:31","date_gmt":"2025-02-27T14:36:31","guid":{"rendered":"https:\/\/varnagame.site\/?p=1055"},"modified":"2026-02-25T09:08:02","modified_gmt":"2026-02-25T09:08:02","slug":"%d0%bf%d1%80%d0%be%d1%81%d1%82%d0%be%d0%b9-%d0%bf%d1%80%d0%b8%d0%bc%d0%b5%d1%80-action-callback-delegate","status":"publish","type":"post","link":"https:\/\/varnagame.site\/?p=1055","title":{"rendered":"\u041f\u0440\u043e\u0441\u0442\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b  Action Callback Delegate"},"content":{"rendered":"\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-csharp\" data-lang=\"C#\"><code>using UnityEngine;\nusing System;\nusing System.Collections;\n\npublic class MyScript_1 : MonoBehaviour\n{\n    void Start() {\n        MyScript_2.Instance.MyFunc_2(MyFunc_1);\n    }\n\n    private void MyFunc_1(bool result) {\n        Debug.Log(&quot;result &quot; + result);\n    }\n\n}\n\n\npublic class MyScript_2 : MonoBehaviour\n{\n    static public MyScript_2 Instance;\n    private Action&lt;bool&gt; _maynCallback;\n\n    void Awake() {\n        Instance = this;\n    }\n\n    public void MyFunc_2(Action&lt;bool&gt; callback) {\n        _maynCallback = callback;\n        MyFunc_3();\n    }\n\n    private void MyFunc_3() {\n        _maynCallback?.Invoke(true);\n        _maynCallback = null;\n    }\n\n}<\/code><\/pre><\/div>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-csharp\" data-lang=\"C#\"><code>using UnityEngine;\nusing System;\nusing System.Collections;\n\npublic class MyScript_1 : MonoBehaviour\n{\n    void Start() {\n        MyScript_2.Instance.MyFunc_2(() =&gt; \n            {\n                Debug.Log(&quot;done&quot;);\n            });\n    }\n}\n\n\npublic class MyScript_2 : MonoBehaviour\n{\n    static public MyScript_2 Instance;\n\n    void Awake() {\n        Instance = this;\n    }\n\n    public void MyFunc_2(Action callback) {\n        callback?.Invoke();\n    }\n}<\/code><\/pre><\/div>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-csharp\" data-lang=\"C#\"><code>using UnityEngine;\nusing System;\nusing System.Collections;\n\npublic class MyScript_1 : MonoBehaviour\n{\n    void Start() {\n        MyScript_2.Instance.MyFunc_2(result =&gt; \n            {\n                Debug.Log(&quot;done&quot;+result);\n            });\n    }\n}\n\n\npublic class MyScript_2 : MonoBehaviour\n{\n    static public MyScript_2 Instance;\n\n    void Awake() {\n        Instance = this;\n    }\n\n    public void MyFunc_2(Action&lt;bool&gt; callback) {\n        callback?.Invoke(true);\n    }\n}<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,10,20],"tags":[],"_links":{"self":[{"href":"https:\/\/varnagame.site\/index.php?rest_route=\/wp\/v2\/posts\/1055"}],"collection":[{"href":"https:\/\/varnagame.site\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/varnagame.site\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/varnagame.site\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/varnagame.site\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1055"}],"version-history":[{"count":11,"href":"https:\/\/varnagame.site\/index.php?rest_route=\/wp\/v2\/posts\/1055\/revisions"}],"predecessor-version":[{"id":1605,"href":"https:\/\/varnagame.site\/index.php?rest_route=\/wp\/v2\/posts\/1055\/revisions\/1605"}],"wp:attachment":[{"href":"https:\/\/varnagame.site\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1055"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/varnagame.site\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1055"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/varnagame.site\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1055"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}