{{tag>dragonscript behavior}} [[:start|Start Page]] >> [[main|DragonScript Scripting Language]] >> [[abstractions#behavior_elementsquick_and_easy_development|Behavior Elements: Quick and Easy Development]] >> **ECBehaviorAttachDynamicSkin** * [[behaviors_use_cases|Behaviors Explained: By Use-Case]] * [[behaviors_a_to_z|Behaviors Explained: From A to Z]] ====== ECBehaviorAttachDynamicSkin ====== Behavior element behavior adding support to use dynamic skin on attaching. For use together with [[behavior_attachtoparent|ECBehaviorAttachToParent]] or [[behavior_attachable|ECBehaviorAttachable]]. Upon attaching the element to a parent element the dynamic skin of parent element [[behavior_dynamicskin|ECBehaviorDynamicSkin]] is assigned to this element [[behavior_component|ECBehaviorComponent]]. If an [[behavior_attachslot|ECBehaviorAttachSlot]] is involved supports also detaching when the dynamic skin is removed. This behavior helps with situations where a child element has to use the same dynamic skin as the parent it is attached to. A typical example would be a base object using dynamic skin to show a user selected paint color or showing flashing emissive textures where child elements should match up with. The dynamic skin is controlled by the parent element and can be used for all child elements. Do not use this behavior together with child elements using their own [[behavior_dynamicskin|ECBehaviorDynamicSkin]] otherwise this dynamic skin will be overwritten. By default the behavior is configured to be used by attaching to parent element using ECBehaviorAttachToParent. If [[behavior_attachable|ECBehaviorAttachable]] is also present a listener is added to also react to being added and removed from [[behavior_attachslot|ECBehaviorAttachSlot]]. By default the [[behavior_component|ECBehaviorComponent]] with empty ID is assigned the [[behavior_dynamicskin|ECBehaviorDynamicSkin]] with empty ID. This can be configured. See also: * [[gamedev:renderables|Dynamic Content using Renderables]] * [[gamedev:deigde:editors:skin|IGDE Skin Editor]] ====== Instance Counts ====== This behavior can be used only once on an element. ====== Element Class Properties ====== Element class properties have the prefix ''attachDynamicSkin.'' . ====== Events ====== This behavior has no events. ====== Required Behaviors ====== * [[behavior_component|ECBehaviorComponent]] ====== Optional Behaviors ====== * [[behavior_attachable|ECBehaviorAttachable]]: Listens on attachable to assign dynamic skin from attach slot if present. ====== Persistency ====== This behavior does not required element class to be persistable (setPersistable). ====== API Documentation ====== #@LinkApiDocDEDS2_HTML~classDragengine_1_1Scenery_1_1ECBehaviorAttachDynamicSkin.html,ECBehaviorAttachDynamicSkin~@#. Since DragonScript Module Version ''1.0'' ====== Use Cases ====== * Assign dynamic skin from parent object upon attaching to update parent object dynamic skin. ====== Element Class Example ====== This example defines an element which can assign dynamic skin from parent elements. class MyElement extends BehaviorElementClass public var ECBehaviorComponent component public var ECBehaviorCollider collider public var ECBehaviorAttachable attachable public var ECBehaviorAttachDynamicSkin attachDynamicSkin func new() component = ECBehaviorComponent.new(this, null) collider = ECBehaviorCollider.new(this, component) attachable = ECBehaviorAttachable.new(this, collider) attachDynamicSkin = ECBehaviorAttachDynamicSkin.new(this, component, attachable) end end ====== Behavior Factory ====== Using element class supporting adding behaviors the behavior can be added like this: second value ====== Live Examples ====== * [[https://github.com/LordOfDragons/deexamples|DEExamples Repository]]