public override void OnInspectorGUI()
        {
            Shapeable _target = (Shapeable) target;

            _target.shapeGroups = AllGroupsGUI (_target.shapeGroups);

            if (selectedGroup != null)
            {
                List<string> blendShapeNames = new List<string>();
                if (_target.GetComponent <SkinnedMeshRenderer>() && _target.GetComponent <SkinnedMeshRenderer>().sharedMesh)
                {
                    for (int i=0; i<_target.GetComponent <SkinnedMeshRenderer>().sharedMesh.blendShapeCount; i++)
                    {
                        blendShapeNames.Add (_target.GetComponent <SkinnedMeshRenderer>().sharedMesh.GetBlendShapeName (i));
                    }
                }
                else
                {
                    EditorGUILayout.HelpBox ("This component should be attached to a Skinned Mesh Renderer.", MessageType.Warning);
                }

                selectedGroup = GroupGUI (selectedGroup, blendShapeNames.ToArray ());
            }

            if (GUI.changed)
            {
                EditorUtility.SetDirty (_target);
            }
        }
Пример #2
0
        public override void OnInspectorGUI()
        {
            Shapeable _target = (Shapeable)target;

            _target.shapeGroups = AllGroupsGUI(_target.shapeGroups);

            if (selectedGroup != null)
            {
                List <string> blendShapeNames = new List <string>();
                if (_target.GetComponent <SkinnedMeshRenderer>() && _target.GetComponent <SkinnedMeshRenderer>().sharedMesh)
                {
                    for (int i = 0; i < _target.GetComponent <SkinnedMeshRenderer>().sharedMesh.blendShapeCount; i++)
                    {
                        blendShapeNames.Add(_target.GetComponent <SkinnedMeshRenderer>().sharedMesh.GetBlendShapeName(i));
                    }
                }
                else
                {
                    EditorGUILayout.HelpBox("This component should be attached to a Skinned Mesh Renderer.", MessageType.Warning);
                }

                selectedGroup = GroupGUI(selectedGroup, blendShapeNames.ToArray());
            }

            if (GUI.changed)
            {
                EditorUtility.SetDirty(_target);
            }
        }
Пример #3
0
        /**
         * <summary>Sets a blendshape within a ShapeGroup as the "active" one, causing all others to be disabled.</summary>
         * <param name = "_groupLabel">The name of the ShapeGroup to affect</param>
         * <param name = "_keyLabel">The name of the blendshape to affect</param?
         * <param name = "_value">The value to set the active blendshape</param>
         * <param name = "_deltaTime">The duration, in seconds, that the group's blendshapes should be affected</param>
         * <param name = "_moveMethod">The interpolation method by which the blendshapes are affected (Linear, Smooth, Curved, EaseIn, EaseOut, CustomCurve)</param>
         * <param name = "_timeCurve">If _moveMethod = MoveMethod.CustomCurve, then the transition speed will be follow the shape of the supplied AnimationCurve. This curve can exceed "1" in the Y-scale, allowing for overshoot effects.</param>
         */
        public void SetActiveKey(string _groupLabel, string _keyLabel, float _value, float _deltaTime, MoveMethod _moveMethod, AnimationCurve _timeCurve)
        {
            ShapeGroup shapeGroup = GetGroup(_groupLabel);

            if (shapeGroup != null)
            {
                shapeGroup.SetActive(_keyLabel, _value, _deltaTime, _moveMethod, _timeCurve);
            }
        }
Пример #4
0
        /**
         * <summary>Sets a blendshape within a ShapeGroup as the "active" one, causing all others to be disabled.</summary>
         * <param name = "_groupID">The unique identifier of the ShapeGroup to affect</param>
         * <param name = "_keyID">The unique identifier of the blendshape to affect</param?
         * <param name = "_value">The value to set the active blendshape</param>
         * <param name = "_deltaTime">The duration, in seconds, that the group's blendshapes should be affected</param>
         * <param name = "_moveMethod">The interpolation method by which the blendshapes are affected (Linear, Smooth, Curved, EaseIn, EaseOut, CustomCurve)</param>
         * <param name = "_timeCurve">If _moveMethod = MoveMethod.CustomCurve, then the transition speed will be follow the shape of the supplied AnimationCurve. This curve can exceed "1" in the Y-scale, allowing for overshoot effects.</param>
         */
        public void SetActiveKey(int _groupID, int _keyID, float _value, float _deltaTime, MoveMethod _moveMethod, AnimationCurve _timeCurve)
        {
            ShapeGroup shapeGroup = GetGroup(_groupID);

            if (shapeGroup != null)
            {
                shapeGroup.SetActive(_keyID, _value, _deltaTime, _moveMethod, _timeCurve);
            }
        }
