public void RandomizeCharacter() { int up_custom = Random.Range(0, 1); switch (up_custom) { case 0: //hair GameObject hair = GameObject.Find("Hair"); ChangeHair hairScript = hair.GetComponent <ChangeHair>(); hairScript.Randomize(); Debug.Log("Hair"); break; case 1: //hat GameObject hat = GameObject.Find("Hats"); Accessories hatScript = hat.GetComponent <Accessories>(); hatScript.Randomize(); Debug.Log("Hats"); break; } //Hair-hat color GameObject haircolor = GameObject.Find("Hair-/HatColor"); ChangeHairColour haircolorScript = haircolor.GetComponent <ChangeHairColour>(); haircolorScript.Randomize(); Debug.Log("Hair color"); //face GameObject faces = GameObject.Find("FaceGesture"); ChangeFace faceScript = faces.GetComponent <ChangeFace>(); faceScript.Randomize(); Debug.Log("face"); //face tone GameObject faceTone = GameObject.Find("FaceTone"); ChangeFaceTone faceToneScript = faceTone.GetComponent <ChangeFaceTone>(); faceToneScript.Randomize(); Debug.Log("face tone"); //upper body GameObject upperBody = GameObject.Find("UpperBody"); ChangeUpperBody upperBodyScript = upperBody.GetComponent <ChangeUpperBody>(); upperBodyScript.Randomize(); Debug.Log("upper body"); //arms GameObject arms = GameObject.Find("Arms"); ChangeArms armsScript = arms.GetComponent <ChangeArms>(); armsScript.Randomize(); Debug.Log("arms"); //hands GameObject hands = GameObject.Find("Hands"); ChangeHands handsScript = hands.GetComponent <ChangeHands>(); handsScript.Randomize(); Debug.Log("hands"); //hip GameObject hip = GameObject.Find("HipSelection"); ChangeHip hipScript = hip.GetComponent <ChangeHip>(); hipScript.Randomize(); Debug.Log("hip"); //legs GameObject legs = GameObject.Find("Legs"); ChangeLegs legsScript = legs.GetComponent <ChangeLegs>(); legsScript.Randomize(); Debug.Log("legs"); //feet GameObject feet = GameObject.Find("Feet"); ChangeFeet feetScript = feet.GetComponent <ChangeFeet>(); feetScript.Randomize(); Debug.Log("feet"); }
//Creates a custom player with the current selections private void SavePlayerCustomization() { //Create new blueprint for customization CustomCharacter player = new CustomCharacter(); //Head //Hair GameObject hair = GameObject.Find("Hair"); ChangeHair hairScript = hair.GetComponent <ChangeHair>(); player.hair = hairScript.GetCurrentSelection(); //Hat GameObject hat = GameObject.Find("Hats"); Accessories hatScript = hat.GetComponent <Accessories>(); player.hat = hatScript.GetCurrentSelection(); //Hat-hair color GameObject haircolor = GameObject.Find("Hair-/HatColor"); ChangeHairColour haircolorScript = haircolor.GetComponent <ChangeHairColour>(); player.hairColor = haircolorScript.GetCurrentSelection(); //Face GameObject faces = GameObject.Find("FaceGesture"); ChangeFace faceScript = faces.GetComponent <ChangeFace>(); player.face = faceScript.GetCurrentSelection(); //Face tone GameObject faceTone = GameObject.Find("FaceTone"); ChangeFaceTone faceToneScript = faceTone.GetComponent <ChangeFaceTone>(); player.faceTone = faceToneScript.GetCurrentSelection(); //Upper body GameObject upperBody = GameObject.Find("UpperBody"); ChangeUpperBody upperBodyScript = upperBody.GetComponent <ChangeUpperBody>(); player.upperBody_front = upperBodyScript.GetCurrentSelection(ChangeUpperBody.UpperBodyOptions.TorsoFront); player.upperBody_back = upperBodyScript.GetCurrentSelection(ChangeUpperBody.UpperBodyOptions.TorsoBack); player.upperBody_main = upperBodyScript.GetCurrentSelection(ChangeUpperBody.UpperBodyOptions.TorsoMain); //Arms GameObject arms = GameObject.Find("Arms"); ChangeArms armsScript = arms.GetComponent <ChangeArms>(); player.leftArm_front = armsScript.GetCurrentSelection(ChangeArms.ArmOptions.LeftArmFront); player.leftArm_main = armsScript.GetCurrentSelection(ChangeArms.ArmOptions.LeftArmMain); player.rightArm_front = armsScript.GetCurrentSelection(ChangeArms.ArmOptions.RightArmFront); player.rightArm_main = armsScript.GetCurrentSelection(ChangeArms.ArmOptions.RightArmMain); //Hands GameObject hands = GameObject.Find("Hands"); ChangeHands handsScript = hands.GetComponent <ChangeHands>(); player.left_hand = handsScript.GetCurrentSelection(ChangeHands.HandOptions.LeftHand); player.right_hand = handsScript.GetCurrentSelection(ChangeHands.HandOptions.RighHand); //Hips GameObject hip = GameObject.Find("HipSelection"); ChangeHip hipScript = hip.GetComponent <ChangeHip>(); player.hip_crotch = hipScript.GetCurrentSelection(ChangeHip.HipOptions.HipCrotch); player.hip_front = hipScript.GetCurrentSelection(ChangeHip.HipOptions.HipFront); player.hip_main = hipScript.GetCurrentSelection(ChangeHip.HipOptions.HipMain); //Legs GameObject legs = GameObject.Find("Legs"); ChangeLegs legsScript = legs.GetComponent <ChangeLegs>(); player.leftleg_front = legsScript.GetCurrentSelection(ChangeLegs.LegsOptions.LeftLegFront); player.leftleg_side = legsScript.GetCurrentSelection(ChangeLegs.LegsOptions.LeftLegSide); player.leftleg_main = legsScript.GetCurrentSelection(ChangeLegs.LegsOptions.LeftLegMain); player.rightleg_front = legsScript.GetCurrentSelection(ChangeLegs.LegsOptions.RightLegFront); player.rightleg_side = legsScript.GetCurrentSelection(ChangeLegs.LegsOptions.RightLegSide); player.rightleg_main = legsScript.GetCurrentSelection(ChangeLegs.LegsOptions.RightLegMain); //Feet GameObject feet = GameObject.Find("Feet"); ChangeFeet feetScript = feet.GetComponent <ChangeFeet>(); player.right_foot = feetScript.GetCurrentSelection(ChangeFeet.FeetOptions.RightFoot); player.left_foot = feetScript.GetCurrentSelection(ChangeFeet.FeetOptions.LeftFoot); player.playerId = characterIndex; //Save character into InputManager InputManager.Instance.SaveCustomCharacter(player); }