Пример #1
0
    public void RingGray()
    {
        //UnityNativeChromaSDK.PlayAnimationName("Blank_Keyboard.chroma");

        baseLayer = "RingGray_Keyboard.chroma";
        UnityNativeChromaSDK.CloseAnimationName(baseLayer);
        UnityNativeChromaSDK.MultiplyIntensityAllFramesName(baseLayer, 1.0f + 64.0f * _mBaseIntensity);

        List <int> keyList = new List <int>();

        if (w)
        {
            keyList.Add((int)UnityNativeChromaSDK.Keyboard.RZKEY.RZKEY_W);
        }
        if (a)
        {
            keyList.Add((int)UnityNativeChromaSDK.Keyboard.RZKEY.RZKEY_A);
        }
        if (s)
        {
            keyList.Add((int)UnityNativeChromaSDK.Keyboard.RZKEY.RZKEY_S);
        }
        if (d)
        {
            keyList.Add((int)UnityNativeChromaSDK.Keyboard.RZKEY.RZKEY_D);
        }

        int[] keys = keyList.ToArray();

        Color color = new Color(_mHotkeyIntensity * 1, _mHotkeyIntensity * 0.5f, 0);

        UnityNativeChromaSDK.SetKeysColorAllFramesName(baseLayer, keys, color);

        UnityNativeChromaSDK.PlayAnimationName(baseLayer, true);
    }
Пример #2
0
    // Play the animation on enable
    void OnEnable()
    {
        // Turn off script if platform is not supported
        if (!UnityNativeChromaSDK.IsPlatformSupported())
        {
            enabled = false;
            return;
        }

        _mAnimationName = UnityNativeChromaSDK.GetAnimationNameWithExtension(AnimationName);
        UnityNativeChromaSDK.PlayAnimationName(_mAnimationName, Loop);
    }
    // Play the animation on enable
    void OnDestroy()
    {
        // Turn off script if platform is not supported
        if (!UnityNativeChromaSDK.IsPlatformSupported())
        {
            enabled = false;
            return;
        }

        string animationName = UnityNativeChromaSDK.GetAnimationNameWithExtension(AnimationName);

        UnityNativeChromaSDK.PlayAnimationName(animationName);
    }
Пример #4
0
    private void ClickHeal()
    {
        int[] keys = new int[]
        {
            (int)UnityNativeChromaSDK.Keyboard.RZLED.RZLED_LOGO,
            (int)UnityNativeChromaSDK.Keyboard.RZKEY.RZKEY_ESC,
            (int)UnityNativeChromaSDK.Keyboard.RZKEY.RZKEY_Q,
            (int)UnityNativeChromaSDK.Keyboard.RZKEY.RZKEY_E
        };

        string baseLayer = "EnvironmentSnow_Keyboard.chroma";

        UnityNativeChromaSDK.CloseAnimationName(baseLayer);
        UnityNativeChromaSDK.MultiplyIntensityAllFramesName(baseLayer, 1.0f + 64.0f * _mBaseIntensity);

        string layer2 = "RingGray_Keyboard.chroma";

        UnityNativeChromaSDK.CloseAnimationName(layer2);
        // turn animation green
        UnityNativeChromaSDK.OffsetNonZeroColorsAllFramesName(layer2, -127, 127, -127); //animation starts with 127,127,127 so adding -127,127,-127 results in 0,255,0 or green
        // set intensity
        UnityNativeChromaSDK.MultiplyIntensityAllFramesName(layer2, _mEffectIntensity);
        UnityNativeChromaSDK.CopyNonZeroAllKeysAllFramesName(layer2, baseLayer);

        string layer3 = "FadeInOutGray_Keyboard.chroma";

        UnityNativeChromaSDK.CloseAnimationName(layer3);
        // change color
        UnityNativeChromaSDK.OffsetNonZeroColorsAllFramesName(layer3, 173 - 127, 255 - 127, 47 - 127);
        // set intensity
        UnityNativeChromaSDK.MultiplyIntensityAllFramesName(layer3, _mHotkeyIntensity);
        UnityNativeChromaSDK.CopyKeysColorAllFramesName(layer3, baseLayer, keys);

        keys = 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
        };

        Color color = new Color(_mHotkeyIntensity * 1, _mHotkeyIntensity * 0.5f, 0);

        UnityNativeChromaSDK.SetKeysColorAllFramesName(baseLayer, keys, color);

        UnityNativeChromaSDK.PlayAnimationName(baseLayer, true);
    }
