Example #1
0
        public IEnumerator CreateCharacter()
        {
            if (IsPlayer)
            {
                // If there are already any objects tagged "Player" in the scene, disable them so that there is no conflict
                // with the newly created character
                var lExistingPlayers = GameObject.FindGameObjectsWithTag("Player");
                if (lExistingPlayers != null)
                {
                    foreach (var lPlayer in lExistingPlayers)
                    {
                        if (lPlayer.GetComponent <MotionController>() == null)
                        {
                            continue;
                        }
                        lPlayer.gameObject.SetActive(false);
                    }
                }
            }

            // Instantiate the character
            if (!string.IsNullOrEmpty(AssetDatabase.GetAssetPath(Character)))
            {
                // Use the entered Name (if not blank); default to the character model/prefab name
                string lName = string.IsNullOrEmpty(Name) ? Character.name : Name;
                Character      = GameObject.Instantiate(Character) as GameObject;
                Character.name = lName;
                yield return(mShortWait);
            }

            Character.SetActive(true);

            // Add the Motion Controller component
            MotionController lMotionController = CharacterSetupHelper.CreateMotionController(Character, IsPlayer);

            yield return(mShortWait);


            this.StartCoroutine(ActiveProfile.CreateCharacter(lMotionController, AnimatorPath, Name, IsPlayer));

            // Wait for the profile to finish
            while (ActiveProfile.IsWorking)
            {
                yield return(mShortWait);
            }

            yield return(mShortWait);

            EditorUtility.ClearProgressBar();
            Debug.Log("Character Wizard: Completed");

            yield return(mShortWait);

            this.Close();
        }