private void UMAAddOverlay(UMAEquipSlotData equipSlotData, SlotData slot, OverlayLibraryBase overlayLibrary, string overlayName) { slot.AddOverlay(overlayLibrary.InstantiateOverlay(overlayName)); if (equipSlotData.umaOverrideColor) { slot.SetOverlayColor(equipSlotData.umaOverlayColor, overlayName); } }
UMAData.UMARecipe CreateMaleRecipe() { var recipe = new UMAData.UMARecipe(); recipe.slotDataList = new SlotData[numberOfSlots]; recipe.AddDna(umaDna); recipe.AddDna(umaTutorialDna); recipe.SetRace(raceLibrary.GetRace("HumanMale")); SlotData eyes = slotLibrary.InstantiateSlot("MaleEyes"); eyes.AddOverlay(overlayLibrary.InstantiateOverlay("EyeOverlay")); recipe.slotDataList[0] = eyes; SlotData mouth = slotLibrary.InstantiateSlot("MaleInnerMouth"); mouth.AddOverlay(overlayLibrary.InstantiateOverlay("InnerMouth")); recipe.slotDataList[1] = mouth; recipe.slotDataList[2] = slotLibrary.InstantiateSlot("MaleFace", new List <OverlayData> { overlayLibrary.InstantiateOverlay("MaleHead02"), overlayLibrary.InstantiateOverlay("MaleEyebrow01", Color.black) });; SlotData torso = slotLibrary.InstantiateSlot("MaleTorso", new List <OverlayData> { overlayLibrary.InstantiateOverlay("MaleBody02"), overlayLibrary.InstantiateOverlay("MaleUnderwear01") }); recipe.slotDataList[3] = torso; recipe.slotDataList[4] = slotLibrary.InstantiateSlot("MaleHands", torso.GetOverlayList()); recipe.slotDataList[5] = slotLibrary.InstantiateSlot("MaleLegs", torso.GetOverlayList()); recipe.slotDataList[6] = slotLibrary.InstantiateSlot("MaleFeet", torso.GetOverlayList()); return(recipe); }
/// <summary> /// Instantiate an overlay by name. /// </summary> /// <returns>The overlay.</returns> /// <param name="name">Name.</param> public OverlayData InstantiateOverlay(string name) { return(overlayLibrary.InstantiateOverlay(name)); }
public static void Apply(UMA.UMAData umaData, CrowdRaceData race, Color skinColor, Color HairColor, HashSet <string> Keywords, SlotLibraryBase slotLibrary, OverlayLibraryBase overlayLibrary) { var slotParts = new HashSet <string>(); umaData.umaRecipe.slotDataList = new SlotData[race.slotElements.Length]; for (int i = 0; i < race.slotElements.Length; i++) { var currentElement = race.slotElements[i]; if (!string.IsNullOrEmpty(currentElement.requirement) && !slotParts.Contains(currentElement.requirement)) { continue; } if (!string.IsNullOrEmpty(currentElement.condition)) { if (currentElement.condition.StartsWith("!")) { if (Keywords.Contains(currentElement.condition.Substring(1))) { continue; } } else { if (!Keywords.Contains(currentElement.condition)) { continue; } } } if (currentElement.possibleSlots.Length == 0) { continue; } int randomResult = Random.Range(0, currentElement.possibleSlots.Length); var slot = currentElement.possibleSlots[randomResult]; if (string.IsNullOrEmpty(slot.slotID)) { continue; } slotParts.Add(slot.slotID); SlotData slotData; if (slot.useSharedOverlayList && slot.overlayListSource >= 0 && slot.overlayListSource < i) { slotData = slotLibrary.InstantiateSlot(slot.slotID, umaData.umaRecipe.slotDataList[slot.overlayListSource].GetOverlayList()); } else { if (slot.useSharedOverlayList) { Debug.LogError("UMA Crowd: Invalid overlayListSource for " + slot.slotID); } slotData = slotLibrary.InstantiateSlot(slot.slotID); } umaData.umaRecipe.slotDataList[i] = slotData; for (int overlayIdx = 0; overlayIdx < slot.overlayElements.Length; overlayIdx++) { var currentOverlayElement = slot.overlayElements[overlayIdx]; randomResult = Random.Range(0, currentOverlayElement.possibleOverlays.Length); var overlay = currentOverlayElement.possibleOverlays[randomResult]; if (string.IsNullOrEmpty(overlay.overlayID)) { continue; } overlay.UpdateVersion(); slotParts.Add(overlay.overlayID); Color overlayColor; switch (overlay.overlayType) { case UMACrowdRandomSet.OverlayType.Color: overlayColor = overlay.minRGB; break; case UMACrowdRandomSet.OverlayType.Texture: overlayColor = Color.white; break; case UMACrowdRandomSet.OverlayType.Hair: overlayColor = HairColor * overlay.hairColorMultiplier; break; case UMACrowdRandomSet.OverlayType.Skin: overlayColor = skinColor + new Color(Random.Range(overlay.minRGB.r, overlay.maxRGB.r), Random.Range(overlay.minRGB.g, overlay.maxRGB.g), Random.Range(overlay.minRGB.b, overlay.maxRGB.b), 1); break; case UMACrowdRandomSet.OverlayType.Random: overlayColor = new Color(Random.Range(overlay.minRGB.r, overlay.maxRGB.r), Random.Range(overlay.minRGB.g, overlay.maxRGB.g), Random.Range(overlay.minRGB.b, overlay.maxRGB.b), Random.Range(overlay.minRGB.a, overlay.maxRGB.a)); break; default: Debug.LogError("Unknown RandomSet overlayType: " + ((int)overlay.overlayType)); overlayColor = overlay.minRGB; break; } var overlayData = overlayLibrary.InstantiateOverlay(overlay.overlayID, overlayColor); slotData.AddOverlay(overlayData); if (overlay.colorChannelUse != ChannelUse.None) { overlayColor.a *= overlay.minRGB.a; if (overlay.colorChannelUse == ChannelUse.InverseColor) { Vector3 color = new Vector3(overlayColor.r, overlayColor.g, overlayColor.b); var len = color.magnitude; if (len < 1f) { len = 1f; } color = new Vector3(1.001f, 1.001f, 1.001f) - color; color = color.normalized * len; overlayColor = new Color(color.x, color.y, color.z, overlayColor.a); } overlayData.SetColor(overlay.colorChannel, overlayColor); } } } }
public static void Apply(UMA.UMAData umaData, CrowdRaceData race, Color skinColor, Color HairColor, HashSet <string> Keywords, SlotLibraryBase slotLibrary, OverlayLibraryBase overlayLibrary) { var slotParts = new HashSet <string>(); umaData.umaRecipe.slotDataList = new SlotData[race.slotElements.Length]; for (int i = 0; i < race.slotElements.Length; i++) { var currentElement = race.slotElements[i]; if (!string.IsNullOrEmpty(currentElement.requirement) && !slotParts.Contains(currentElement.requirement)) { continue; } if (!string.IsNullOrEmpty(currentElement.condition)) { if (currentElement.condition.StartsWith("!")) { if (Keywords.Contains(currentElement.condition.Substring(1))) { continue; } } else { if (!Keywords.Contains(currentElement.condition)) { continue; } } } if (currentElement.possibleSlots.Length == 0) { continue; } int randomResult = Random.Range(0, currentElement.possibleSlots.Length); var slot = currentElement.possibleSlots[randomResult]; if (string.IsNullOrEmpty(slot.slotID)) { continue; } slotParts.Add(slot.slotID); SlotData slotData; if (slot.useSharedOverlayList && slot.overlayListSource >= 0 && slot.overlayListSource < i) { slotData = slotLibrary.InstantiateSlot(slot.slotID, umaData.umaRecipe.slotDataList[slot.overlayListSource].GetOverlayList()); } else { if (slot.useSharedOverlayList) { Debug.LogError("UMA Crowd: Invalid overlayListSource for " + slot.slotID); } slotData = slotLibrary.InstantiateSlot(slot.slotID); } umaData.umaRecipe.slotDataList[i] = slotData; for (int overlayIdx = 0; overlayIdx < slot.overlayElements.Length; overlayIdx++) { var currentOverlayElement = slot.overlayElements[overlayIdx]; randomResult = Random.Range(0, currentOverlayElement.possibleOverlays.Length); var overlay = currentOverlayElement.possibleOverlays[randomResult]; if (string.IsNullOrEmpty(overlay.overlayID)) { continue; } slotParts.Add(overlay.overlayID); Color overlayColor; if (overlay.useSkinColor) { overlayColor = skinColor + new Color(Random.Range(overlay.minRGB.r, overlay.maxRGB.r), Random.Range(overlay.minRGB.g, overlay.maxRGB.g), Random.Range(overlay.minRGB.b, overlay.maxRGB.b), 1); } else if (overlay.useHairColor) { overlayColor = HairColor * overlay.hairColorMultiplier; } else { overlayColor = new Color(Random.Range(overlay.minRGB.r, overlay.maxRGB.r), Random.Range(overlay.minRGB.g, overlay.maxRGB.g), Random.Range(overlay.minRGB.b, overlay.maxRGB.b), 1); } slotData.AddOverlay(overlayLibrary.InstantiateOverlay(overlay.overlayID, overlayColor)); } if (umaData.umaRecipe.slotDataList[i].GetOverlayList().Count == 0) { Debug.LogError("Slot without overlay: " + umaData.umaRecipe.slotDataList[i].slotName + " at index " + i + " of race: " + race.raceID); } } }
public static void Apply(UMA.UMAData umaData, CrowdRaceData race, Color skinColor, Color HairColor, HashSet<string> Keywords, SlotLibraryBase slotLibrary, OverlayLibraryBase overlayLibrary) { var slotParts = new HashSet<string>(); umaData.umaRecipe.slotDataList = new SlotData[race.slotElements.Length]; for (int i = 0; i < race.slotElements.Length; i++) { var currentElement = race.slotElements[i]; if (!string.IsNullOrEmpty(currentElement.requirement) && !slotParts.Contains(currentElement.requirement)) continue; if (!string.IsNullOrEmpty(currentElement.condition)) { if (currentElement.condition.StartsWith("!")) { if (Keywords.Contains(currentElement.condition.Substring(1))) continue; } else { if (!Keywords.Contains(currentElement.condition)) continue; } } if (currentElement.possibleSlots.Length == 0) continue; int randomResult = Random.Range(0, currentElement.possibleSlots.Length); var slot = currentElement.possibleSlots[randomResult]; if (string.IsNullOrEmpty(slot.slotID)) continue; slotParts.Add(slot.slotID); SlotData slotData; if (slot.useSharedOverlayList && slot.overlayListSource >= 0 && slot.overlayListSource < i) { slotData = slotLibrary.InstantiateSlot(slot.slotID, umaData.umaRecipe.slotDataList[slot.overlayListSource].GetOverlayList()); } else { if (slot.useSharedOverlayList) { Debug.LogError("UMA Crowd: Invalid overlayListSource for " + slot.slotID); } slotData = slotLibrary.InstantiateSlot(slot.slotID); } umaData.umaRecipe.slotDataList[i] = slotData; for (int overlayIdx = 0; overlayIdx < slot.overlayElements.Length; overlayIdx++) { var currentOverlayElement = slot.overlayElements[overlayIdx]; randomResult = Random.Range(0, currentOverlayElement.possibleOverlays.Length); var overlay = currentOverlayElement.possibleOverlays[randomResult]; if (string.IsNullOrEmpty(overlay.overlayID)) continue; overlay.UpdateVersion(); slotParts.Add(overlay.overlayID); Color overlayColor; switch (overlay.overlayType) { case UMACrowdRandomSet.OverlayType.Color: overlayColor = overlay.minRGB; break; case UMACrowdRandomSet.OverlayType.Texture: overlayColor = Color.white; break; case UMACrowdRandomSet.OverlayType.Hair: overlayColor = HairColor * overlay.hairColorMultiplier; break; case UMACrowdRandomSet.OverlayType.Skin: overlayColor = skinColor + new Color(Random.Range(overlay.minRGB.r, overlay.maxRGB.r), Random.Range(overlay.minRGB.g, overlay.maxRGB.g), Random.Range(overlay.minRGB.b, overlay.maxRGB.b), 1); break; case UMACrowdRandomSet.OverlayType.Random: overlayColor = new Color(Random.Range(overlay.minRGB.r, overlay.maxRGB.r), Random.Range(overlay.minRGB.g, overlay.maxRGB.g), Random.Range(overlay.minRGB.b, overlay.maxRGB.b), Random.Range(overlay.minRGB.a, overlay.maxRGB.a)); break; default: Debug.LogError("Unknown RandomSet overlayType: "+((int)overlay.overlayType)); overlayColor = overlay.minRGB; break; } var overlayData = overlayLibrary.InstantiateOverlay(overlay.overlayID, overlayColor); slotData.AddOverlay(overlayData); if (overlay.colorChannelUse != ChannelUse.None) { overlayColor.a *= overlay.minRGB.a; if (overlay.colorChannelUse == ChannelUse.InverseColor) { Vector3 color = new Vector3(overlayColor.r, overlayColor.g, overlayColor.b); var len = color.magnitude; if (len < 1f) len = 1f; color = new Vector3(1.001f, 1.001f, 1.001f) - color; color = color.normalized* len; overlayColor = new Color(color.x, color.y, color.z, overlayColor.a); } overlayData.SetColor(overlay.colorChannel, overlayColor); } } if (umaData.umaRecipe.slotDataList[i].GetOverlayList().Count == 0) { Debug.LogError("Slot without overlay: " + umaData.umaRecipe.slotDataList[i].slotName + " at index " + i + " of race: " + race.raceID); } } }
public static void Apply(UMA.UMAData umaData, CrowdRaceData race, Color skinColor, Color HairColor, HashSet<string> Keywords, SlotLibraryBase slotLibrary, OverlayLibraryBase overlayLibrary) { var slotParts = new HashSet<string>(); umaData.umaRecipe.slotDataList = new SlotData[race.slotElements.Length]; for (int i = 0; i < race.slotElements.Length; i++) { var currentElement = race.slotElements[i]; if (!string.IsNullOrEmpty(currentElement.requirement) && !slotParts.Contains(currentElement.requirement)) continue; if (!string.IsNullOrEmpty(currentElement.condition)) { if (currentElement.condition.StartsWith("!")) { if (Keywords.Contains(currentElement.condition.Substring(1))) continue; } else { if (!Keywords.Contains(currentElement.condition)) continue; } } if (currentElement.possibleSlots.Length == 0) continue; int randomResult = Random.Range(0, currentElement.possibleSlots.Length); var slot = currentElement.possibleSlots[randomResult]; if (string.IsNullOrEmpty(slot.slotID)) continue; slotParts.Add(slot.slotID); SlotData slotData; if (slot.useSharedOverlayList && slot.overlayListSource >= 0 && slot.overlayListSource < i) { slotData = slotLibrary.InstantiateSlot(slot.slotID, umaData.umaRecipe.slotDataList[slot.overlayListSource].GetOverlayList()); } else { if (slot.useSharedOverlayList) { Debug.LogError("UMA Crowd: Invalid overlayListSource for " + slot.slotID); } slotData = slotLibrary.InstantiateSlot(slot.slotID); } umaData.umaRecipe.slotDataList[i] = slotData; for (int overlayIdx = 0; overlayIdx < slot.overlayElements.Length; overlayIdx++) { var currentOverlayElement = slot.overlayElements[overlayIdx]; randomResult = Random.Range(0, currentOverlayElement.possibleOverlays.Length); var overlay = currentOverlayElement.possibleOverlays[randomResult]; if (string.IsNullOrEmpty(overlay.overlayID)) continue; slotParts.Add(overlay.overlayID); Color overlayColor; if (overlay.useSkinColor) { overlayColor = skinColor + new Color(Random.Range(overlay.minRGB.r, overlay.maxRGB.r), Random.Range(overlay.minRGB.g, overlay.maxRGB.g), Random.Range(overlay.minRGB.b, overlay.maxRGB.b), 1); } else if (overlay.useHairColor) { overlayColor = HairColor * overlay.hairColorMultiplier; } else { overlayColor = new Color(Random.Range(overlay.minRGB.r, overlay.maxRGB.r), Random.Range(overlay.minRGB.g, overlay.maxRGB.g), Random.Range(overlay.minRGB.b, overlay.maxRGB.b), 1); } slotData.AddOverlay(overlayLibrary.InstantiateOverlay(overlay.overlayID, overlayColor)); } if (umaData.umaRecipe.slotDataList[i].GetOverlayList().Count == 0) { Debug.LogError("Slot without overlay: " + umaData.umaRecipe.slotDataList[i].slotName + " at index " + i + " of race: " + race.raceID); } } }