void findUMAStuff() { this.slotLibrary = GameObject.Find ("SlotLibrary").GetComponent<SlotLibrary>(); this.generator = GameObject.Find ("UMAGenerator").GetComponent<UMAGenerator>(); this.overlayLibrary = GameObject.Find("OverlayLibrary").GetComponent<OverlayLibrary>(); this.raceLibrary = GameObject.Find ("RaceLibrary").GetComponent<RaceLibrary>(); }
void Awake() { slotLibrary = GameObject.Find("SlotLibrary").GetComponent<SlotLibrary>(); overlayLibrary = GameObject.Find("OverlayLibrary").GetComponent<OverlayLibrary>(); raceLibrary = GameObject.Find("RaceLibrary").GetComponent<RaceLibrary>(); generator = GameObject.Find("UMAGenerator").GetComponent<UMAGenerator>(); }
#pragma warning disable 618 public void Start() { if (!slotLibrary) { slotLibrary = GameObject.Find("SlotLibrary").GetComponent("SlotLibrary") as SlotLibrary; } if (!raceLibrary) { raceLibrary = GameObject.Find("RaceLibrary").GetComponent("RaceLibrary") as RaceLibrary; } if (!overlayLibrary) { overlayLibrary = GameObject.Find("OverlayLibrary").GetComponent("OverlayLibrary") as OverlayLibrary; } if (Instance == null) Instance = this; }
public void Initialize() { umaPackRecipe = new UMAPackRecipe(); if(!slotLibrary){ slotLibrary = GameObject.Find("SlotLibrary").GetComponent("SlotLibrary") as SlotLibrary; } if(!raceLibrary){ raceLibrary = GameObject.Find("RaceLibrary").GetComponent("RaceLibrary") as RaceLibrary; } if(!overlayLibrary){ overlayLibrary = GameObject.Find("OverlayLibrary").GetComponent("OverlayLibrary") as OverlayLibrary; } if(!umaData){ umaData = gameObject.GetComponent("UMAData") as UMAData; } }
public void Launch(DK_RPG_UMA DKRPGUMA, DK_UMACrowd DKUMACrowd, string streamed) { // assign scripts _DK_UMACrowd = DKUMACrowd; _DK_RPG_UMA = DKRPGUMA; Gender = DKRPGUMA.Gender; // _DK_UMACrowd = GameObject.Find ("DKUMACrowd").GetComponent<DK_UMACrowd>(); // get libraries try { raceLibrary = GameObject.Find("RaceLibrary").GetComponent <RaceLibrary>(); slotLibrary = GameObject.Find("SlotLibrary").GetComponent <SlotLibrary>(); overlayLibrary = GameObject.Find("OverlayLibrary").GetComponent <OverlayLibrary>(); }catch (NullReferenceException) { Debug.LogError("UMA is missing from your scene. UMA is required to generate a UMA avatar."); } // assign recipe _StreamedUMA = streamed; // Start the creation of the avatar ConvertStreamedUMA(streamed); CreateUMAData(); }
void Awake() { //Assign instance s_Instance = this; //Find if libraries not assigned UMAContext context = UMAContext.FindInstance(); if (context != null) { _RaceLibrary = context.raceLibrary; _SlotLibrary = context.slotLibrary; _OverlayLibrary = context.overlayLibrary; } //Create first one CreateUMA(); }
static void InitializeUMA() {//Initialize UMA context // UMA GameObject uma = new GameObject(); uma.name = "UMA"; GameObject parent; if (parent = Selection.activeGameObject) { uma.transform.SetParent(parent.transform); } // Race Library GameObject races = new GameObject(); races.name = "RaceLibrary"; races.transform.SetParent(uma.transform); RaceLibrary raceLibrary = races.AddComponent <RaceLibrary>(); //null search in all assets folder, t means type, so we are searching Uma.RaceData string[] racesData = AssetDatabase.FindAssets("t: RaceData", null); foreach (string data in racesData) { //get the path string racePath = AssetDatabase.GUIDToAssetPath(data); RaceData raceAsset = AssetDatabase.LoadAssetAtPath <RaceData>(racePath); raceLibrary.AddRace(raceAsset); } // Slots GameObject slots = new GameObject(); slots.name = "SlotLibrary"; slots.transform.SetParent(uma.transform); SlotLibrary slotLibrary = slots.AddComponent <SlotLibrary>(); //null search in all assets folder, t means type, so we are searching Uma.RaceData string[] slotsData = AssetDatabase.FindAssets("t: SlotDataAsset", null); foreach (string data in slotsData) { //get the path string slotPath = AssetDatabase.GUIDToAssetPath(data); SlotDataAsset slotAsset = AssetDatabase.LoadAssetAtPath <SlotDataAsset>(slotPath); slotLibrary.AddSlotAsset(slotAsset); } // Overlays GameObject overlays = new GameObject(); overlays.name = "OverlayLibrary"; overlays.transform.SetParent(uma.transform); OverlayLibrary overlayLibrary = overlays.AddComponent <OverlayLibrary>(); //null search in all assets folder, t means type, so we are searching Uma.RaceData string[] overlaysData = AssetDatabase.FindAssets("t: OverlayDataAsset", null); foreach (string data in overlaysData) { //get the path string overlayPath = AssetDatabase.GUIDToAssetPath(data); OverlayDataAsset overlayAsset = AssetDatabase.LoadAssetAtPath <OverlayDataAsset>(overlayPath); overlayLibrary.AddOverlayAsset(overlayAsset); } // Context GameObject context = new GameObject(); context.name = "ContextLibrary"; context.transform.SetParent(uma.transform); UMAContext umaContext = context.AddComponent <UMAContext>(); umaContext.raceLibrary = raceLibrary; umaContext.slotLibrary = slotLibrary; umaContext.overlayLibrary = overlayLibrary; // Generators UMAGenerator generator = MonoBehaviour.Instantiate <UMAGenerator> (AssetDatabase.LoadAssetAtPath <UMAGenerator>(CommonNames.umaFolderGeneratorPrefabPath)); generator.name = "UMAGenerator"; generator.transform.SetParent(uma.transform); UMADefaultMeshCombiner meshCombiner = generator.gameObject.AddComponent <UMADefaultMeshCombiner>(); generator.meshCombiner = meshCombiner; //Mixers for random UMA creation //Male GameObject maleRecipeMixer = new GameObject(); maleRecipeMixer.name = "MaleRecipeMixer"; UMA.Examples.UMARecipeMixer maleRecipeMixerScript = maleRecipeMixer.AddComponent <UMA.Examples.UMARecipeMixer>(); maleRecipeMixerScript.raceData = raceLibrary.GetRace("HumanMale"); UMA.Examples.UMARecipeMixer.RecipeSection[] maleRecipeSection = new UMA.Examples.UMARecipeMixer.RecipeSection[3]; //Male Recipe Section : Body maleRecipeSection[0] = new UMA.Examples.UMARecipeMixer.RecipeSection(); maleRecipeSection[0].name = "Body"; maleRecipeSection[0].selectionRule = UMA.Examples.UMARecipeMixer.SelectionType.IncludeOne; maleRecipeSection[0].recipes = new UMARecipeBase[2]; string[] maleBodyRecipePath = AssetDatabase.FindAssets("MaleBase t: UMATextRecipe", null); maleRecipeSection[0].recipes[0] = AssetDatabase.LoadAssetAtPath <UMATextRecipe>(AssetDatabase.GUIDToAssetPath(maleBodyRecipePath[0])); string[] maleBody2RecipePath = AssetDatabase.FindAssets("MaleBase2 t: UMATextRecipe", null); maleRecipeSection[0].recipes[1] = AssetDatabase.LoadAssetAtPath <UMATextRecipe>(AssetDatabase.GUIDToAssetPath(maleBody2RecipePath[0])); //Male Recipe Section : Underwear maleRecipeSection[1] = new UMA.Examples.UMARecipeMixer.RecipeSection(); maleRecipeSection[1].name = "Clothing"; maleRecipeSection[1].selectionRule = UMA.Examples.UMARecipeMixer.SelectionType.IncludeOne; maleRecipeSection[1].recipes = new UMARecipeBase[1]; //string[] maleUnderwearRecipePath = AssetDatabase.FindAssets("MaleUnderwear t: UMATextRecipe", null); //maleRecipeSection[1].recipes[0] = AssetDatabase.LoadAssetAtPath<UMATextRecipe>(AssetDatabase.GUIDToAssetPath(maleUnderwearRecipePath[0])); string[] maleOutfit1RecipePath = AssetDatabase.FindAssets("MaleOutfit1 t: UMATextRecipe", null); foreach (string hairPath in maleOutfit1RecipePath) { UMATextRecipe umaTextRecipe = AssetDatabase.LoadAssetAtPath <UMATextRecipe>(AssetDatabase.GUIDToAssetPath(hairPath)); if (umaTextRecipe.name == "MaleOutfit1") { maleRecipeSection[1].recipes[0] = umaTextRecipe; } } //Male Recipe Section : Hair maleRecipeSection[2] = new UMA.Examples.UMARecipeMixer.RecipeSection(); maleRecipeSection[2].name = "Hair"; maleRecipeSection[2].selectionRule = UMA.Examples.UMARecipeMixer.SelectionType.IncludeSome; maleRecipeSection[2].recipes = new UMARecipeBase[2]; string[] maleBeardRecipePath = AssetDatabase.FindAssets("MaleBeard t: UMATextRecipe", null); foreach (string hairPath in maleBeardRecipePath) { UMATextRecipe umaTextRecipe = AssetDatabase.LoadAssetAtPath <UMATextRecipe>(AssetDatabase.GUIDToAssetPath(hairPath)); if (umaTextRecipe.name == "MaleBeard") { maleRecipeSection[2].recipes[0] = umaTextRecipe; } } string[] maleHairRecipePath = AssetDatabase.FindAssets("MaleHair t: UMATextRecipe", null); foreach (string hairPath in maleHairRecipePath) { UMATextRecipe umaTextRecipe = AssetDatabase.LoadAssetAtPath <UMATextRecipe>(AssetDatabase.GUIDToAssetPath(hairPath)); if (umaTextRecipe.name == "MaleHair") { maleRecipeSection[2].recipes[1] = umaTextRecipe; } } maleRecipeMixerScript.recipeSections = maleRecipeSection; maleRecipeMixer.GetComponent <Transform>().SetParent(uma.transform); //Female GameObject femaleRecipeMixer = new GameObject(); femaleRecipeMixer.name = "FemaleRecipeMixer"; UMA.Examples.UMARecipeMixer femaleRecipeMixerScript = femaleRecipeMixer.AddComponent <UMA.Examples.UMARecipeMixer>(); femaleRecipeMixerScript.raceData = raceLibrary.GetRace("HumanFemale"); UMA.Examples.UMARecipeMixer.RecipeSection[] femaleRecipeSection = new UMA.Examples.UMARecipeMixer.RecipeSection[3]; //Female Recipe Section : Body femaleRecipeSection[0] = new UMA.Examples.UMARecipeMixer.RecipeSection(); femaleRecipeSection[0].name = "Body"; femaleRecipeSection[0].selectionRule = UMA.Examples.UMARecipeMixer.SelectionType.IncludeOne; femaleRecipeSection[0].recipes = new UMARecipeBase[1]; string[] femaleBodyRecipePath = AssetDatabase.FindAssets("HumanFemale Base Recipe t: UMATextRecipe", null); femaleRecipeSection[0].recipes[0] = AssetDatabase.LoadAssetAtPath <UMATextRecipe>(AssetDatabase.GUIDToAssetPath(femaleBodyRecipePath[0])); //Female Recipe Section : Underwear femaleRecipeSection[1] = new UMA.Examples.UMARecipeMixer.RecipeSection(); femaleRecipeSection[1].name = "Clothing"; femaleRecipeSection[1].selectionRule = UMA.Examples.UMARecipeMixer.SelectionType.IncludeOne; femaleRecipeSection[1].recipes = new UMARecipeBase[2]; //string[] femaleUnderwearRecipePath = AssetDatabase.FindAssets("FemaleUnderwear t: UMATextRecipe", null); string[] femaleOutfit1RecipePath = AssetDatabase.FindAssets("FemaleOutfit1 t: UMATextRecipe", null); string[] femaleOutfit2RecipePath = AssetDatabase.FindAssets("FemaleOutfit2 t: UMATextRecipe", null); //femaleRecipeSection[1].recipes[0] = AssetDatabase.LoadAssetAtPath<UMATextRecipe>(AssetDatabase.GUIDToAssetPath(femaleUnderwearRecipePath[0])); femaleRecipeSection[1].recipes[0] = AssetDatabase.LoadAssetAtPath <UMATextRecipe>(AssetDatabase.GUIDToAssetPath(femaleOutfit1RecipePath[0])); femaleRecipeSection[1].recipes[1] = AssetDatabase.LoadAssetAtPath <UMATextRecipe>(AssetDatabase.GUIDToAssetPath(femaleOutfit2RecipePath[0])); //Female Recipe Section : Hair femaleRecipeSection[2] = new UMA.Examples.UMARecipeMixer.RecipeSection(); femaleRecipeSection[2].name = "Hair"; femaleRecipeSection[2].selectionRule = UMA.Examples.UMARecipeMixer.SelectionType.IncludeOne; femaleRecipeSection[2].recipes = new UMARecipeBase[3]; string[] femaleHairRecipePath = AssetDatabase.FindAssets("FemaleHair t: UMATextRecipe", null); string[] femaleHairLongRecipePath = AssetDatabase.FindAssets("FemaleHairLong t: UMATextRecipe", null); string[] femaleHairShortRecipePath = AssetDatabase.FindAssets("FemaleHairShort t: UMATextRecipe", null); foreach (string hairPath in femaleHairRecipePath) { UMATextRecipe umaTextRecipe = AssetDatabase.LoadAssetAtPath <UMATextRecipe>(AssetDatabase.GUIDToAssetPath(hairPath)); if (umaTextRecipe.name == "FemaleHair") { femaleRecipeSection[2].recipes[0] = umaTextRecipe; } } femaleRecipeSection[2].recipes[1] = AssetDatabase.LoadAssetAtPath <UMATextRecipe>(AssetDatabase.GUIDToAssetPath(femaleHairLongRecipePath[0])); femaleRecipeSection[2].recipes[2] = AssetDatabase.LoadAssetAtPath <UMATextRecipe>(AssetDatabase.GUIDToAssetPath(femaleHairShortRecipePath[0])); femaleRecipeMixerScript.recipeSections = femaleRecipeSection; femaleRecipeMixer.GetComponent <Transform>().SetParent(uma.transform); //Shared colors table GameObject recipeMixerController = new GameObject(); recipeMixerController.name = "RecipeMixerController"; RecipeMixerController recipeMixerControllerScript = recipeMixerController.AddComponent <RecipeMixerController>(); SharedColorTable[] sharedColorTable = recipeMixerControllerScript.sharedColors; string[][] sharedColorsPath = new string[5][]; sharedColorsPath[0] = AssetDatabase.FindAssets("HumanHairLinear", null); sharedColorsPath[1] = AssetDatabase.FindAssets("HumanSkinLinear", null); sharedColorsPath[2] = AssetDatabase.FindAssets("ClothingUnderwear", null); sharedColorsPath[3] = AssetDatabase.FindAssets("ClothingTops", null); sharedColorsPath[4] = AssetDatabase.FindAssets("ClothingBottoms", null); sharedColorTable[0] = AssetDatabase.LoadAssetAtPath <SharedColorTable>(AssetDatabase.GUIDToAssetPath(sharedColorsPath[0][0])); sharedColorTable[1] = AssetDatabase.LoadAssetAtPath <SharedColorTable>(AssetDatabase.GUIDToAssetPath(sharedColorsPath[1][0])); sharedColorTable[2] = AssetDatabase.LoadAssetAtPath <SharedColorTable>(AssetDatabase.GUIDToAssetPath(sharedColorsPath[2][0])); sharedColorTable[3] = AssetDatabase.LoadAssetAtPath <SharedColorTable>(AssetDatabase.GUIDToAssetPath(sharedColorsPath[3][0])); sharedColorTable[4] = AssetDatabase.LoadAssetAtPath <SharedColorTable>(AssetDatabase.GUIDToAssetPath(sharedColorsPath[4][0])); recipeMixerController.transform.SetParent(uma.transform); }
void setupFallbackObjects() { if (generator == null) { generator = GameObject.Find("UMAGenerator").GetComponent<UMAGenerator>(); } if (slotLibrary == null) { slotLibrary = GameObject.Find("SlotLibrary").GetComponent<SlotLibrary>(); } if (overlayLibrary == null) { overlayLibrary = GameObject.Find("OverlayLibrary").GetComponent<OverlayLibrary>(); } if (raceLibrary == null) { raceLibrary = GameObject.Find("RaceLibrary").GetComponent<RaceLibrary>(); } }