<?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=OnRoleChanged</id>
	<title>OnRoleChanged - 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=OnRoleChanged"/>
	<link rel="alternate" type="text/html" href="http://www.wlabsocks.com/wiki/index.php?title=OnRoleChanged&amp;action=history"/>
	<updated>2026-05-13T04:36:27Z</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=OnRoleChanged&amp;diff=783&amp;oldid=prev</id>
		<title>Tayfunwiki: Created page with &quot;== &lt;code&gt;onRoleChanged&lt;/code&gt; Event in Actor Class ==  === Overview === The &lt;code&gt;onRoleChanged&lt;/code&gt; event is an integral part of the &lt;code&gt;Actor&lt;/code&gt; class, activated when the actor is assigned a new role. This event plays a crucial role in games where role assignments and changes significantly impact character development, gameplay mechanics, or narrative progression.  === Description ===  * Event Type: &lt;code&gt;Action&lt;Role&gt;&lt;/code&gt; * Functionality: This event triggers...&quot;</title>
		<link rel="alternate" type="text/html" href="http://www.wlabsocks.com/wiki/index.php?title=OnRoleChanged&amp;diff=783&amp;oldid=prev"/>
		<updated>2023-12-24T19:53:11Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;== &amp;lt;code&amp;gt;onRoleChanged&amp;lt;/code&amp;gt; Event in Actor Class ==  === Overview === The &amp;lt;code&amp;gt;onRoleChanged&amp;lt;/code&amp;gt; event is an integral part of the &amp;lt;code&amp;gt;Actor&amp;lt;/code&amp;gt; class, activated when the actor is assigned a new role. This event plays a crucial role in games where role assignments and changes significantly impact character development, gameplay mechanics, or narrative progression.  === Description ===  * Event Type: &amp;lt;code&amp;gt;Action&amp;lt;Role&amp;gt;&amp;lt;/code&amp;gt; * Functionality: This event triggers...&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;onRoleChanged&amp;lt;/code&amp;gt; Event in Actor Class ==&lt;br /&gt;
&lt;br /&gt;
=== Overview ===&lt;br /&gt;
The &amp;lt;code&amp;gt;onRoleChanged&amp;lt;/code&amp;gt; event is an integral part of the &amp;lt;code&amp;gt;Actor&amp;lt;/code&amp;gt; class, activated when the actor is assigned a new role. This event plays a crucial role in games where role assignments and changes significantly impact character development, gameplay mechanics, or narrative progression.&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
&lt;br /&gt;
* Event Type: &amp;lt;code&amp;gt;Action&amp;lt;Role&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
* Functionality: This event triggers when there is a change in the actor's role. It allows for the execution of custom actions or logic in response to the new role assignment, enabling dynamic character evolution and interaction based on role-related attributes and responsibilities.&lt;br /&gt;
&lt;br /&gt;
=== Usage ===&lt;br /&gt;
The event is used to implement specific responses or updates in the game when an actor's role changes. This can include modifying character abilities, updating narrative elements, or changing interaction options to align with the new role.&lt;br /&gt;
&lt;br /&gt;
=== Subscribing to the Event ===&lt;br /&gt;
Subscribe to the &amp;lt;code&amp;gt;onRoleChanged&amp;lt;/code&amp;gt; event within a MonoBehaviour script to handle role changes in an actor. Ensure to unsubscribe from the event when it's no longer needed or when the actor is destroyed, to maintain optimal performance and avoid memory leaks.&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 RoleChangeHandler : MonoBehaviour {&lt;br /&gt;
    public Actor actor;&lt;br /&gt;
&lt;br /&gt;
    void Start() {&lt;br /&gt;
        if (actor != null) {&lt;br /&gt;
            actor.onRoleChanged += OnRoleChanged;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    private void OnRoleChanged(Role newRole) {&lt;br /&gt;
        Debug.Log($&amp;quot;{actor.FullName} has been assigned a new role: {newRole.RoleName}.&amp;quot;);&lt;br /&gt;
        // Implement logic to handle the actor's new role&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    void OnDestroy() {&lt;br /&gt;
        if (actor != null) {&lt;br /&gt;
            actor.onRoleChanged -= OnRoleChanged;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;In this Unity script, the &amp;lt;code&amp;gt;RoleChangeHandler&amp;lt;/code&amp;gt; is attached to a GameObject and subscribes to the &amp;lt;code&amp;gt;onRoleChanged&amp;lt;/code&amp;gt; event of an &amp;lt;code&amp;gt;Actor&amp;lt;/code&amp;gt;. When the actor's role changes, the &amp;lt;code&amp;gt;OnRoleChanged&amp;lt;/code&amp;gt; method is invoked, providing an opportunity to adapt the game to the actor's new role.&lt;br /&gt;
&lt;br /&gt;
=== Remarks ===&lt;br /&gt;
&lt;br /&gt;
* The &amp;lt;code&amp;gt;onRoleChanged&amp;lt;/code&amp;gt; event is essential for creating responsive and adaptive gameplay experiences, particularly in games where character roles define abilities, duties, or story arcs.&lt;br /&gt;
* Proper handling of role changes through this event contributes to the depth and interactivity of the game, reflecting the evolving nature of characters.&lt;br /&gt;
* This event is highly relevant in role-playing games, strategy games, and other titles where character roles are central to gameplay dynamics and narrative development.&lt;/div&gt;</summary>
		<author><name>Tayfunwiki</name></author>
	</entry>
</feed>