Table of Contents
- Related
- Frameworks supported
- Prerequisites
- Dependencies
- Packaging
- Getting Started
- Tutorials
- Assets
- API
- Examples
Apps:
-
ChromaClientForDiscord - Add Chroma lighting to the Discord App events
-
ChromaClientForMixer - Add Chroma lighting to the Mixer streaming experience
-
ChromaClientForTwitch - Add Chroma lighting to the Twitch streaming experience
Plugins:
-
CChromaEditor - C++ native MFC library for playing and editing Chroma animations
-
GameMakerChromaExtension - GameMaker extension to control lighting for Razer Chroma
-
HTML5ChromaSDK - JavaScript library for playing Chroma animations
-
UE4ChromaSDKRT - UE4 runtime module with Blueprint library for the ChromaSDK
-
UnityNativeChromaSDK - Unity native library for the ChromaSDK
- Unity 3.5.7 or later
- Windows Editor / Windows Standalone
- Install Synapse
- Synapse will install the Chroma SDK when a Chroma enabled device is connected
- Install Microsoft Visual C++ Redistributable for Visual Studio 2017
- CChromaEditor - C++ Native MFC Library for playing and editing Chroma animations
Import UnityNativeChromaSDK.unitypackage into your project.
1 Install Synapse
2 (Optional) Install the Emulator
3 Connect Razer Chroma hardware
4 Install Unity3d
5 Open Unity and start with an existing project or open a new project
6 Backup your project in source control!
7 Import UnityNativeChromaSDK.unitypackage into your project.
Import Unity Package
8 Create Chroma
animations from the Assets/ChromaSDK/Create Chroma Animation
menu item. This will open a file save dialog and create a chroma animation file when saved.
9 Edit Chroma
animations by selecting a Chroma
animation in the Object Hierarchy
and select the Assets/ChromaSDK/Edit Chroma Animation
menu item.
10 Also edit Chroma
animations by selecting a .chroma
file in the Object Hierarchy
, right-click, and select the ChromaSDK/Edit Chroma Animation
context item.
Capture Window
Composite Capture
Composite Playback
Capture With Images
Keyboard Layout Toggle
Loop and Reverse
Keyboard Masks
Layouts and Playback Looping
Chroma
animations are loaded from the StreamingAssets
folder.
Use the GameObject->ChromaSDK
menu to create Chroma
animations.
Chroma
animations should be saved in the StreamingAssets
folder.
Editing Chroma
animations will open the Chroma
editor dialog.
- CloseAnimationName
- CopyKeysColorAllFramesName
- CopyNonZeroAllKeysAllFramesName
- EditAnimation
- GetCurrentFrameName
- GetFrameCountName
- HasAnimationLoopName
- Init
- IsAnimationPausedName
- IsPlaying
- MultiplyIntensityAllFramesName
- OffsetNonZeroColorsAllFramesName
- PauseAnimationName
- PlayAnimationName
- PlayComposite
- PluginIsInitialized
- PluginIsPlatformSupported
- ResumeAnimationName
- SetCurrentFrameName
- SetKeysColorAllFramesName
- StopAnimationName
- StopAnimationType
- StopComposite
- Uninit
Add the ChromaSDK
namespace.
using ChromaSDK;
The API
is only available on the Windows Editor
and Windows Standalone
platforms.
#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
// put your windows specific code in here
#endif
The native plugin should be initialized on Awake
. 0
indicates success, otherwise failure.
private void Awake()
{
UnityNativeChromaSDK.Init();
}
The native plugin should be uninitialized on Quit
. 0
indicates success, otherwise failure.
private void OnApplicationQuit()
{
UnityNativeChromaSDK.Uninit();
}
Returns true if the plugin has been initialized. Returns false if the plugin is uninitialized.
bool isInitialized = UnityNativeChromaSDK.PluginIsInitialized();
The animation will play with looping ON
or OFF
.
string animation = "Random_Keyboard.chroma";
bool loop = true;
UnityNativeChromaSDK.PlayAnimationName(animation, loop);
The animation will stop playing.
string animation = "Random_Keyboard.chroma";
UnityNativeChromaSDK.StopAnimationName(animation);
Stop playing animations by type.
UnityNativeChromaSDK.StopAnimationType(UnityNativeChromaSDK.Device.ChromaLink);
UnityNativeChromaSDK.StopAnimationType(UnityNativeChromaSDK.Device.Headset);
UnityNativeChromaSDK.StopAnimationType(UnityNativeChromaSDK.Device.Keyboard);
UnityNativeChromaSDK.StopAnimationType(UnityNativeChromaSDK.Device.Keypad);
UnityNativeChromaSDK.StopAnimationType(UnityNativeChromaSDK.Device.Mouse);
UnityNativeChromaSDK.StopAnimationType(UnityNativeChromaSDK.Device.Mousepad);
The animation will be closed so that it can be reloaded from disk.
string animation = "Random_Keyboard.chroma";
UnityNativeChromaSDK.CloseAnimationName(animation);
The animation will open in the editor dialog. Only one animation can be edited at a time.
string animation = "Random_Keyboard.chroma";
UnityNativeChromaSDK.EditAnimation(animation);
Get the frame count of the animation.
string animation = "Random_Keyboard.chroma";
int frameCount = UnityNativeChromaSDK.GetFrameCountName(animation);
Copy a set of key colors from the source animation to the target animation for all frames.
string sourceAnimation = "Fire_Keyboard.chroma";
string targetAnimation = "Random_Keyboard.chroma";
UnityNativeChromaSDK.CopyKeysColorAllFramesName(sourceAnimation, targetAnimation,
new int[] {
(int)UnityNativeChromaSDK.Keyboard.RZKEY.RZKEY_W,
(int)UnityNativeChromaSDK.Keyboard.RZKEY.RZKEY_A,
(int)UnityNativeChromaSDK.Keyboard.RZKEY.RZKEY_S,
(int)UnityNativeChromaSDK.Keyboard.RZKEY.RZKEY_D,
(int)UnityNativeChromaSDK.Keyboard.RZLED.RZLED_LOGO});
Assign a set of key colors to a static color for all animation frames.
string animation = "Random_Keyboard.chroma";
Color color = Color.red;
UnityNativeChromaSDK.SetKeysColorAllFramesName(animation,
new int[] {
(int)UnityNativeChromaSDK.Keyboard.RZKEY.RZKEY_I,
(int)UnityNativeChromaSDK.Keyboard.RZKEY.RZKEY_J,
(int)UnityNativeChromaSDK.Keyboard.RZKEY.RZKEY_K,
(int)UnityNativeChromaSDK.Keyboard.RZKEY.RZKEY_L,
(int)UnityNativeChromaSDK.Keyboard.RZKEY.RZKEY_ENTER},
color);
Get the current frame of the animation.
string animation = "Random_Keyboard.chroma";
int currentFrame = UnityNativeChromaSDK.GetCurrentFrameName(animation)
Set the current frame of the animation.
string animation = "Random_Keyboard.chroma";
int frameId = 0;
UnityNativeChromaSDK.SetCurrentFrameName(animation, frameId);
Check if the animation is paused.
string animation = "Random_Keyboard.chroma";
bool isPaused = UnityNativeChromaSDK.IsAnimationPausedName(animation);
Check if the animation has loop ON
or OFF
.
string animation = "Random_Keyboard.chroma";
bool loop = UnityNativeChromaSDK.HasAnimationLoopName(animation);
Pause the animation.
string animation = "Random_Keyboard.chroma";
UnityNativeChromaSDK.PauseAnimationName(animation);
Resume playing the animation with loop ON
or OFF
.
string animation = "Random_Keyboard.chroma";
bool loop = true;
UnityNativeChromaSDK.ResumeAnimationName(animation, loop);
Play a set of animations with loop ON
or OFF
. A set includes ChromaLink, Headset, Keyboard, Keypad, Mouse, and Mousepad.
string composite = "Random";
bool loop = true;
UnityNativeChromaSDK.PlayComposite(composite, loop);
Stop playing a set of animations.
string composite = "Random";
UnityNativeChromaSDK.StopComposite(composite);
Check if an animation is playing.
string animation = "Random_Keyboard.chroma";
bool isPlaying = UnityNativeChromaSDK.IsPlaying(animation);
Check if the current platform supports playing Chroma.
bool isPlatformSupported = UnityNativeChromaSDK.PluginIsPlatformSupported();
MultiplyIntensityAllFramesName
The MultiplyIntensityAllFramesName
method multiplies a color intensity for all frames of an animation. This is useful to control the intensity of a layer. 0.0
results in a completely black layer. 0.5
would half the color values for all frames.
string baseLayer = "EnvironmentSnow_Keyboard.chroma";
// reload the animation
UnityNativeChromaSDK.CloseAnimationName(baseLayer);
// set the intensity of the layer
UnityNativeChromaSDK.MultiplyIntensityAllFramesName(baseLayer, _mBaseIntensity);
OffsetNonZeroColorsAllFramesName
The OffsetNonZeroColorsAllFrames
method offsets the RGB values for all frames in the animation that aren't black. This method allows a gray animation layer to be tinted to any color while keeping the black colors black. Red, green, blue use expected values 0
to 255
.
string layer2 = "RingGray_Keyboard.chroma";
// reload the animation
UnityNativeChromaSDK.CloseAnimationName(layer2);
//animation starts with 127,127,127 so adding -127,127,-127 results in 0,255,0 or green
UnityNativeChromaSDK.OffsetNonZeroColorsAllFramesName(layer2, -127, 127, -127);
CopyNonZeroAllKeysAllFramesName
The CopyNonZeroAllKeysAllFramesName
method copies all non-black colors for all frames from a source animation to a target animation. This is useful for combining multiple layers into a base layer.
UnityNativeChromaSDK.CopyNonZeroAllKeysAllFramesName(sourceAnimation, targetAnimation);
Example01
UnityNativeChromaSDKExample01.cs has a GUI example to play/stop/edit Chroma
animations at runtime.
Example02
UnityNativeChromaSDKExample02.cs has a GUI button to load scene 1 to show animations work with multiple scenes.
UnityNativeChromaSDKPlayOnEnable
The UnityNativeChromaSDKPlayOnEnable.cs script will automatically open and play a Chroma
animation by name.
The AnimationName
field references a .chroma
asset filename
from the StreamingAssets
folder.
The .chroma
extension on the AnimationName
field is optional.
The UnityNativeChromaSDKPlayOnEnable.cs
script will play the animation when the OnEnable
event fires.
The UnityNativeChromaSDKPlayOnEnable.cs
script will stop the animation when the OnDisable
event fires.
Example03
Particle capture example
Example04
Show PlayOnEnable
script
Example05
Image plane capture example
Example06
Show PlayAndDeactivate
script
Example07
Show PlayOnDestroy
script
Example08
SetKeys
and CopyKeys
can be used to highlight keys on top of an animated base layer.
Example09
Chroma animations can be paused and resumed with looping ON or OFF.
Example10
Chroma animations support independent layering.