<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://www.wlabsocks.com/wiki/index.php?action=history&amp;feed=atom&amp;title=Policy.onPolicyNameChanged</id>
	<title>Policy.onPolicyNameChanged - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://www.wlabsocks.com/wiki/index.php?action=history&amp;feed=atom&amp;title=Policy.onPolicyNameChanged"/>
	<link rel="alternate" type="text/html" href="http://www.wlabsocks.com/wiki/index.php?title=Policy.onPolicyNameChanged&amp;action=history"/>
	<updated>2026-05-12T22:58:08Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.5</generator>
	<entry>
		<id>http://www.wlabsocks.com/wiki/index.php?title=Policy.onPolicyNameChanged&amp;diff=978&amp;oldid=prev</id>
		<title>Tayfunwiki: Created page with &quot;=== Policy Class - &lt;code&gt;onPolicyNameChanged&lt;/code&gt; Event ===  ==== Overview ==== The &lt;code&gt;onPolicyNameChanged&lt;/code&gt; event in the Policy class is triggered when the name of a policy is changed. It's useful for updating UI elements or other game components that depend on the policy name.  ==== Syntax ==== &lt;syntaxhighlight lang=&quot;c#&quot;&gt; public event Action&lt;string&gt; onPolicyNameChanged; &lt;/syntaxhighlight&gt;  ==== Description ==== This event is attached to a specific policy and...&quot;</title>
		<link rel="alternate" type="text/html" href="http://www.wlabsocks.com/wiki/index.php?title=Policy.onPolicyNameChanged&amp;diff=978&amp;oldid=prev"/>
		<updated>2024-01-05T14:15:15Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;=== Policy Class - &amp;lt;code&amp;gt;onPolicyNameChanged&amp;lt;/code&amp;gt; Event ===  ==== Overview ==== The &amp;lt;code&amp;gt;onPolicyNameChanged&amp;lt;/code&amp;gt; event in the Policy class is triggered when the name of a policy is changed. It&amp;#039;s useful for updating UI elements or other game components that depend on the policy name.  ==== Syntax ==== &amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt; public event Action&amp;lt;string&amp;gt; onPolicyNameChanged; &amp;lt;/syntaxhighlight&amp;gt;  ==== Description ==== This event is attached to a specific policy and...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;=== Policy Class - &amp;lt;code&amp;gt;onPolicyNameChanged&amp;lt;/code&amp;gt; Event ===&lt;br /&gt;
&lt;br /&gt;
==== Overview ====&lt;br /&gt;
The &amp;lt;code&amp;gt;onPolicyNameChanged&amp;lt;/code&amp;gt; event in the Policy class is triggered when the name of a policy is changed. It's useful for updating UI elements or other game components that depend on the policy name.&lt;br /&gt;
&lt;br /&gt;
==== Syntax ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
public event Action&amp;lt;string&amp;gt; onPolicyNameChanged;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Description ====&lt;br /&gt;
This event is attached to a specific policy and gets triggered when its name is altered. The event passes the old name of the policy as a parameter.&lt;br /&gt;
&lt;br /&gt;
==== Usage ====&lt;br /&gt;
This event can be used to synchronize the policy's name across different parts of the game, like updating UI elements to reflect the new name.&lt;br /&gt;
&lt;br /&gt;
==== Example of Usage ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
public class PolicyManager : MonoBehaviour {&lt;br /&gt;
    private Policy currentPolicy;&lt;br /&gt;
&lt;br /&gt;
    void Start() {&lt;br /&gt;
        // Fetching the 'Economy' policy from the game's policy manager&lt;br /&gt;
        currentPolicy = IM.GetPolicy(&amp;quot;Economy&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        if (currentPolicy != null) {&lt;br /&gt;
            // Subscribing to the policy name change event&lt;br /&gt;
            currentPolicy.onPolicyNameChanged += OnPolicyNameChanged;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    private void OnPolicyNameChanged(string oldName) {&lt;br /&gt;
        // Handling the policy name change event&lt;br /&gt;
        Debug.Log($&amp;quot;Policy name changed from {oldName} to {currentPolicy.PolicyName}&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    void OnDestroy() {&lt;br /&gt;
        if (currentPolicy != null) {&lt;br /&gt;
            // Unsubscribing from the policy name change event&lt;br /&gt;
            currentPolicy.onPolicyNameChanged -= OnPolicyNameChanged;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Remarks ====&lt;br /&gt;
&lt;br /&gt;
* The event handler &amp;lt;code&amp;gt;OnPolicyNameChanged&amp;lt;/code&amp;gt; is called when the name of the &amp;lt;code&amp;gt;currentPolicy&amp;lt;/code&amp;gt; changes.&lt;br /&gt;
* It's important to unsubscribe from the event in the &amp;lt;code&amp;gt;OnDestroy&amp;lt;/code&amp;gt; method to avoid memory leaks and ensure proper cleanup.&lt;br /&gt;
* The &amp;lt;code&amp;gt;IM.GetPolicy&amp;lt;/code&amp;gt; method is used to get the specific policy instance from the game's policy manager.&lt;/div&gt;</summary>
		<author><name>Tayfunwiki</name></author>
	</entry>
</feed>