---
title: SKAttributeValue
framework: spritekit
role: symbol
role_heading: Class
path: spritekit/skattributevalue
---

# SKAttributeValue

A container for dynamic shader data associated with a node.

## Declaration

```swift
class SKAttributeValue
```

## Overview

Overview SpriteKit nodes that are rendered with a custom shader can use SKAttributeValue objects to pass dynamic values which can change without requiring that shader to be recompiled. An attribute value is passed to a shader using a node’s setValue(_:forAttribute:) method using the relevant attribute’s name. For example, given a shader with a SKAttributeType.float attribute named a_radius: Listing 1. Creating an attribute let attribute = SKAttribute(name: "a_radius",                              type: SKAttributeType.float) The following code sets the value of this attribute to 10 and passes it to a SKSpriteNode object’s shader: Listing 2. Setting an attribute value node.setValue(SKAttributeValue(float: 10),                forAttribute: "a_radius") The attribute, a_radius, is available as a global floating-point variable within the shader code. Using this technique, a single shader can be shared across many nodes and each nodes can supply its own attributes. This approach is an alternative to using SKUniform objects which would require a recompilation for each distinct set of parameters.

## Topics

### Initializers

- [init()](spritekit/skattributevalue/init().md)
- [init(float:)](spritekit/skattributevalue/init(float:).md)
- [init(vectorFloat2:)](spritekit/skattributevalue/init(vectorfloat2:).md)
- [init(vectorFloat3:)](spritekit/skattributevalue/init(vectorfloat3:).md)
- [init(vectorFloat4:)](spritekit/skattributevalue/init(vectorfloat4:).md)
- [init(coder:)](spritekit/skattributevalue/init(coder:).md)

### Instance Properties

- [floatValue](spritekit/skattributevalue/floatvalue.md)
- [vectorFloat2Value](spritekit/skattributevalue/vectorfloat2value.md)
- [vectorFloat3Value](spritekit/skattributevalue/vectorfloat3value.md)
- [vectorFloat4Value](spritekit/skattributevalue/vectorfloat4value.md)

## Relationships

### Inherits From

- [NSObject](objectivec/nsobject-swift.class.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSCoding](foundation/nscoding.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [NSSecureCoding](foundation/nssecurecoding.md)

## See Also

### Shaders

- [SKShader](spritekit/skshader.md)
- [SKAttribute](spritekit/skattribute.md)
- [SKUniform](spritekit/skuniform.md)
