示例#1
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);
    }
    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();
    }
示例#4
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;
    }