コード例 #1
0
    /****************************************************************************************************/
    private void CreateExpressionSetGUI()
    {
        EditorGUILayout.BeginVertical("Box");         //Root layout group
        {
            EditorGUILayout.LabelField("Step 2: Expression Set", titleStyle);
            EditorGUILayout.BeginHorizontal("Box");                                                                       //Scroll view container region
            {
                expressionScrollPos = GUILayout.BeginScrollView(expressionScrollPos, false, true, GUILayout.Height(300)); //Scroll view region
                EditorGUILayout.BeginVertical();
                GUILayoutOption buttonWidth = GUILayout.Width(95);
                foreach (KeyValuePair <string, string> kvp in charSetupData.GetExpressionNameAttrList()) //Create controls within scroll view
                {
                    EditorGUILayout.BeginHorizontal();                                                   //Individual control region
                    {
                        bool hasData = charSetupData.InUse(kvp.Value);
                        GUILayout.Label(hasData ? yesIcon : noIcon, GUILayout.Width(20));
                        EditorGUILayout.LabelField(kvp.Key, GUILayout.Width(205));
                        GUILayout.FlexibleSpace();
                        if (GUILayout.Button(hasData ? "Update Pose" : "Save Pose", buttonWidth))
                        {
                            bool updateExpression = true;
                            if (hasData)
                            {
                                updateExpression = EditorUtility.DisplayDialog("Update Pose", "Are you sure you want to overwrite this Pose?", "Yes", "No");
                            }
                            if (updateExpression)
                            {
                                List <string> controls = charSetupData.GetControlList();
                                if (controls.Count > 0)
                                {
                                    charSetupData.SetControlValues(kvp.Value, LiveUnityInterface.GetControlValues(currentCharSetupFile.rootObject, controls));
                                    charSetupData.SetInUse(kvp.Value, true);
                                    currentCharSetupFile.Expressions = charSetupData.data.Expressions;
                                    EditorUtility.SetDirty(currentCharSetupFile);
                                    AssetDatabase.SaveAssets();
                                }
                            }
                        }
                        if (GUILayout.Button("Show Saved", buttonWidth))
                        {
                            Undo.RecordObjects(sceneControlObjectList.ToArray(), ("Set '" + kvp.Key + "' Expression"));
                            LiveUnityInterface.ApplyControlValues(currentCharSetupFile.rootObject, charSetupData.GetControlValues(kvp.Value));
                        }
                    }
                    EditorGUILayout.EndHorizontal(); //End of individual control region
                }
                GUILayout.EndScrollView();           //End scroll view region
                GUILayout.FlexibleSpace();
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndVertical();

            CreateSpace(1);
            EditorGUILayout.BeginHorizontal(); //Reset to neutral button region
            {
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Reset Character to 'Neutral'", GUILayout.Width(496)))
                {
                    if (currentCharSetupFile != null)
                    {
                        LiveUnityInterface.ApplyControlValues(currentCharSetupFile.rootObject, charSetupData.GetControlValues("neutral"));
                    }
                    else
                    {
                        ShowNoSetupFileMsg();
                    }
                }
                GUILayout.FlexibleSpace();
            }
            EditorGUILayout.EndHorizontal(); //End neutral button region
        }
        CreateSpace(1);
        EditorGUILayout.EndVertical();
        CreateSpace(1);
    }
コード例 #2
0
    public void RecordFrame()
    {
        if (Recording && live.m_RecievedNewData)
        {
            live.m_RecievedNewData = false;
            //Grab values from rig
            Dictionary <string, Vector4> controlValues;
            if (cachedRigValues == null)
            {
                controlValues = LiveUnityInterface.GetControlValues(this.gameObject, character.GetControlList());
            }
            else
            {
                controlValues = cachedRigValues;
            }

            //Write keyframes for each control, if keyframe on new data only check if there is new data
            foreach (KeyValuePair <string, Vector4> controlKvp in controlValues)
            {
                string       controlName = controlKvp.Key;
                FTIAnimCurve curveData   = RecordedCurves[controlName];

                if (curveData.isBlendShape)
                {
                    if (!KeyframeOnNewData || curveData.animCurves[0].keys[curveData.animCurves[0].keys.Length - 1].value != controlKvp.Value.x)
                    {
                        Keyframe newFrame = new Keyframe(recordingTime, controlKvp.Value.x);
                        curveData.animCurves[0].AddKey(newFrame);
                    }
                }
                else
                {
                    if (!KeyframeOnNewData || curveData.animCurves[0].keys[curveData.animCurves[0].keys.Length - 1].value != controlKvp.Value.x)
                    {
                        Keyframe newFrame = new Keyframe(recordingTime, controlKvp.Value.x);
                        curveData.animCurves[0].AddKey(newFrame);
                    }

                    if (!KeyframeOnNewData || curveData.animCurves[1].keys[curveData.animCurves[1].keys.Length - 1].value != controlKvp.Value.y)
                    {
                        Keyframe newFrame = new Keyframe(recordingTime, controlKvp.Value.y);
                        curveData.animCurves[1].AddKey(newFrame);
                    }

                    if (!KeyframeOnNewData || curveData.animCurves[2].keys[curveData.animCurves[2].keys.Length - 1].value != controlKvp.Value.z)
                    {
                        Keyframe newFrame = new Keyframe(recordingTime, controlKvp.Value.z);
                        curveData.animCurves[2].AddKey(newFrame);
                    }

                    string attr = LiveHelpers.GetAttrString(controlName);

                    if (attr == LiveCharacterSetup.rotationSuffix)
                    {
                        if (!KeyframeOnNewData || curveData.animCurves[3].keys[curveData.animCurves[3].keys.Length - 1].value != controlKvp.Value.w)
                        {
                            Keyframe newFrame = new Keyframe(recordingTime, controlKvp.Value.w);
                            curveData.animCurves[3].AddKey(newFrame);
                        }
                    }
                }
            }
        }
    }
コード例 #3
0
    /****************************************************************************************************/
    private void CreateExpressionSetGUI()
    {
        EditorGUILayout.BeginVertical();
        {
            EditorGUILayout.LabelField("Step 2: Expression Set", titleStyle, GUILayout.ExpandHeight(true));

            EditorGUILayout.BeginHorizontal(exprSetBgStyle, GUILayout.Width(492));
            {
                expressionScrollPos = GUILayout.BeginScrollView(expressionScrollPos, false, true, GUILayout.Width(491), GUILayout.Height(300));
                EditorGUILayout.BeginVertical();
                GUILayoutOption buttonWidth = GUILayout.Width(95);
                foreach (KeyValuePair <string, string> kvp in charSetupData.GetExpressionNameAttrList())
                {
                    EditorGUILayout.BeginHorizontal(exprBgStyle);
                    {
                        bool hasData = charSetupData.InUse(kvp.Value);
                        GUILayout.Label(hasData ? yesIcon : noIcon, GUILayout.Width(20));
                        EditorGUILayout.LabelField(kvp.Key, GUILayout.Width(205));
                        if (GUILayout.Button(hasData ? "Update Pose" : "Save Pose", buttonWidth))
                        {
                            bool updateExpression = true;
                            if (hasData)
                            {
                                updateExpression = EditorUtility.DisplayDialog("Update Pose", "Are you sure you want to overwrite this Pose?", "Yes", "No");
                            }
                            if (updateExpression)
                            {
                                List <string> controls = charSetupData.GetControlList();
                                if (controls.Count > 0)
                                {
                                    charSetupData.SetControlValues(kvp.Value, LiveUnityInterface.GetControlValues(controls));
                                    charSetupData.SetInUse(kvp.Value, true);
                                }
                            }
                        }
                        if (GUILayout.Button("Show Saved", buttonWidth))
                        {
                            Undo.RecordObjects(sceneControlObjectList.ToArray(), ("Set '" + kvp.Key + "' Expression"));
                            LiveUnityInterface.ApplyControlValues(charSetupData.GetControlValues(kvp.Value));
                        }
                        if (GUILayout.Button(helpIcon, EditorStyles.miniButton))
                        {
                            System.Diagnostics.Process.Start("http://support.facewaretech.com/entries/37471737#" + kvp.Value);
                        }
                    }
                    EditorGUILayout.EndHorizontal();
                }
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndVertical();
            GUILayout.EndScrollView();

            CreateSpace(1);
            if (GUILayout.Button("Reset Character to 'Neutral'", GUILayout.Width(496)))
            {
                LiveUnityInterface.ApplyControlValues(charSetupData.GetControlValues("neutral"));
            }
        }
        EditorGUILayout.EndVertical();
        CreateSpace(2);
    }