Пример #5
0
        /**
         * <summary>Disables all blendshapes within a ShapeGroup.</summary>
         * <param name = "_groupID">The unique identifier of the ShapeGroup to affect</param>
         * <param name = "_deltaTime">The duration, in seconds, that the group's blendshapes should be disabled</param>
         * <param name = "_moveMethod">The interpolation method by which the blendshapes are affected (Linear, Smooth, Curved, EaseIn, EaseOut, CustomCurve)</param>
         * <param name = "_timeCurve">If _moveMethod = MoveMethod.CustomCurve, then the transition speed will be follow the shape of the supplied AnimationCurve. This curve can exceed "1" in the Y-scale, allowing for overshoot effects.</param>
         */
        public void DisableAllKeys(string _groupLabel, float _deltaTime, MoveMethod _moveMethod, AnimationCurve _timeCurve)
        {
            ShapeGroup shapeGroup = GetGroup(_groupLabel);

            if (shapeGroup != null)
            {
                shapeGroup.SetActive(-1, 0f, _deltaTime, _moveMethod, _timeCurve);
            }
        }
Пример #6
0
        private List<ShapeGroup> AllGroupsGUI(List<ShapeGroup> shapeGroups)
        {
            EditorGUILayout.LabelField ("Shape groups", EditorStyles.boldLabel);

            foreach (ShapeGroup shapeGroup in shapeGroups)
            {
                EditorGUILayout.BeginHorizontal ();

                string buttonLabel = shapeGroup.ID + ": ";
                if (shapeGroup.label == "")
                {
                    buttonLabel += "(Untitled)";
                }
                else
                {
                    buttonLabel += shapeGroup.label;
                }

                bool buttonOn = false;
                if (selectedGroup == shapeGroup)
                {
                    buttonOn = true;
                }

                if (GUILayout.Toggle (buttonOn, buttonLabel, "Button"))
                {
                    if (selectedGroup != shapeGroup)
                    {
                        selectedGroup = shapeGroup;
                        selectedKey = null;
                    }
                }

                if (GUILayout.Button ("-", GUILayout.Width (20f), GUILayout.Height (15f)))
                {
                    shapeGroups.Remove (shapeGroup);
                    selectedGroup = null;
                    selectedKey = null;
                    break;
                }

                EditorGUILayout.EndHorizontal ();
            }

            if (GUILayout.Button ("Create new shape group"))
            {
                ShapeGroup newShapeGroup = new ShapeGroup (GetIDArray (shapeGroups));
                shapeGroups.Add (newShapeGroup);
                selectedGroup = newShapeGroup;
                selectedKey = null;
            }

            return shapeGroups;
        }
Пример #7
0
        private List <ShapeGroup> AllGroupsGUI(List <ShapeGroup> shapeGroups)
        {
            EditorGUILayout.LabelField("Shape groups", EditorStyles.boldLabel);

            foreach (ShapeGroup shapeGroup in shapeGroups)
            {
                EditorGUILayout.BeginHorizontal();

                string buttonLabel = shapeGroup.ID + ": ";
                if (shapeGroup.label == "")
                {
                    buttonLabel += "(Untitled)";
                }
                else
                {
                    buttonLabel += shapeGroup.label;
                }

                bool buttonOn = false;
                if (selectedGroup == shapeGroup)
                {
                    buttonOn = true;
                }

                if (GUILayout.Toggle(buttonOn, buttonLabel, "Button"))
                {
                    if (selectedGroup != shapeGroup)
                    {
                        selectedGroup = shapeGroup;
                        selectedKey   = null;
                    }
                }

                if (GUILayout.Button("-", GUILayout.Width(20f), GUILayout.Height(15f)))
                {
                    shapeGroups.Remove(shapeGroup);
                    selectedGroup = null;
                    selectedKey   = null;
                    break;
                }

                EditorGUILayout.EndHorizontal();
            }

            if (GUILayout.Button("Create new shape group"))
            {
                ShapeGroup newShapeGroup = new ShapeGroup(GetIDArray(shapeGroups));
                shapeGroups.Add(newShapeGroup);
                selectedGroup = newShapeGroup;
                selectedKey   = null;
            }

            return(shapeGroups);
        }
Пример #8
0
        public override void OnInspectorGUI()
        {
            Shapeable _target = (Shapeable) target;

            _target.shapeGroups = AllGroupsGUI (_target.shapeGroups);

            if (selectedGroup != null)
            {
                selectedGroup = GroupGUI (selectedGroup);
            }

            if (GUI.changed)
            {
                EditorUtility.SetDirty (_target);
            }
        }
