Esempio n. 1
0
    public void OnAnimationSelected()
    {
        GameObject objInstance = AnimationEditorFunctions.InstantiateWithAnimation(sessionModel, sessionAnim);

        //TODO: May have to change this, since we might not want the actual model a child of the animation visualizer.
        GameObject newThing = new GameObject();

        newThing.transform.localPosition.Set(objInstance.transform.localPosition.x, objInstance.transform.localPosition.y, objInstance.transform.localPosition.z);

        objInstance.transform.parent = newThing.transform;

        objInstance.transform.localPosition.Set(0f, 0f, 0f);

        newThing.transform.parent        = animVis.transform;
        newThing.transform.localPosition = new Vector3(0f, 0f, 0f);

        //-------End TODO

        animVis.SetCurrentClipAndGameObject(sessionAnim, objInstance);
    }
Esempio n. 2
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.KeypadEnter))
        {
            //animClip = AnimationEditorFunctions.CreateNewAnimation (string.Concat("Test", System.DateTime.Now.Minute.ToString()));
            animClip = AnimationEditorFunctions.CreateNewAnimation("Test");
            GameObject go = AnimationEditorFunctions.InstantiateWithAnimation(testPrefab, animClip);
            animVisual.SetCurrentClipAndGameObject(animClip, go);
        }

        if (Input.GetKeyDown(KeyCode.KeypadPlus))
        {
            //Debug.Log ("Hey!");

            AnimationCurve testCurve = new AnimationCurve();
            Keyframe       key1      = new Keyframe();
            Keyframe       key2      = new Keyframe();

            key1.time  = 0f;
            key1.value = 2;

            key2.time  = 2f;
            key2.value = 1;

            testCurve.AddKey(key1);
            testCurve.AddKey(key2);

            animClip.SetCurve("", typeof(Transform), "localPosition.y", testCurve);

            animVisual.RefreshCurves();
        }
        if (Input.GetKeyDown(KeyCode.KeypadMinus))
        {
            //Debug.Log ("Hey!");

            AnimationCurve testCurve = new AnimationCurve();
            Keyframe       key1      = new Keyframe();
            Keyframe       key2      = new Keyframe();

            key1.time  = 0f;
            key1.value = 3f;

            key2.time  = 4f;
            key2.value = -5f;

            testCurve.AddKey(key1);
            testCurve.AddKey(key2);

            animClip.SetCurve("", typeof(Transform), "localPosition.x", testCurve);

            animVisual.RefreshCurves();
        }

        if (Input.GetKeyDown(KeyCode.KeypadDivide))
        {
            animVisual.TogglePlayAnimation();
        }

        if (Input.GetKeyDown(KeyCode.KeypadMultiply))
        {
            animClip.ClearCurves();
            animVisual.RefreshCurves();
        }
    }