Пример #5
0
    void Movement(Vector2 move)
    {
        GameObject bear = GameObject.FindWithTag("bear");

        if (RB2D.position.y > -5)
        {
            //RB2D.position += move;
            RB2D.rotation += Random.Range(0f, Mathf.Abs(velocity.y) * 2f);
        }
        else if (true)
        {
            velocity.y = RB2D.velocity.y * Random.Range(-0.8f, -0.9f);
            velocity.x = RB2D.velocity.x * Random.Range(0.8f, 0.9f);
            AudioData.Play();
            float distanceToBear = Vector2.Distance(bear.transform.position, RB2D.position);

            AudioData.volume = Mathf.Max(0, 1.0f / (distanceToBear + 0.1f) + 0.001f * velocity.y * velocity.y);
            //Debug.Log("AudioData.volume: " + AudioData.volume);
            if (velocity.magnitude < 0.01f)
            {
                RB2D.rotation    = 0;
                AudioData.volume = 0;
                // UnityNativeChromaSDK.SetCurrentFrameName("anim.chroma", 1);
                RB2D.velocity = 0 * RB2D.velocity;
                UnityNativeChromaSDK.StopAnimationName("anim.chroma");
            }
            else
            {
                //  UnityNativeChromaSDK.SetCurrentFrameName("anim.chroma", 0);
            }

            UnityNativeChromaSDK.PlayAnimationName("anim.chroma", false);
            // RB2D.rotation = -RB2D.rotation;
            //RB2D.position -= move;
        }

        if (RB2D.position.x > 19 || RB2D.position.x < -19)
        {
            velocity.x = -velocity.x;
        }
        RB2D.velocity = velocity;
    }
    private void OnGUI()
    {
        if (!UnityNativeChromaSDK.IsPlatformSupported())
        {
            GUILayout.BeginVertical(GUILayout.Height(Screen.height));
            GUILayout.FlexibleSpace();
            GUILayout.BeginHorizontal(GUILayout.Width(Screen.width));
            GUILayout.FlexibleSpace();
            GUILayout.Label("The ChromaSDK is not supported on this platform!");
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.EndVertical();
            return;
        }

        bool isInitialized = UnityNativeChromaSDK.PluginIsInitialized();
        GUILayout.BeginVertical(GUILayout.Height(Screen.height));
        GUILayout.FlexibleSpace();
        GUILayout.BeginHorizontal(GUILayout.Width(Screen.width));
        GUILayout.FlexibleSpace();
        if (GUILayout.Button("Load Scene 2"))
        {
#if UNITY_3 || UNITY_3_0 || UNITY_3_1 || UNITY_3_2 || UNITY_3_3 || UNITY_3_4 || UNITY_3_5
            Application.LoadLevel(1);
#else
            SceneManager.LoadScene(1);
#endif
        }
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();
        GUILayout.BeginHorizontal(GUILayout.Width(Screen.width));
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();
        GUILayout.BeginHorizontal(GUILayout.Width(Screen.width));
        GUILayout.FlexibleSpace();
        GUI.enabled = isInitialized;
        if (GUILayout.Button("PLAY", GUILayout.Height(30)))
        {
            UnityNativeChromaSDK.PlayComposite("Random", false);
        }
        if (GUILayout.Button("LOOP", GUILayout.Height(30)))
        {
            UnityNativeChromaSDK.PlayComposite("Random", true);
        }
        if (GUILayout.Button("STOP", GUILayout.Height(30)))
        {
            UnityNativeChromaSDK.StopComposite("Random");
        }
        if (GUILayout.Button("RELOAD", GUILayout.Height(30)))
        {
            foreach (string animation in _mAnimations)
            {
                UnityNativeChromaSDK.CloseAnimationName(animation);
            }
        }
#endif
        GUI.enabled = true;
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();
        foreach (string animation in _mAnimations)
        {
            GUILayout.BeginHorizontal(GUILayout.Width(Screen.width));
            GUILayout.FlexibleSpace();
            GUILayout.Label(string.Format("{0}:", UnityNativeChromaSDK.GetDevice(animation)));
            GUILayout.Label(animation);
            GUI.enabled = isInitialized;
            if (GUILayout.Button("Play", GUILayout.Height(30)))
            {
                UnityNativeChromaSDK.PlayAnimationName(animation);
            }
            if (GUILayout.Button("Loop", GUILayout.Height(30)))
            {
                UnityNativeChromaSDK.PlayAnimationName(animation, true);
            }
            if (GUILayout.Button("Stop", GUILayout.Height(30)))
            {
                UnityNativeChromaSDK.StopAnimationName(animation);
            }
            if (GUILayout.Button("Reload", GUILayout.Height(30)))
            {
                UnityNativeChromaSDK.CloseAnimationName(animation);
            }
            if (GUILayout.Button("Edit", GUILayout.Height(30)))
            {
                UnityNativeChromaSDK.EditAnimation(animation);
            }
            GUI.enabled = true;
            GUILayout.Label(string.Format("({0} frames)", UnityNativeChromaSDK.GetFrameCountName(animation)));
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
        }
        GUILayout.BeginHorizontal(GUILayout.Width(Screen.width));
        GUILayout.FlexibleSpace();
        if (GUILayout.Button("QUIT", GUILayout.Height(30)))
        {
            Application.Quit();
        }
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();
        GUILayout.FlexibleSpace();
        GUILayout.EndVertical();
    }
