/// <summary>
        /// Change character configuarion based on CharacterConfig
        /// </summary>
        /// <param name="config">CharacterConfiguration</param>
        public void ChangeCharacter(CharacterConfig config)
        {
            Clear();

            currentGender = config.gender;
            characterBase = config.characterBase;

            if (PopBloopSettings.useLogs)
            {
                Debug.Log("CharacterGenerator: Loading Character : " + characterBase);
            }

            BuildElementsFromConfig(config);
        }
        /// <summary>
        /// Load a Character Configuration to generate character with
        /// </summary>
        /// <param name="config"></param>
        public void LoadConfig(CharacterConfig config)
        {
            if (config == null)
            {
                Debug.Log("CharacterGenerator: Can not load null character configuration");
                return;
            }

            if (currentGender != config.gender)
            {
                ChangeCharacter(config);
            }
            else
            {
                BuildElementsFromConfig(config);
            }
        }
        /// <summary>
        /// Change Character Configuration using JSON string Array<Dictionary>
        /// </summary>
        /// <param name="content">JSON array of dictionary</param>
        /// <returns>true if valid, false otherwise</returns>
        public bool ChangeCharacterFromJSON(string content)
        {
            if (content == "")
            {
                return false;
            }

            string json = content;

            List<Dictionary<string, string>> jsonValues = null;
            try
            {
                jsonValues = JsonMapper.ToObject<List<Dictionary<string, string>>>(json);
                //TODOCHECK
                //jsonValues = JsonConvert.DeserializeObject<List<Dictionary<string, string>>>(json);
            }
            catch (Exception ex)
            {
                Debug.LogError("Error on JsonConvert Array: " + ex.Message);
                return false;
            }

            bool result = false;

            if (jsonValues != null)
            {
                CharacterConfig config = new CharacterConfig();

                ///*********** SAVE UNDO HERE ************************/

                if (currentCharacterConfig != null)
                {
                    var undo = currentCharacterConfig.CharacterConfigToJson(SkinColorIndex, IsUseHat);
                    Debug.LogWarning("saving undo: " + undo);
                    UndoData data = new UndoData(UndoType.Character, undo);
                    undoStacks.Push(data);
                }

                currentCharacterConfig = config;

                ///***************************************************/

                foreach (Dictionary<string, string> map in jsonValues)
                {
                    if (map.ContainsKey("tipe") == false)
                    {
                        continue;
                    }

                    string tipe = map["tipe"];

                    if (tipe.ToLower() == "gender")
                    {
                        config.characterBase = map["element"];
                    }
                    else if (tipe.ToLower() == "skin")
                    {
                        if (map.ContainsKey("color"))
                        {
                            string color = map["color"];
                            if (string.IsNullOrEmpty(color) || color.ToLower() == "nan")
                            {
                                color = "1";
                            }
                            
                            _skinColorIndex = Int32.Parse(color);
                        }
                    }
                    else
                    {
                        CharacterConstants.BodyPart bodyPart = (CharacterConstants.BodyPart)Enum.Parse(typeof(CharacterConstants.BodyPart), tipe, true);
                        string element = map["element"];

                        string id = map.ContainsKey("id") ? map["id"] : "";

                        if (bodyPart == CharacterConstants.BodyPart.Face)
                        {
                            // Only for face
                            string eyeBrows = map["eye_brows"];
                            string eyes = map["eyes"];
                            string lip = map["lip"];

                            config.face = element;
                            config.eyeBrows = eyeBrows;
                            config.eyes = eyes;
                            config.lip = lip;
                            config.faceId = id;
                        }
                        else
                        {
                            string material = map["material"];

                            switch (bodyPart)
                            {
                                case CharacterConstants.BodyPart.Hat:
                                    config.hatId = id;
                                    config.hat = element;
                                    config.hatMaterial = material;
                                    break;

                                case CharacterConstants.BodyPart.Hair:
                                    config.hairId = id;
                                    config.hair = element;
                                    config.hairMaterial = material;
                                    break;

                                case CharacterConstants.BodyPart.Face:
                                    config.faceId = id;
                                    config.face = element;
                                    config.faceMaterial = material;
                                    break;

                                case CharacterConstants.BodyPart.Body:
                                    config.bodyId = id;
                                    config.body = element;
                                    config.bodyMaterial = material;
                                    break;

                                case CharacterConstants.BodyPart.Pants:
                                    config.pantsId = id;
                                    config.pants = element;
                                    config.pantsMaterial = material;
                                    break;

                                case CharacterConstants.BodyPart.Shoes:
                                    config.shoesId = id;
                                    config.shoes = element;
                                    config.shoesMaterial = material;
                                    break;

                                case CharacterConstants.BodyPart.Hand:
                                    config.handId = id;
                                    config.hand = element;
                                    config.handMaterial = material;
                                    break;

                                case CharacterConstants.BodyPart.HairBottom:
                                    config.hairBottomId = id;
                                    config.hairBottom = element;
                                    config.hairBottomMaterial = material;
                                    break;
                            }
                        }
                    }
                }

                ChangeCharacter(config);
                result = true;
                
                //Debug.LogWarning(config.CharacterConfigToJson(SkinColorIndex, IsUseHat));
            }

            return result;
        }
 /// <summary>
 /// Build Elements from a given Character Configuration
 /// </summary>
 /// <param name="config">Configuration</param>
 private void BuildElementsFromConfig(CharacterConfig config)
 {
     //ChangeElement(CharacterConstants.BodyPart.Hat, config.hat, config.hatMaterial);
     ChangeFaceElement(config.face, config.eyeBrows, config.eyes, config.lip);
     //Debug.LogError("CG: hat: " + config.hat + ", mat: " + config.hatMaterial);
     //ChangeElement(CharacterConstants.BodyPart.Hat, config.hat, config.hatMaterial);
     //ChangeElement(CharacterConstants.BodyPart.Hair, config.hair, config.hairMaterial);
     ChangeHairElement(config.hair, config.hairMaterial, config.hat, config.hatMaterial);
     ChangeElement(CharacterConstants.BodyPart.Body, config.body, config.bodyMaterial);
     ChangeElement(CharacterConstants.BodyPart.Hand, config.hand, config.handMaterial);
     ChangeElement(CharacterConstants.BodyPart.Pants, config.pants, config.pantsMaterial);
     ChangeElement(CharacterConstants.BodyPart.Shoes, config.shoes, config.shoesMaterial);
 }