void GenerateUMA() { // Create a new game object and add UMA components to it GameObject GO = new GameObject("MyUMA"); umaDynamicAvatar = GO.AddComponent<UMADynamicAvatar>(); // Initialise Avatar and grab a reference to it's data component umaDynamicAvatar.Initialize(); umaData = umaDynamicAvatar.umaData; // Attach our generator umaDynamicAvatar.umaGenerator = generator; umaData.umaGenerator = generator; // Set up slot Array umaData.umaRecipe.slotDataList = new SlotData[numberOfSlots]; // Set up our Morph reference umaDna = new UMADnaHumanoid(); umaTutorialDNA = new UMADnaTutorial(); umaData.umaRecipe.AddDna(umaDna); umaData.umaRecipe.AddDna(umaTutorialDNA); // Grab a reference to our recipe // var umaRecipe = umaDynamicAvatar.umaData.umaRecipe; //moved to subroutine MakeMale // >>> This is whee the fun will happen according to Secret Anorak <<<< CreateMale(); // Generate Our UMA umaDynamicAvatar.UpdateNewRace(); }
void GenerateUMA() { // Generate new GameObject and add UMA components to it GameObject GO = new GameObject("NPC"); umaDynamicAvatar = GO.AddComponent <UMADynamicAvatar> (); // Initialise Avatar and grab a reference to it's data component umaDynamicAvatar.Initialize(); umaData = umaDynamicAvatar.umaData; // Attach our generator umaDynamicAvatar.umaGenerator = generator; umaData.umaGenerator = generator; // Set up slot Array umaData.umaRecipe.slotDataList = new SlotData[numberOfSlots]; // Set up our Morph references umaDna = new UMADnaHumanoid(); umaData.umaRecipe.AddDna(umaDna); GenerateNPC(); umaDynamicAvatar.animationController = animController; // Generate our UMA umaDynamicAvatar.UpdateNewRace(); GO.transform.parent = this.gameObject.transform; GO.transform.localPosition = Vector3.zero; GO.transform.localRotation = Quaternion.identity; }
void GenerateUMA() { GameObject myUMA = new GameObject("MyUMA"); avatar = myUMA.AddComponent<UMADynamicAvatar>(); avatar.Initialize(); umaData = avatar.umaData; avatar.umaGenerator = generator; umaData.umaGenerator = generator; umaData.umaRecipe = new UMAData.UMARecipe(); umaData.umaRecipe.slotDataList = new SlotData[NUM_SLOTS]; umaDna = new UMADnaHumanoid(); umaTutorialDna = new UMADnaTutorial(); umaData.umaRecipe.AddDna(umaDna); umaData.umaRecipe.AddDna(umaTutorialDna); CreateMale(); avatar.animationController = animController; avatar.UpdateNewRace(); myUMA.transform.parent = this.gameObject.transform; myUMA.transform.localPosition = Vector3.zero; myUMA.transform.localRotation = Quaternion.identity; }
void GenerateUMA() { GameObject myUMA = new GameObject("MyUMA"); avatar = myUMA.AddComponent <UMADynamicAvatar>(); avatar.Initialize(); umaData = avatar.umaData; avatar.umaGenerator = generator; umaData.umaGenerator = generator; umaData.umaRecipe = new UMAData.UMARecipe(); umaData.umaRecipe.slotDataList = new SlotData[NUM_SLOTS]; umaDna = new UMADnaHumanoid(); umaTutorialDna = new UMADnaTutorial(); umaData.umaRecipe.AddDna(umaDna); umaData.umaRecipe.AddDna(umaTutorialDna); CreateMale(); avatar.animationController = animController; avatar.UpdateNewRace(); myUMA.transform.parent = this.gameObject.transform; myUMA.transform.localPosition = Vector3.zero; myUMA.transform.localRotation = Quaternion.identity; }
void GenerateUMA() { // Create a new game object and add UMA components to it GameObject GO = new GameObject("MyUMA"); umaDynamicAvatar = GO.AddComponent <UMADynamicAvatar>(); // Initialise Avatar and grab a reference to it's data component umaDynamicAvatar.Initialize(); umaData = umaDynamicAvatar.umaData; // Attach our generator umaDynamicAvatar.umaGenerator = generator; umaData.umaGenerator = generator; // Set up slot Array umaData.umaRecipe.slotDataList = new SlotData[numberOfSlots]; // Set up our Morph reference umaDna = new UMADnaHumanoid(); umaTutorialDNA = new UMADnaTutorial(); umaData.umaRecipe.AddDna(umaDna); umaData.umaRecipe.AddDna(umaTutorialDNA); // Grab a reference to our recipe // var umaRecipe = umaDynamicAvatar.umaData.umaRecipe; //moved to subroutine MakeMale // >>> This is whee the fun will happen according to Secret Anorak <<<< CreateMale(); // Generate Our UMA umaDynamicAvatar.UpdateNewRace(); }
void GeneratUMA() { //Add UMA Components to GameObject GO GameObject GO = new GameObject("MyUMA"); umaDynamicAvatar = GO.AddComponent <UMADynamicAvatar> (); //Initialise avatar and grab a reference to it's data component umaDynamicAvatar.Initialize(); umaData = umaDynamicAvatar.umaData; //Attach our generator umaDynamicAvatar.umaGenerator = generator; umaData.umaGenerator = generator; //Setup slot array umaData.umaRecipe.slotDataList = new SlotData[numberOfSlots]; //Setup Morph References umaDna = new UMADnaHumanoid(); umaTutorialDna = new UMADnaTutorial(); umaData.umaRecipe.AddDna(umaDna); umaData.umaRecipe.AddDna(umaTutorialDna); //Make UMA CreateMale(); umaDynamicAvatar.animationController = animController; umaDynamicAvatar.UpdateNewRace(); //Setze Player als Parent GO.transform.parent = this.gameObject.transform; GO.transform.localPosition = Vector3.zero; GO.transform.localRotation = Quaternion.identity; }
void GenerateUMA() { // Create a new game object and add UMA components to it GameObject GO = new GameObject("MyUMA"); umaDynamicAvatar = GO.AddComponent <UMADynamicAvatar>(); // Initialise Avatar and grab a reference to it's data component umaDynamicAvatar.Initialize(); umaData = umaDynamicAvatar.umaData; //practical guide to uma part 15 uma events https://youtu.be/_k-SZRCvgIk?t=8m20s umaData.OnCharacterCreated += CharacterCreatedCallback; // Attach our generator umaDynamicAvatar.umaGenerator = generator; umaData.umaGenerator = generator; // Set up slot Array umaData.umaRecipe.slotDataList = new SlotData[numberOfSlots]; // Set up our Morph reference umaDna = new UMADnaHumanoid(); umaTutorialDNA = new UMADnaTutorial(); umaData.umaRecipe.AddDna(umaDna); umaData.umaRecipe.AddDna(umaTutorialDNA); // Grab a reference to our recipe // var umaRecipe = umaDynamicAvatar.umaData.umaRecipe; //moved to subroutine MakeMale // >>> This is whee the fun will happen according to Secret Anorak <<<< CreateMale(); // dynamic animation controller umaDynamicAvatar.animationController = animController; // Generate Our UMA umaDynamicAvatar.UpdateNewRace(); // parent the new uma into the host game object GO.transform.parent = this.gameObject.transform; GO.transform.localPosition = Vector3.zero; GO.transform.localRotation = Quaternion.identity; // GO.AddComponent(typeof(Animator)); GO.AddComponent(typeof(UnityEngine.AI.NavMeshAgent)); GO.AddComponent(typeof(Rigidbody)); GO.AddComponent(typeof(CapsuleCollider)); var goCol = GO.GetComponent <CapsuleCollider>(); goCol.center = new Vector3(0f, 0.78f, 0f); goCol.height = 1.7f; goCol.radius = 0.2f; }
void GenerateUMA() { //UMA naming // Check a list of UMA objects. int umaCount = GameObject.FindGameObjectsWithTag("UMA").Length; UMAName = "UMA_" + umaCount.ToString(); // Create a new game object and add UMA components to it GameObject GO = new GameObject("myUMA"); GO.tag = "UMA"; umaDynamicAvatar = GO.AddComponent <UMADynamicAvatar>(); // Initialise Avatar and grab a reference to it's data component umaDynamicAvatar.Initialize(); umaData = umaDynamicAvatar.umaData; //practical guide to uma part 15 uma events https://youtu.be/_k-SZRCvgIk?t=8m20s umaData.OnCharacterCreated += CharacterCreatedCallback; // Attach our generator umaDynamicAvatar.umaGenerator = generator; umaData.umaGenerator = generator; // Set up slot Array umaData.umaRecipe.slotDataList = new SlotData[numberOfSlots]; // Set up our Morph reference umaDna = new UMADnaHumanoid(); umaTutorialDNA = new UMADnaTutorial(); umaData.umaRecipe.AddDna(umaDna); umaData.umaRecipe.AddDna(umaTutorialDNA); // Grab a reference to our recipe // var umaRecipe = umaDynamicAvatar.umaData.umaRecipe; //moved to subroutine MakeMale // >>> This is whee the fun will happen according to Secret Anorak <<<< CreateMale(); // dynamic animation controller umaDynamicAvatar.animationController = animController; // Generate Our UMA umaDynamicAvatar.UpdateNewRace(); // parent the new uma into the host game object GO.transform.parent = this.gameObject.transform; GO.transform.localPosition = Vector3.zero; GO.transform.localRotation = Quaternion.identity; }
void GenerateUMA() { // Create a new game object and add UMA components to it GameObject GO = new GameObject("MyUMA"); umaDynamicAvatar = GO.AddComponent <UMADynamicAvatar>(); // Initialise Avatar and grab a reference to it's data component umaDynamicAvatar.Initialize(); umaData = umaDynamicAvatar.umaData; //practical guide to uma part 15 uma events https://youtu.be/_k-SZRCvgIk?t=8m20s umaData.OnCharacterCreated += CharacterCreatedCallback; // Attach our generator umaDynamicAvatar.umaGenerator = generator; umaData.umaGenerator = generator; // Set up slot Array umaData.umaRecipe.slotDataList = new SlotData[numberOfSlots]; // Set up our Morph reference umaDna = new UMADnaHumanoid(); umaTutorialDNA = new UMADnaTutorial(); umaData.umaRecipe.AddDna(umaDna); umaData.umaRecipe.AddDna(umaTutorialDNA); // Grab a reference to our recipe // var umaRecipe = umaDynamicAvatar.umaData.umaRecipe; //moved to subroutine MakeMale // >>> This is where the fun will happen according to Secret Anorak <<<< CreateMale(); // dynamic animation controller umaDynamicAvatar.animationController = animController; // Generate Our UMA umaDynamicAvatar.UpdateNewRace(); }
void InitializeUma() { GameObject go = transform.FindChild("AvatarContainer").gameObject; avatar = go.AddComponent <UMADynamicAvatar> (); avatar.Initialize(); avatar.umaGenerator = generator; avatar.animationController = animController; // TODO make this a server command UMAGeneratorBase.OnUmaAnimatorCreated += heroAnimator.OnUmaAnimatorCreated; avatar.umaData.OnCharacterCreated += OnCharacterCreated; dna = new UMADnaHumanoid(); tutorialDna = new UMADnaTutorial(); data = avatar.umaData; data.umaGenerator = generator; data.umaRecipe.slotDataList = new SlotData[numSlots]; data.umaRecipe.AddDna(dna); data.umaRecipe.AddDna(tutorialDna); ApplyHumanMaleRecipe(); avatar.UpdateNewRace(); }
void GenerateUMA() { // Create a new game object and add UMA components to it GameObject GO = new GameObject("MyUMA"); umaDynamicAvatar = GO.AddComponent<UMADynamicAvatar>(); // Initialise Avatar and grab a reference to it's data component umaDynamicAvatar.Initialize(); umaData = umaDynamicAvatar.umaData; //practical guide to uma part 15 uma events https://youtu.be/_k-SZRCvgIk?t=8m20s umaData.OnCharacterCreated += CharacterCreatedCallback; // Attach our generator umaDynamicAvatar.umaGenerator = generator; umaData.umaGenerator = generator; // Set up slot Array umaData.umaRecipe.slotDataList = new SlotData[numberOfSlots]; // Set up our Morph reference umaDna = new UMADnaHumanoid(); umaTutorialDNA = new UMADnaTutorial(); umaData.umaRecipe.AddDna(umaDna); umaData.umaRecipe.AddDna(umaTutorialDNA); // Grab a reference to our recipe // var umaRecipe = umaDynamicAvatar.umaData.umaRecipe; //moved to subroutine MakeMale // >>> This is where the fun will happen according to Secret Anorak <<<< CreateFemale(); // dynamic animation controller umaDynamicAvatar.animationController = animController; // Generate Our UMA umaDynamicAvatar.UpdateNewRace(); }
public void GenerateUMA() { if(this.slotLibrary==null) { findUMAStuff(); } GameObject GO = new GameObject("MyUMA"); umaDynamicAvatar = GO.AddComponent<UMADynamicAvatar>(); this.umaDynamicAvatar.Initialize(); umaData = this.umaDynamicAvatar.umaData; umaDynamicAvatar.umaGenerator = generator; umaData.umaGenerator = generator; umaData.umaRecipe.slotDataList = new SlotData[numberOfSlots]; umaDna = new UMADnaHumanoid(); umaData.umaRecipe.AddDna(umaDna); CreateMale(); umaDynamicAvatar.animationController = this.animController; umaDynamicAvatar.UpdateNewRace(); GO.transform.parent = this.gameObject.transform; GO.transform.localPosition = Vector3.zero; GO.transform.localRotation = Quaternion.identity; }
void GenerateUMA() { // Create a new game object and add UMA components to it GameObject GO = new GameObject("MyUMA"); // parent the new uma into the host game object GO.transform.parent = this.gameObject.transform; GO.transform.localPosition = Vector3.zero; GO.transform.localRotation = Quaternion.identity; GO.AddComponent(typeof(NavMeshAgent)); GO.AddComponent(typeof(CapsuleCollider)); var goCol = GO.GetComponent<CapsuleCollider>(); goCol.center = new Vector3(0f, 0.78f, 0f); goCol.height = 1.7f; goCol.radius = 0.33f; umaDynamicAvatar = GO.AddComponent<UMADynamicAvatar>(); // Initialise Avatar and grab a reference to it's data component umaDynamicAvatar.Initialize(); umaData = umaDynamicAvatar.umaData; //practical guide to uma part 15 uma events https://youtu.be/_k-SZRCvgIk?t=8m20s umaData.OnCharacterCreated += CharacterCreatedCallback; // Attach our generator umaDynamicAvatar.umaGenerator = generator; umaData.umaGenerator = generator; // Set up slot Array umaData.umaRecipe.slotDataList = new SlotData[numberOfSlots]; // Set up our Morph reference umaDna = new UMADnaHumanoid(); umaTutorialDNA = new UMADnaTutorial(); umaData.umaRecipe.AddDna(umaDna); umaData.umaRecipe.AddDna(umaTutorialDNA); // Grab a reference to our recipe // var umaRecipe = umaDynamicAvatar.umaData.umaRecipe; //moved to subroutine MakeMale // >>> This is whee the fun will happen according to Secret Anorak <<<< CreateMale(); // dynamic animation controller umaDynamicAvatar.animationController = animController; // Generate Our UMA umaDynamicAvatar.UpdateNewRace(); }
void GenerateUMA() { //UMA naming // Check a list of UMA objects. int umaCount = GameObject.FindGameObjectsWithTag("UMA").Length; UMAName = "UMA_" + umaCount.ToString(); // Create a new game object and add UMA components to it GameObject GO = new GameObject("myUMA"); GO.tag = "UMA"; umaDynamicAvatar = GO.AddComponent<UMADynamicAvatar>(); // Initialise Avatar and grab a reference to it's data component umaDynamicAvatar.Initialize(); umaData = umaDynamicAvatar.umaData; //practical guide to uma part 15 uma events https://youtu.be/_k-SZRCvgIk?t=8m20s umaData.OnCharacterCreated += CharacterCreatedCallback; // Attach our generator umaDynamicAvatar.umaGenerator = generator; umaData.umaGenerator = generator; // Set up slot Array umaData.umaRecipe.slotDataList = new SlotData[numberOfSlots]; // Set up our Morph reference umaDna = new UMADnaHumanoid(); umaTutorialDNA = new UMADnaTutorial(); umaData.umaRecipe.AddDna(umaDna); umaData.umaRecipe.AddDna(umaTutorialDNA); // Grab a reference to our recipe // var umaRecipe = umaDynamicAvatar.umaData.umaRecipe; //moved to subroutine MakeMale // >>> This is whee the fun will happen according to Secret Anorak <<<< CreateMale(); // dynamic animation controller umaDynamicAvatar.animationController = animController; // Generate Our UMA umaDynamicAvatar.UpdateNewRace(); // parent the new uma into the host game object GO.transform.parent = this.gameObject.transform; GO.transform.localPosition = Vector3.zero; GO.transform.localRotation = Quaternion.identity; }
/// <summary> /// Create a new UMA from a given HumanoidStructure. /// </summary> /// <returns> /// Returns a reference to the created GameObject containing the generated UMA. /// </returns> /// <param name='name'> /// The name given to the GameObject in the heirarchy. /// </param> /// <param name='position'> /// The Vector3 position to give the new UMA. /// </param> /// <param name='layer'> /// The layer to put the UMA in, or 0 for the default layer /// </param> /// <param name='human'> /// The UMAElements.HumanoidStructure to build from. /// </param> /// <param name='useRigidBody'> /// Whether to keep a RigidBody on the new UMA. /// </param> /// <param name='useCharController'> /// Whether to add a CharacterController to the new UMA. /// </param> /// <param name='animationController'> /// If null, will keep the original Locomotion script, or use the given RuntimeAnimationController. /// </param> public static GameObject Create(HumanoidStructure human, string name, RuntimeAnimatorController animationController, Vector3 position = default(Vector3), int layer = 0, bool useRigidBody = true, bool useCharController = true) { // are we initialized? if (!_initialized) { Debug.LogError("UMAElements.HumanoidBuilder.Create: Attempted use before initialization. Must call HumanoidBuilder.Initialize(scale) first."); return(null); } // create a new UMARecipe GameObject thisUMA = new GameObject(name); UMADynamicAvatar dynamicAvatar = thisUMA.AddComponent <UMADynamicAvatar>(); dynamicAvatar.Initialize(); UMAData thisUMAData = dynamicAvatar.umaData; dynamicAvatar.umaGenerator = _generator; thisUMAData.umaGenerator = _generator; var umaRecipe = dynamicAvatar.umaData.umaRecipe; thisUMAData.OnCharacterCreated += UMAFinished; // race and gender bool found = false; if (human.gender == 'M') { umaRecipe.SetRace(_raceLibrary.GetRace("HumanMale")); found = true; } else if (human.gender == 'F') { umaRecipe.SetRace(_raceLibrary.GetRace("HumanFemale")); found = true; } if (!found) { Debug.LogError("UMAElements.HumanoidBuilder.Create: Incorrect gender given as '" + human.gender + "'. UMA could not be built."); return(null); } // do the build (this is the same as update) thisUMAData.atlasResolutionScale = _atlasScale; BuildUMAShape(thisUMAData, human, true); BuildUMASlots(thisUMAData, human, true); // remove the rigidbody (if required) if (useRigidBody) { thisUMA.AddComponent <Rigidbody>(); } // add a character controller (if required) if (useCharController) { CapsuleCollider chc = thisUMA.AddComponent <CapsuleCollider>(); chc.radius = 0.0015f * human.height; chc.height = (human.height / 100.0f); chc.center = new Vector3(0, chc.height / 2.0f, 0); } // add the correct animator (if required) if (animationController != null) { dynamicAvatar.animationController = animationController; } // put the uma in the correct position thisUMA.transform.position = position; // ensure that all elements of the uma are set to the "Entities" layer thisUMA.layer = layer; foreach (Transform t in thisUMA.GetComponentsInChildren <Transform>()) { t.gameObject.layer = layer; } dynamicAvatar.UpdateNewRace(); Humanoid tmp = new Humanoid(); tmp.name = name; tmp.human = human; _charList.Add(tmp); // finally return this UMA's game object return(thisUMA); }
GameObject GenerateUMA(string name) { // Create a new game object and add UMA components to it GameObject GO = new GameObject(name); GO.transform.position = this.transform.position; //parentAtPosition(GO); umaDynamicAvatar = GO.AddComponent<UMADynamicAvatar>(); umaDynamicAvatar.animationController = animationController; GO.AddComponent<RagdollCreatorTest>(); if (name.Contains ("Zombie")) { ZombieBehavior zbh = GO.AddComponent<ZombieBehavior> (); zbh.speedMultiplier = Random.Range (0.5f, 2.5f); GO.tag = "Zombie"; GameObject[] zombies = GameObject.FindGameObjectsWithTag("Zombie"); GO.name = "Zombie" + zombies.Length; } else { HumanBehavior hb = GO.AddComponent<HumanBehavior> (); hb.zombieAnimationController = secondaryAnimationController; GO.tag = "Human"; // GameObject[] humans = GameObject.FindGameObjectsWithTag("Human"); //GO.name = "Human" + humans.Length; } GO.AddComponent<NavMeshAgent> (); GO.AddComponent<HealthComponent> (); // Initialize Avatar and grab a reference to its data component umaDynamicAvatar.Initialize(); umaData = umaDynamicAvatar.umaData; // Attach our generator umaDynamicAvatar.umaGenerator = generator; umaData.umaGenerator = generator; // Set up slot Array umaData.umaRecipe.slotDataList = new SlotData[numberOfSlots]; // Set up our Morph references umaDna = new UMADnaHumanoid(); umaTutorialDNA = new UMADnaTutorial(); umaData.umaRecipe.AddDna(umaDna); umaData.umaRecipe.AddDna(umaTutorialDNA); if (name.Contains ("Female")) { CreateFemale (); } else { CreateMale (); } // Generate our UMA setupDna (umaDna); umaDynamicAvatar.UpdateNewRace(); if (name.Contains("Human")) { if (name.Contains("Female")) { GO.name = createName("Female"); } else { GO.name = createName("Male"); } } return GO; }
GameObject GenerateUMA(string name) { // Create a new game object and add UMA components to it GameObject GO = new GameObject(name); GO.transform.position = this.transform.position; //parentAtPosition(GO); umaDynamicAvatar = GO.AddComponent <UMADynamicAvatar>(); umaDynamicAvatar.animationController = animationController; GO.AddComponent <RagdollCreatorTest>(); if (name.Contains("Zombie")) { ZombieBehavior zbh = GO.AddComponent <ZombieBehavior> (); zbh.speedMultiplier = Random.Range(0.5f, 2.5f); GO.tag = "Zombie"; GameObject[] zombies = GameObject.FindGameObjectsWithTag("Zombie"); GO.name = "Zombie" + zombies.Length; } else { HumanBehavior hb = GO.AddComponent <HumanBehavior> (); GO.tag = "Human"; // GameObject[] humans = GameObject.FindGameObjectsWithTag("Human"); //GO.name = "Human" + humans.Length; } GO.AddComponent <UnityEngine.AI.NavMeshAgent> (); GO.AddComponent <HealthComponent> (); // Initialize Avatar and grab a reference to its data component umaDynamicAvatar.Initialize(); umaData = umaDynamicAvatar.umaData; // Attach our generator umaDynamicAvatar.umaGenerator = generator; umaData.umaGenerator = generator; // Set up slot Array umaData.umaRecipe.slotDataList = new SlotData[numberOfSlots]; // Set up our Morph references umaDna = new UMADnaHumanoid(); umaTutorialDNA = new UMADnaTutorial(); umaData.umaRecipe.AddDna(umaDna); umaData.umaRecipe.AddDna(umaTutorialDNA); if (name.Contains("Female")) { CreateFemale(); } else { CreateMale(); } // Generate our UMA setupDna(umaDna); umaDynamicAvatar.UpdateNewRace(); if (name.Contains("Human")) { if (name.Contains("Female")) { GO.name = createName("Female"); } else { GO.name = createName("Male"); } } return(GO); }
void GenerateUMA() { //Create a new game object and add UMA components to it GameObject GO = new GameObject ("MyUMA"); umaDynamicAvatar = GO.AddComponent<UMADynamicAvatar>(); //Initialise Avatar and grab a refrence to its data component umaDynamicAvatar.Initialize(); umaData = umaDynamicAvatar.umaData; //Attach our generator umaDynamicAvatar.umaGenerator = generator; umaData.umaGenerator = generator; //Setup slot array umaData.umaRecipe.slotDataList = new SlotData[numberOfSlots]; //Set up our morph refrence umaDNA = new UMADnaHumanoid(); umaTutorialDNA = new UMADnaTutorial(); umaData.umaRecipe.AddDna (umaDNA); umaData.umaRecipe.AddDna (umaTutorialDNA); //----------UMA Generation Section----------------- CreateMale(); umaDynamicAvatar.animationController = animController; //Generate our UMA umaDynamicAvatar.UpdateNewRace(); GO.transform.parent = this.gameObject.transform; GO.transform.localPosition = Vector3.zero; GO.transform.localRotation = Quaternion.identity; }
public void LoadAvatar(string assetData) { /* if (assetData != null && assetData != "{}" && umaAvatar == null) { * umaAvatar = gameObject.AddComponent<UMADynamicAvatar>(); * umaAvatar.umaGenerator = gameObject.GetComponentInChildren<UMAGenerator>(); * umaAvatar.context = gameObject.GetComponentInChildren<UMAContext>(); * umaAvatar.animationController = (RuntimeAnimatorController)RuntimeAnimatorController.Instantiate(Resources.Load("Locomotion", typeof(RuntimeAnimatorController ))); * umaAvatar.umaData = gameObject.GetComponentInChildren<UMAData>(); * var asset = ScriptableObject.CreateInstance<UMATextRecipe> (); * asset.recipeString = assetData; * umaAvatar.Load(asset); * Destroy (asset); * } */ /* isLoad = true; * if (umaData) { * var avatarData = umaData.gameObject.GetComponent<UMAAvatarBase> (); * if (avatarData != null && user.asset != null && user.asset != "{}") { * Debug.Log(user.asset); * var asset = ScriptableObject.CreateInstance<UMATextRecipe> (); * asset.recipeString = user.asset; * avatarData.Load (asset); * Destroy (asset); * isLoad = false; * } * umaData = null; * } */ if (racelibrary != null) { // Generate new GameObject and add UMA components to it GameObject GO = new GameObject("Player"); umaDynamicAvatar = GO.AddComponent <UMADynamicAvatar> (); // Initialise Avatar and grab a reference to it's data component umaDynamicAvatar.Initialize(); umaData = umaDynamicAvatar.umaData; // Attach our generator umaDynamicAvatar.umaGenerator = generator; umaData.umaGenerator = generator; // Set up slot Array umaData.umaRecipe.slotDataList = new SlotData[numberOfSlots]; // Set up our Morph references umaDna = new UMADnaHumanoid(); umaData.umaRecipe.AddDna(umaDna); GenerateAvatar(); umaDynamicAvatar.animationController = animController; // Generate our UMA umaDynamicAvatar.UpdateNewRace(); GO.transform.parent = this.gameObject.transform; GO.transform.localPosition = Vector3.zero; GO.transform.localRotation = Quaternion.identity; //GameObject playerCamera = GameObject.Find ("PlayerCamera"); //playerCamera.transform.parent = GO.transform; //playerCamera.transform.localPosition = new Vector3 (0.0f, 1.5f, -1.285f); //playerCamera.transform.localRotation = Quaternion.Euler (23.0f, 0.0f, 0.0f); } }