Table of Contents

,

Start Page » DragonScript Scripting Language » Behavior Elements: Quick and Easy Development » ECBehaviorAttachDynamicSkin

ECBehaviorAttachDynamicSkin

Behavior element behavior adding support to use dynamic skin on attaching.

For use together with ECBehaviorAttachToParent or ECBehaviorAttachable. Upon attaching the element to a parent element the dynamic skin of parent element ECBehaviorDynamicSkin is assigned to this element ECBehaviorComponent. If an 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 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 ECBehaviorAttachable is also present a listener is added to also react to being added and removed from ECBehaviorAttachSlot. By default the ECBehaviorComponent with empty ID is assigned the ECBehaviorDynamicSkin with empty ID. This can be configured.

See also:

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

Optional Behaviors

Persistency

This behavior does not required element class to be persistable (setPersistable).

API Documentation

ECBehaviorAttachDynamicSkin.

Since DragonScript Module Version 1.0

Use Cases

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:

<?xml version='1.0' encoding='UTF-8'?>
<elementClass name='MyClass' class='GenericBehaviorElement'>
  <behavior type='ECBehaviorComponent'/>
  <behavior type='ECBehaviorCollider'/>
  <behavior type='ECBehaviorAttachable'/>
 
  <behavior type='ECBehaviorAttachDynamicSkin'>
    <!-- optional: use component with id instead of empty string -->
    <string name='component'>second</string>
 
    <!-- set element properties. omit property prefix if used inside behavior tag -->
    <string name='.name'>value</string>
  </behavior>
 
  <!-- for adding multiple behaviors use unique identifiers -->
  <behavior type='ECBehaviorAttachDynamicSkin' id='second'/>
</elementClass>

Live Examples