<?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=IM.SetVariable</id>
	<title>IM.SetVariable - 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=IM.SetVariable"/>
	<link rel="alternate" type="text/html" href="http://www.wlabsocks.com/wiki/index.php?title=IM.SetVariable&amp;action=history"/>
	<updated>2026-05-13T03:08:53Z</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=IM.SetVariable&amp;diff=872&amp;oldid=prev</id>
		<title>Tayfunwiki: Created page with &quot;== &lt;code&gt;SetVariable&lt;/code&gt; and &lt;code&gt;SetVariable&lt;T&gt;&lt;/code&gt; Methods in IM Class ==  === Overview === The &lt;code&gt;SetVariable&lt;/code&gt; methods in the IM class are designed to set the value of a public variable. There are two versions: a non-generic version for general use, and a generic version that returns the updated variable cast to a specific type &lt;code&gt;T&lt;/code&gt;.  === Syntax === &lt;syntaxhighlight lang=&quot;c#&quot;&gt; public static void SetVariable(string varNameOrId, object value) p...&quot;</title>
		<link rel="alternate" type="text/html" href="http://www.wlabsocks.com/wiki/index.php?title=IM.SetVariable&amp;diff=872&amp;oldid=prev"/>
		<updated>2024-01-04T20:27:41Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;== &amp;lt;code&amp;gt;SetVariable&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SetVariable&amp;lt;T&amp;gt;&amp;lt;/code&amp;gt; Methods in IM Class ==  === Overview === The &amp;lt;code&amp;gt;SetVariable&amp;lt;/code&amp;gt; methods in the IM class are designed to set the value of a public variable. There are two versions: a non-generic version for general use, and a generic version that returns the updated variable cast to a specific type &amp;lt;code&amp;gt;T&amp;lt;/code&amp;gt;.  === Syntax === &amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt; public static void SetVariable(string varNameOrId, object value) p...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== &amp;lt;code&amp;gt;SetVariable&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SetVariable&amp;lt;T&amp;gt;&amp;lt;/code&amp;gt; Methods in IM Class ==&lt;br /&gt;
&lt;br /&gt;
=== Overview ===&lt;br /&gt;
The &amp;lt;code&amp;gt;SetVariable&amp;lt;/code&amp;gt; methods in the IM class are designed to set the value of a public variable. There are two versions: a non-generic version for general use, and a generic version that returns the updated variable cast to a specific type &amp;lt;code&amp;gt;T&amp;lt;/code&amp;gt;.&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 static void SetVariable(string varNameOrId, object value)&lt;br /&gt;
public static T SetVariable&amp;lt;T&amp;gt;(string varNameOrId, object value) where T : NVar&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;varNameOrId&amp;lt;/code&amp;gt;: The name or ID of the variable to be set.&lt;br /&gt;
* &amp;lt;code&amp;gt;value&amp;lt;/code&amp;gt;: The new value to assign to the variable.&lt;br /&gt;
&lt;br /&gt;
=== Functionality ===&lt;br /&gt;
&lt;br /&gt;
* SetVariable (Non-generic):&lt;br /&gt;
** Searches for and sets the value of a variable matching the provided name or ID.&lt;br /&gt;
** Does not return any value.&lt;br /&gt;
* SetVariable&amp;lt;T&amp;gt; (Generic):&lt;br /&gt;
** Operates similarly to the non-generic version but also returns the updated variable cast to the specified type &amp;lt;code&amp;gt;T&amp;lt;/code&amp;gt;.&lt;br /&gt;
** Useful when the type of the variable is known and specific type handling is needed.&lt;br /&gt;
&lt;br /&gt;
=== Usage 1: Non-Generic Method ===&lt;br /&gt;
Used for setting the value of a variable without needing to handle its specific type. This method is suitable for general-purpose variable manipulation.&lt;br /&gt;
&lt;br /&gt;
==== Example of Usage 1 ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
public class GameSettings : MonoBehaviour {&lt;br /&gt;
    public void UpdateAudioVolume(float newVolume) {&lt;br /&gt;
        IM.SetVariable(&amp;quot;audio_volume&amp;quot;, newVolume);&lt;br /&gt;
        Debug.Log(&amp;quot;Audio volume updated.&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Usage 2: Generic Method ===&lt;br /&gt;
Used for setting a variable's value and returning it as a specific type &amp;lt;code&amp;gt;T&amp;lt;/code&amp;gt;. This method is suitable when type-specific handling or processing is required after updating the variable.&lt;br /&gt;
&lt;br /&gt;
==== Example of Usage 2 ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
public class GameSettings : MonoBehaviour {&lt;br /&gt;
    public void UpdateAndFetchAudioVolume(float newVolume) {&lt;br /&gt;
        NFloat volumeVar = IM.SetVariable&amp;lt;NFloat&amp;gt;(&amp;quot;audio_volume&amp;quot;, newVolume);&lt;br /&gt;
        if (volumeVar != null) {&lt;br /&gt;
            Debug.Log($&amp;quot;Audio volume updated to: {volumeVar.Value}&amp;quot;);&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;
* These methods are critical for dynamic data manipulation within games, allowing variables to be updated in response to gameplay events or user actions.&lt;br /&gt;
* Proper implementation ensures that game state and logic can adapt fluidly to changing conditions, enhancing gameplay responsiveness and flexibility.&lt;br /&gt;
* Particularly relevant in games where player choices or actions dynamically affect game mechanics or narrative elements.&lt;/div&gt;</summary>
		<author><name>Tayfunwiki</name></author>
	</entry>
</feed>