public void RandomWardrobeSlotGUI(RandomAvatar ra, RandomWardrobeSlot rws) { // do random colors // show each possible item. GUIHelper.FoldoutBar(ref rws.GuiFoldout, rws.WardrobeSlot.name + " (" + rws.WardrobeSlot.wardrobeSlot + ")", out rws.Delete); if (rws.GuiFoldout) { GUIHelper.BeginVerticalPadded(10, new Color(0.75f, 0.75f, 0.75f)); rws.Chance = EditorGUILayout.IntSlider("Weighted Chance", rws.Chance, 1, 100); if (rws.PossibleColors.Length > 0) { if (GUILayout.Button("Add Shared Color")) { rws.AddColorTable = true; } foreach (RandomColors rc in rws.Colors) { RandomColorsGUI(ra, rws, rc); } } else { GUILayout.Label("Wardrobe Recipe has no Shared Colors"); } GUIHelper.EndVerticalPadded(10); } }
public void RandomColorsGUI(RandomAvatar ra, RandomWardrobeSlot rws, RandomColors rc) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Shared Color", GUILayout.Width(80)); rc.CurrentColor = EditorGUILayout.Popup(rc.CurrentColor, rws.PossibleColors, GUILayout.Width(80)); rc.ColorName = rws.PossibleColors[rc.CurrentColor]; EditorGUILayout.LabelField("Color Table", GUILayout.Width(80)); rc.ColorTable = (SharedColorTable)EditorGUILayout.ObjectField(rc.ColorTable, typeof(SharedColorTable), false, GUILayout.ExpandWidth(true)); EditorGUILayout.EndHorizontal(); }
public bool RandomColorsGUI(RandomAvatar ra, RandomWardrobeSlot rws, RandomColors rc) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Shared Color", GUILayout.Width(80)); rc.CurrentColor = EditorGUILayout.Popup(rc.CurrentColor, rws.PossibleColors, GUILayout.Width(80)); rc.ColorName = rws.PossibleColors[rc.CurrentColor]; EditorGUILayout.LabelField("Color Table", GUILayout.Width(80)); rc.ColorTable = (SharedColorTable)EditorGUILayout.ObjectField(rc.ColorTable, typeof(SharedColorTable), false, GUILayout.ExpandWidth(true)); bool retval = GUILayout.Button("\u0078", EditorStyles.miniButton, GUILayout.ExpandWidth(false)); EditorGUILayout.EndHorizontal(); return(retval); }
public void RandomWardrobeSlotGUI(RandomAvatar ra, RandomWardrobeSlot rws) { // do random colors // show each possible item. string name = "<null>"; if (rws.WardrobeSlot != null) { name = rws.WardrobeSlot.name; } GUIHelper.FoldoutBar(ref rws.GuiFoldout, name + " (" + rws.Chance + ")", out rws.Delete); if (rws.GuiFoldout) { GUIHelper.BeginVerticalPadded(10, new Color(0.75f, 0.75f, 0.75f)); rws.Chance = EditorGUILayout.IntSlider("Weighted Chance", rws.Chance, 1, 100); if (rws.PossibleColors.Length > 0) { if (GUILayout.Button("Add Shared Color")) { rws.AddColorTable = true; } RandomColors delme = null; foreach (RandomColors rc in rws.Colors) { if (RandomColorsGUI(ra, rws, rc)) { delme = rc; } } if (delme != null) { rws.Colors.Remove(delme); EditorUtility.SetDirty(this.target); AssetDatabase.SaveAssets(); } } else { GUILayout.Label("Wardrobe Recipe has no Shared Colors"); } GUIHelper.EndVerticalPadded(10); } }
private void UpdateObject() { // Add any dropped items. int ChangeCount = currentTarget.droppedItems.Count; if (currentTarget.droppedItems.Count > 0) { foreach (RandomAvatar rv in currentTarget.RandomAvatars) { rv.GuiFoldout = false; foreach (RandomWardrobeSlot rws in rv.RandomWardrobeSlots) { rws.GuiFoldout = false; } } RandomAvatar ra = FindAvatar(currentTarget.raceDatas[currentTarget.currentRace]); // Add all the wardrobe items. foreach (UMAWardrobeRecipe uwr in currentTarget.droppedItems) { if (RecipeCompatible(uwr, currentTarget.raceDatas[currentTarget.currentRace])) { RandomWardrobeSlot rws = new RandomWardrobeSlot(uwr, uwr.wardrobeSlot); ra.GuiFoldout = true; ra.RandomWardrobeSlots.Add(rws); } } // sort the wardrobe slots ra.RandomWardrobeSlots.Sort((x, y) => x.SortName.CompareTo(y.SortName)); currentTarget.droppedItems.Clear(); } ChangeCount += currentTarget.RandomAvatars.RemoveAll(x => x.Delete); foreach (RandomAvatar ra in currentTarget.RandomAvatars) { if (!string.IsNullOrEmpty(ra.DNAAdd)) { ra.DnaChanged = true; ra.RandomDna.Add(new RandomDNA(ra.DNAAdd)); ra.DNAAdd = ""; ChangeCount++; } int DNAChangeCount = ra.RandomDna.RemoveAll(x => x.Delete); if (DNAChangeCount > 0) { ra.DnaChanged = true; ChangeCount++; } ChangeCount += ra.SharedColors.RemoveAll(x => x.Delete); ChangeCount += ra.RandomWardrobeSlots.RemoveAll(x => x.Delete); foreach (RandomWardrobeSlot rws in ra.RandomWardrobeSlots) { ChangeCount += rws.Colors.RemoveAll(x => x.Delete); if (rws.AddColorTable) { rws.Colors.Add(new RandomColors(rws)); rws.AddColorTable = false; ChangeCount++; } } } if (ChangeCount > 0) { EditorUtility.SetDirty(currentTarget); AssetDatabase.SaveAssets(); } }