Пример #9
0
        public override void OnInspectorGUI()
        {
            Shapeable _target = (Shapeable)target;

            _target.shapeGroups = AllGroupsGUI(_target.shapeGroups);

            if (selectedGroup != null)
            {
                selectedGroup = GroupGUI(selectedGroup);
            }

            if (GUI.changed)
            {
                EditorUtility.SetDirty(_target);
            }
        }
Пример #10
0
        private ShapeGroup GroupGUI(ShapeGroup shapeGroup, string[] blendShapeNames)
        {
            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Shape group " + shapeGroup.label, EditorStyles.boldLabel);

            shapeGroup.label     = EditorGUILayout.TextField("Group label:", shapeGroup.label);
            shapeGroup.shapeKeys = AllKeysGUI(shapeGroup.shapeKeys);

            if (selectedKey != null && shapeGroup.shapeKeys.Contains(selectedKey))
            {
                selectedKey = KeyGUI(selectedKey, blendShapeNames);
            }

            EditorGUILayout.EndVertical();

            return(shapeGroup);
        }
Пример #11
0
	private ShapeGroup GroupGUI (ShapeGroup shapeGroup)
	{
		EditorGUILayout.Space ();
		
		EditorGUILayout.BeginVertical ("Button");
		EditorGUILayout.LabelField ("Shape group " + shapeGroup.label, EditorStyles.boldLabel);
		
		shapeGroup.label = EditorGUILayout.TextField ("Group label:", shapeGroup.label);
		
		shapeGroup.shapeKeys = AllKeysGUI (shapeGroup.shapeKeys);
		
		if (selectedKey != null && shapeGroup.shapeKeys.Contains (selectedKey))
		{
			selectedKey = KeyGUI (selectedKey);
		}
		
		EditorGUILayout.EndVertical ();
		
		return shapeGroup;
	}
Пример #12
0
        override public void ShowGUI(List <ActionParameter> parameters)
        {
            isPlayer = EditorGUILayout.Toggle("Is player?", isPlayer);
            if (!isPlayer)
            {
                parameterID = ChooseParameterGUI("Object:", parameters, parameterID, ParameterType.GameObject);
                if (parameterID >= 0)
                {
                    constantID  = 0;
                    shapeObject = null;
                }
                else
                {
                    shapeObject = (Shapeable)EditorGUILayout.ObjectField("Object:", shapeObject, typeof(Shapeable), true);

                    constantID  = FieldToID <Shapeable> (shapeObject, constantID);
                    shapeObject = IDToField <Shapeable> (shapeObject, constantID, false);
                }
            }
            else
            {
                Player _player = null;

                if (Application.isPlaying)
                {
                    _player = KickStarter.player;
                }
                else
                {
                    _player = AdvGame.GetReferences().settingsManager.GetDefaultPlayer();
                }

                if (_player != null && _player.GetShapeable())
                {
                    shapeObject = _player.GetShapeable();
                }
                else
                {
                    shapeObject = null;
                    EditorGUILayout.HelpBox("Cannot find player with Shapeable script attached", MessageType.Warning);
                }
            }

            if (shapeObject != null && shapeObject.shapeGroups != null)
            {
                shapeGroupID   = ActionBlendShape.ShapeableGroupGUI("Shape group:", shapeObject.shapeGroups, shapeGroupID);
                disableAllKeys = EditorGUILayout.Toggle("Disable all keys?", disableAllKeys);
                if (!disableAllKeys)
                {
                    ShapeGroup _shapeGroup = shapeObject.GetGroup(shapeGroupID);
                    if (_shapeGroup != null)
                    {
                        if (_shapeGroup.shapeKeys != null && _shapeGroup.shapeKeys.Count > 0)
                        {
                            shapeKeyID = ShapeableKeyGUI(_shapeGroup.shapeKeys, shapeKeyID);
                        }
                        else
                        {
                            EditorGUILayout.HelpBox("No shape keys found.", MessageType.Info);
                        }
                    }
                    shapeValue = EditorGUILayout.Slider("New value:", shapeValue, 0f, 100f);
                }
            }
            else
            {
                EditorGUILayout.HelpBox("An object must be assigned before more options can show.", MessageType.Info);
            }

            fadeTime = EditorGUILayout.FloatField("Transition time:", fadeTime);
            if (fadeTime > 0f)
            {
                moveMethod = (MoveMethod)EditorGUILayout.EnumPopup("Move method:", moveMethod);
                if (moveMethod == MoveMethod.CustomCurve)
                {
                    timeCurve = EditorGUILayout.CurveField("Time curve:", timeCurve);
                }
                willWait = EditorGUILayout.Toggle("Wait until finish?", willWait);
            }

            AfterRunningOption();
        }