Пример #7
0
    private void OnGUI()
    {
        if (!UnityNativeChromaSDK.IsPlatformSupported())
        {
            GUILayout.BeginVertical(GUILayout.Height(Screen.height));
            GUILayout.FlexibleSpace();
            GUILayout.BeginHorizontal(GUILayout.Width(Screen.width));
            GUILayout.FlexibleSpace();
            GUILayout.Label("The ChromaSDK is not supported on this platform!");
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.EndVertical();
            return;
        }

        GUI.enabled = UnityNativeChromaSDK.PluginIsInitialized();

        GUILayout.BeginVertical(GUILayout.Height(Screen.height));
        GUILayout.FlexibleSpace();

        GUILayout.Label(string.Format("Frame Count: {0}",
                                      UnityNativeChromaSDK.GetFrameCountName(ANIMATION)));

        GUILayout.Label(string.Format("Current Frame: {0}",
                                      UnityNativeChromaSDK.GetCurrentFrameName(ANIMATION)));

        GUILayout.Label(string.Format("Is Paused: {0}",
                                      UnityNativeChromaSDK.IsAnimationPausedName(ANIMATION)));

        GUILayout.Label(string.Format("Has Loop: {0}",
                                      UnityNativeChromaSDK.HasAnimationLoopName(ANIMATION)));

        _mStrFrame = GUILayout.TextField(_mStrFrame, GUILayout.Width(150));
        if (GUILayout.Button("Set Frame", GUILayout.Width(200), GUILayout.Height(60)))
        {
            int frameId;
            if (int.TryParse(_mStrFrame, out frameId))
            {
                _mStrFrame = frameId.ToString();
                UnityNativeChromaSDK.SetCurrentFrameName(ANIMATION, frameId);
            }
        }

        GUILayout.FlexibleSpace();

        GUILayout.BeginHorizontal(GUILayout.Width(Screen.width));
        GUILayout.FlexibleSpace();
        if (GUILayout.Button("Play", GUILayout.Height(60)))
        {
            UnityNativeChromaSDK.PlayAnimationName(ANIMATION, false);
        }
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();

        GUI.enabled = UnityNativeChromaSDK.IsPlaying(ANIMATION);

        GUILayout.BeginHorizontal(GUILayout.Width(Screen.width));
        GUILayout.FlexibleSpace();
        if (GUILayout.Button("Pause", GUILayout.Height(60)))
        {
            UnityNativeChromaSDK.PauseAnimationName(ANIMATION);
        }
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal(GUILayout.Width(Screen.width));
        GUILayout.FlexibleSpace();
        if (GUILayout.Button("Resume", GUILayout.Height(60)))
        {
            UnityNativeChromaSDK.ResumeAnimationName(ANIMATION, false);
        }
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal(GUILayout.Width(Screen.width));
        GUILayout.FlexibleSpace();
        if (GUILayout.Button("Resume Loop", GUILayout.Height(60)))
        {
            UnityNativeChromaSDK.ResumeAnimationName(ANIMATION, true);
        }
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();

        GUILayout.FlexibleSpace();
        GUILayout.EndVertical();

        GUI.enabled = true;
    }
    private void OnGUI()
    {
        if (!UnityNativeChromaSDK.IsPlatformSupported())
        {
            GUILayout.BeginVertical(GUILayout.Height(Screen.height));
            GUILayout.FlexibleSpace();
            GUILayout.BeginHorizontal(GUILayout.Width(Screen.width));
            GUILayout.FlexibleSpace();
            GUILayout.Label("The ChromaSDK is not supported on this platform!");
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.EndVertical();
            return;
        }

        GUI.enabled = UnityNativeChromaSDK.PluginIsInitialized();

        GUILayout.BeginVertical(GUILayout.Height(Screen.height));
        GUILayout.FlexibleSpace();

        GUILayout.BeginHorizontal(GUILayout.Width(Screen.width));
        GUILayout.FlexibleSpace();

        if (GUILayout.Button("Show Hotkeys", GUILayout.Height(60)))
        {
            UnityNativeChromaSDK.CloseAnimationName(TARGET_ANIMATION);

            // copy colors from another animation
            UnityNativeChromaSDK.CopyKeysColorAllFramesName(SOURCE_ANIMATION, TARGET_ANIMATION,
                                                            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
            });

            // set static colors
            UnityNativeChromaSDK.SetKeysColorAllFramesName(TARGET_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.red);

            UnityNativeChromaSDK.PlayAnimationName(TARGET_ANIMATION, true);
        }

        GUILayout.FlexibleSpace();

        if (GUILayout.Button("Hide Hotkeys", GUILayout.Height(60)))
        {
            UnityNativeChromaSDK.CloseAnimationName(TARGET_ANIMATION);
            UnityNativeChromaSDK.PlayAnimationName(TARGET_ANIMATION, true);
        }

        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();
        GUILayout.FlexibleSpace();
        GUILayout.EndVertical();

        GUI.enabled = true;
    }