Exemple #1
0
        public override void OnInspectorGUI()
        {
            base.ShowCommonInspector();

            if (action.actor != null)
            {
                var character = action.actor.GetComponent <Character>();
                if (character != null)
                {
                    BlendShapeGroup current = null;
                    if (!string.IsNullOrEmpty(action.expressionUID))
                    {
                        current = character.FindExpressionByUID(action.expressionUID);
                    }
                    else
                    {
                        current = character.FindExpressionByName(action.expressionName);
                    }
                    var newExp = EditorTools.Popup <BlendShapeGroup>("Expression", current, character.expressions);
                    action.expressionName = newExp != null ? newExp.name : null;
                    action.expressionUID  = newExp != null ? newExp.UID : null;
                }
            }

            base.ShowAnimatableParameters();
        }
Exemple #2
0
        public override void OnInspectorGUI()
        {
            base.ShowCommonInspector();

            GUI.enabled = action.root.currentTime <= 0;

            if (action.actor == null)
            {
                action.skinName  = EditorGUILayout.TextField("Skin", action.skinName);
                action.shapeName = EditorGUILayout.TextField("Shape", action.shapeName);
                return;
            }

            var skins = action.actor.GetComponentsInChildren <SkinnedMeshRenderer>().Where(s => s.sharedMesh.blendShapeCount > 0).ToList();

            if (skins == null || skins.Count == 0)
            {
                EditorGUILayout.HelpBox("There are no Skinned Mesh Renderers with blend shapes within the actor's GameObject hierarchy.", MessageType.Warning);
                return;
            }

            action.skinName = EditorTools.Popup <string>("Skin", action.skinName, skins.Select(s => s.name).ToList());
            if (action.skinName != string.Empty)
            {
                var skin = skins.ToList().Find(s => s.name == action.skinName);
                if (skin != null)
                {
                    action.shapeName = EditorTools.Popup <string>("Shape", action.shapeName, skin.GetBlendShapeNames().ToList());
                }
            }

            base.ShowAnimatableParameters();
        }
Exemple #3
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            var att        = (ActorGroupPopupAttribute)attribute;
            var directable = property.serializedObject.targetObject as IDirectable;

            if (directable != null)
            {
                var allActorGroups  = (directable.root as Cutscene).groups.OfType <ActorGroup>().ToList();
                var overrideCurrent = (ActorGroup)property.objectReferenceValue;
                var overrideNew     = EditorTools.Popup <ActorGroup>(position, label.text, overrideCurrent, allActorGroups);
                if (overrideNew != overrideCurrent)
                {
                    property.objectReferenceValue = overrideNew;
                }
            }
        }
        public override void OnInspectorGUI()
        {
            GUILayout.Space(10);

            serializedObject.Update();
            EditorTools.Header("Head Look At");
            EditorGUILayout.PropertyField(neckProp);
            EditorGUILayout.PropertyField(headProp);
            EditorGUILayout.PropertyField(upVectorProp);
            EditorGUILayout.PropertyField(rotationOffsetProp);
            serializedObject.ApplyModifiedProperties();

            GUILayout.Space(10);

            EditorTools.Header("Expressions");
            var skins = character.GetComponentsInChildren <SkinnedMeshRenderer>().Where(s => s.sharedMesh.blendShapeCount > 0).ToList();

            if (skins == null || skins.Count == 0)
            {
                EditorGUILayout.HelpBox("There are no Skinned Mesh Renderers with blend shapes within the actor's GameObject hierarchy.", MessageType.Warning);
                return;
            }

            if (GUILayout.Button("Create New Expression"))
            {
                Undo.RecordObject(character, "Add Expression");
                character.expressions.Add(new BlendShapeGroup());
            }

            GUILayout.Space(5);


            EditorGUI.indentLevel++;
            foreach (var expression in character.expressions.ToArray())
            {
                var foldState = false;
                if (!foldStates.TryGetValue(expression, out foldState))
                {
                    foldStates[expression] = false;
                }

                GUI.backgroundColor = new Color(0, 0, 0, 0.3f);
                GUILayout.BeginVertical(Slate.Styles.headerBoxStyle);
                GUI.backgroundColor = Color.white;

                GUILayout.BeginHorizontal();
                foldStates[expression] = EditorGUILayout.Foldout(foldStates[expression], expression.name);
                if (GUILayout.Button("X", GUILayout.Width(18)))
                {
                    Undo.RecordObject(character, "Remove Expression");
                    expression.weight = 0;
                    character.expressions.Remove(expression);
                }
                GUILayout.EndHorizontal();

                if (foldStates[expression])
                {
                    EditorGUI.BeginChangeCheck();
                    var expName   = EditorGUILayout.TextField("Name", expression.name);
                    var expWeight = EditorGUILayout.Slider("Debug Weight", expression.weight, 0, 1);
                    if (EditorGUI.EndChangeCheck())
                    {
                        Undo.RecordObject(character, "Expression Changed");
                        expression.name   = expName;
                        expression.weight = expWeight;
                    }


                    foreach (var shape in expression.blendShapes.ToArray())
                    {
                        GUILayout.BeginHorizontal("box");

                        GUILayout.BeginVertical();
                        var skin   = shape.skin;
                        var name   = shape.name;
                        var weight = shape.weight;
                        EditorGUI.BeginChangeCheck();
                        skin = EditorTools.Popup <SkinnedMeshRenderer>("Skin", skin, skins);
                        if (skin != null)
                        {
                            name   = EditorTools.Popup <string>("Shape", name, skin.GetBlendShapeNames().ToList());
                            weight = EditorGUILayout.Slider("Weight", weight, 0, 1);
                        }
                        GUILayout.EndVertical();

                        if (skin != shape.skin || name != shape.name)
                        {
                            shape.SetRealWeight(0);
                        }

                        if (EditorGUI.EndChangeCheck())
                        {
                            Undo.RecordObject(character, "Expression Changed");
                            shape.skin   = skin;
                            shape.name   = name;
                            shape.weight = weight;
                        }

                        if (GUILayout.Button("X", GUILayout.Width(18), GUILayout.Height(50)))
                        {
                            Undo.RecordObject(character, "Remove Expression Blend Shape");
                            shape.SetRealWeight(0);
                            expression.blendShapes.Remove(shape);
                        }

                        GUILayout.EndHorizontal();
                        GUILayout.Space(5);
                    }

                    if (GUILayout.Button("Add Blend Shape"))
                    {
                        Undo.RecordObject(character, "Add Expression Blend Shape");
                        expression.blendShapes.Add(new BlendShape());
                    }

                    GUILayout.Space(5);
                }

                GUILayout.EndVertical();
                GUILayout.Space(5);
            }

            EditorGUI.indentLevel--;


            if (GUI.changed)
            {
                EditorUtility.SetDirty(character);
            }
        }