void OnGUI() { #region fonts variables var bold = new GUIStyle("label"); var boldFold = new GUIStyle("foldout"); bold.fontStyle = FontStyle.Bold; bold.fontSize = 14; boldFold.fontStyle = FontStyle.Bold; // var someMatched = false; var Slim = new GUIStyle("label"); Slim.fontStyle = FontStyle.Normal; Slim.fontSize = 10; var style = new GUIStyle("label"); style.wordWrap = true; #endregion fonts variables #region choose Places List if (Action == "ChoosePlace") { using (new Horizontal()) { GUILayout.Label("choose a Place for the Element", "toolbarbutton", GUILayout.ExpandWidth(true)); GUI.color = new Color(0.9f, 0.5f, 0.5f); if (GUILayout.Button("X", "toolbarbutton", GUILayout.ExpandWidth(false))) { Action = ""; this.Close(); } } } GUI.color = Color.white; GUILayout.Space(5); using (new Horizontal()) { GUI.color = Color.white; GUILayout.Label("Anatomy Slot Name", "toolbarbutton", GUILayout.Width(140)); GUILayout.Label("Race", "toolbarbutton", GUILayout.Width(60)); GUILayout.Label("Gender", "toolbarbutton", GUILayout.Width(55)); GUILayout.Label("Overlay Type", "toolbarbutton", GUILayout.Width(90)); GUILayout.Label("", "toolbarbutton", GUILayout.ExpandWidth(true)); } using (new Horizontal()) { using (new ScrollView(ref scroll)) { SlotsAnatomyLibraryObj = GameObject.Find("DK_SlotsAnatomyLibrary"); DK_SlotsAnatomyLibrary _SlotsAnatomyLibrary = SlotsAnatomyLibraryObj.GetComponent <DK_SlotsAnatomyLibrary>(); for (int i = 0; i < _SlotsAnatomyLibrary.dk_SlotsAnatomyElementList.Length; i++) { DK_Race DK_Race = _SlotsAnatomyLibrary.dk_SlotsAnatomyElementList[i].GetComponent("DK_Race") as DK_Race; using (new Horizontal(GUILayout.Width(80))) { // Element if (EditorVariables.SelectedElemPlace == _SlotsAnatomyLibrary.dk_SlotsAnatomyElementList[i]) { GUI.color = Color.yellow; } else { GUI.color = Color.white; } if (GUILayout.Button(_SlotsAnatomyLibrary.dk_SlotsAnatomyElementList[i].dk_SlotsAnatomyElement.dk_SlotsAnatomyName, "toolbarbutton", GUILayout.Width(140))) { EditorVariables.SelectedElemPlace = _SlotsAnatomyLibrary.dk_SlotsAnatomyElementList[i]; DKSlotData SelectedSlotElement = Selection.activeObject as DKSlotData; if (SelectedSlotElement != null) { if (Action == "ChoosePlace") { SelectedSlotElement.Place = EditorVariables.SelectedElemPlace; } } DKOverlayData SelectedOverlayElement = Selection.activeObject as DKOverlayData; if (SelectedOverlayElement != null) { if (Action == "ChoosePlace") { SelectedOverlayElement.Place = EditorVariables.SelectedElemPlace; } } EditorUtility.SetDirty(DK_Race.gameObject); AssetDatabase.SaveAssets(); this.Close(); } // Race if (_SlotsAnatomyLibrary.dk_SlotsAnatomyElementList[i].gameObject.GetComponent <DK_Race>() as DK_Race == null) { _SlotsAnatomyLibrary.dk_SlotsAnatomyElementList[i].gameObject.AddComponent <DK_Race>(); } if (DK_Race.Race.Count == 0) { GUI.color = new Color(0.9f, 0.5f, 0.5f); } if (DK_Race.Race.Count == 0 && GUILayout.Button("No Race", Slim, GUILayout.Width(50))) { } GUI.color = new Color(0.8f, 1f, 0.8f, 1); if (DK_Race.Race.Count == 1 && GUILayout.Button(DK_Race.Race[0], Slim, GUILayout.Width(50))) { } if (DK_Race.Race.Count > 1 && GUILayout.Button("Multi", Slim, GUILayout.Width(50))) { } // Gender if (DK_Race.Gender == "") { GUI.color = new Color(0.9f, 0.5f, 0.5f); } if (DK_Race.Gender == "") { GUILayout.Label("N", "Button"); } GUI.color = new Color(0.8f, 1f, 0.8f, 1); if (DK_Race.Gender != "" && DK_Race.Gender == "Female") { GUILayout.Label("Female", Slim, GUILayout.Width(50)); } if (DK_Race.Gender != "" && DK_Race.Gender == "Male") { GUILayout.Label("Male", Slim, GUILayout.Width(50)); } if (DK_Race.Gender != "" && DK_Race.Gender == "Both") { GUILayout.Label("Both", Slim, GUILayout.Width(50)); } // OverlayType if (_SlotsAnatomyLibrary.dk_SlotsAnatomyElementList[i].gameObject.GetComponent <DK_Race>() as DK_Race == null) { _SlotsAnatomyLibrary.dk_SlotsAnatomyElementList[i].gameObject.AddComponent <DK_Race>(); } DK_Race = _SlotsAnatomyLibrary.dk_SlotsAnatomyElementList[i].GetComponent("DK_Race") as DK_Race; if (DK_Race.OverlayType == "") { GUI.color = new Color(0.9f, 0.5f, 0.5f); } if (DK_Race.OverlayType == "" && GUILayout.Button("No Race", Slim, GUILayout.Width(50))) { } GUI.color = new Color(0.8f, 1f, 0.8f, 1); if (DK_Race.OverlayType != "" && GUILayout.Button(DK_Race.OverlayType, Slim, GUILayout.Width(50))) { } } } } } #endregion choose Places List }
void OnGUI () { #region fonts variables var bold = new GUIStyle ("label"); var boldFold = new GUIStyle ("foldout"); bold.fontStyle = FontStyle.Bold; bold.fontSize = 14; boldFold.fontStyle = FontStyle.Bold; var Slim = new GUIStyle ("label"); Slim.fontStyle = FontStyle.Normal; Slim.fontSize = 10; var style = new GUIStyle ("label"); style.wordWrap = true; #endregion fonts variables using (new Horizontal()) { GUILayout.Label ( "Races List", "toolbarbutton", GUILayout.ExpandWidth (true)); } tmpObj = (Selection.activeObject as GameObject); if ( Selection.activeObject && Selection.activeObject.GetType().ToString() == "DKRaceData"){ GUI.color = Color.yellow; GUILayout.Label ( "Selection is a Race. Select a Slot or an Overlay.", GUILayout.ExpandWidth (false)); } GUI.color = Color.white; if ( EditorVariables.AutoDetLib == false && Selection.activeObject && Selection.activeObject.GetType().ToString() != "DKRaceData" && ( Selection.activeObject.GetType().ToString() == "DKSlotData" || Selection.activeObject.GetType().ToString() == "DKOverlayData" || ( tmpObj && tmpObj.GetComponent<DK_SlotsAnatomyElement>() != null))) { SelectedElemObj = ( Selection.activeObject as GameObject); using (new Horizontal()) { GUILayout.Label ( "Element :", GUILayout.ExpandWidth (false)); if ( Selection.activeObject.GetType().ToString() == "DKSlotData" ) { SelectedElemName = Selection.activeObject.name; SelectedElemType = "DKSlotData"; } else if ( Selection.activeObject.GetType().ToString() == "DKOverlayData" ) { SelectedElemName = Selection.activeObject.name; SelectedElemType = "DKOverlayData"; } else{ if ( tmpObj.GetComponent<DK_SlotsAnatomyElement>() != null ) { SelectedElemName = Selection.activeObject.name; SelectedElemType = "Anatomy Part"; } } GUILayout.Label ( SelectedElemName, GUILayout.Width (120)); GUILayout.Label ( "Type :", GUILayout.ExpandWidth (false)); GUILayout.Label ( SelectedElemType, GUILayout.Width (120)); } using (new Horizontal()) { GUILayout.Label ( "Element's Races List", "toolbarbutton", GUILayout.ExpandWidth (true)); } // Slots Only if ( (Selection.activeObject.GetType().ToString() == "DKSlotData")){ DKSlotData _SlotData = (Selection.activeObject as DKSlotData); // clear using (new Horizontal()) { if ( GUILayout.Button ( "clear Element's list", GUILayout.ExpandWidth (true))) { _SlotData.Race.Clear(); } if ( GUILayout.Button ( "clear Races list", GUILayout.ExpandWidth (true))) { RaceDataList.Clear(); } if ( RaceDataList.Count != 0 && _SlotData.Race.Count == 00 && GUILayout.Button ( "Add All", GUILayout.ExpandWidth (true))) { if ( RaceDataList.Count != 0 && _SlotData.Race.Count == 00 ) _SlotData.Race = RaceDataList; } } for(int i = 0; i < EditorVariables._RaceLibrary.raceElementList.Length; i ++){ if ( RaceDataList.Contains(EditorVariables._RaceLibrary.raceElementList[i].Race) ) { } else RaceDataList.Add(EditorVariables._RaceLibrary.raceElementList[i].Race); } using (new Horizontal()) { if (_SlotData.Race.Count > 0 )using (new ScrollView(ref scroll1)) { for(int i = 0; i < _SlotData.Race.Count; i ++){ using (new Horizontal()) { GUI.color = new Color (0.9f, 0.5f, 0.5f); if ( GUILayout.Button ( "X", "toolbarbutton", GUILayout.ExpandWidth (false))) { _SlotData.Race.Remove(_SlotData.Race[i]); EditorUtility.SetDirty(_SlotData); AssetDatabase.SaveAssets(); } GUI.color = Color.white; if ( i < _SlotData.Race.Count ) if ( GUILayout.Button ( _SlotData.Race[i], Slim, GUILayout.ExpandWidth (true))) { } } } } if (RaceDataList.Count > 0 )using (new ScrollView(ref scroll)) { for(int i = 0; i < RaceDataList.Count; i ++){ using (new Horizontal()) { if ( _SlotData.Race.Contains(RaceDataList[i]) ) GUI.color = Color.gray; else GUI.color = new Color (0.8f, 1f, 0.8f, 1); if ( GUILayout.Button ( "<", "toolbarbutton", GUILayout.ExpandWidth (false))) { _SlotData.Race.Add(RaceDataList[i]); EditorUtility.SetDirty(_SlotData); AssetDatabase.SaveAssets(); } if ( _SlotData.Race.Contains(RaceDataList[i]) ) GUI.color = Color.gray; else GUI.color = Color.white; if ( GUILayout.Button ( RaceDataList[i], Slim, GUILayout.ExpandWidth (true))) { } } } } } } // Overlays Only if ( (Selection.activeObject.GetType().ToString() == "DKOverlayData")){ DKOverlayData _DKOverlayData = (Selection.activeObject as DKOverlayData); // clear using (new Horizontal()) { if ( GUILayout.Button ( "clear Element's list", GUILayout.ExpandWidth (true))) { _DKOverlayData.Race.Clear(); } if ( GUILayout.Button ( "clear Races list", GUILayout.ExpandWidth (true))) { RaceDataList.Clear(); } if ( RaceDataList.Count != 0 && _DKOverlayData.Race.Count == 00 && GUILayout.Button ( "Add All", GUILayout.ExpandWidth (true))) { if ( RaceDataList.Count != 0 && _DKOverlayData.Race.Count == 00 ) _DKOverlayData.Race = RaceDataList; } } for(int i = 0; i < EditorVariables._RaceLibrary.raceElementList.Length; i ++){ if ( RaceDataList.Contains(EditorVariables._RaceLibrary.raceElementList[i].Race) ) { } else RaceDataList.Add(EditorVariables._RaceLibrary.raceElementList[i].Race); } using (new Horizontal()) { if (_DKOverlayData.Race.Count > 0 )using (new ScrollView(ref scroll1)) { for(int i = 0; i < _DKOverlayData.Race.Count; i ++){ using (new Horizontal()) { GUI.color = new Color (0.9f, 0.5f, 0.5f); if ( GUILayout.Button ( "X", "toolbarbutton", GUILayout.ExpandWidth (false))) { _DKOverlayData.Race.Remove(_DKOverlayData.Race[i]); EditorUtility.SetDirty(_DKOverlayData); AssetDatabase.SaveAssets(); } GUI.color = Color.white; if ( i < _DKOverlayData.Race.Count ) if ( GUILayout.Button ( _DKOverlayData.Race[i], Slim, GUILayout.ExpandWidth (true))) { } } } } if (RaceDataList.Count > 0 )using (new ScrollView(ref scroll)) { for(int i = 0; i < RaceDataList.Count; i ++){ using (new Horizontal()) { if ( _DKOverlayData.Race.Contains(RaceDataList[i]) ) GUI.color = Color.gray; else GUI.color = new Color (0.8f, 1f, 0.8f, 1); if ( GUILayout.Button ( "<", "toolbarbutton", GUILayout.ExpandWidth (false))) { _DKOverlayData.Race.Add(RaceDataList[i]); EditorUtility.SetDirty(_DKOverlayData); AssetDatabase.SaveAssets(); } if ( _DKOverlayData.Race.Contains(RaceDataList[i]) ) GUI.color = Color.gray; else GUI.color = Color.white; if ( GUILayout.Button ( RaceDataList[i], Slim, GUILayout.ExpandWidth (true))) { } } } } } } } // Anatomy Only if ( EditorVariables.AutoDetLib == false && Selection.activeObject as GameObject && ((Selection.activeObject as GameObject).GetComponent<DK_Race>() != null)){ DK_Race _DK_Race = (Selection.activeObject as GameObject).GetComponent<DK_Race>(); // clear using (new Horizontal()) { if ( GUILayout.Button ( "clear Element's list", GUILayout.ExpandWidth (true))) { _DK_Race.Race.Clear(); } if ( GUILayout.Button ( "clear Races list", GUILayout.ExpandWidth (true))) { RaceDataList.Clear(); } if ( RaceDataList.Count != 0 && _DK_Race.Race.Count == 00 && GUILayout.Button ( "Add All", GUILayout.ExpandWidth (true))) { if ( RaceDataList.Count != 0 && _DK_Race.Race.Count == 00 ) _DK_Race.Race = RaceDataList; } } for(int i = 0; i < EditorVariables._RaceLibrary.raceElementList.Length; i ++){ if ( RaceDataList.Contains(EditorVariables._RaceLibrary.raceElementList[i].Race) ) { } else RaceDataList.Add(EditorVariables._RaceLibrary.raceElementList[i].Race); } using (new Horizontal()) { if (_DK_Race.Race.Count > 0 )using (new ScrollView(ref scroll1)) { for(int i = 0; i < _DK_Race.Race.Count; i ++){ using (new Horizontal()) { GUI.color = new Color (0.9f, 0.5f, 0.5f); if ( GUILayout.Button ( "X", "toolbarbutton", GUILayout.ExpandWidth (false))) { _DK_Race.Race.Remove(_DK_Race.Race[i]); EditorUtility.SetDirty(_DK_Race); AssetDatabase.SaveAssets(); } GUI.color = Color.white; if ( i < _DK_Race.Race.Count ) if ( GUILayout.Button ( _DK_Race.Race[i], Slim, GUILayout.ExpandWidth (true))) { } } } } if (RaceDataList.Count > 0 )using (new ScrollView(ref scroll)) { for(int i = 0; i < RaceDataList.Count; i ++){ using (new Horizontal()) { if ( _DK_Race.Race.Contains(RaceDataList[i]) ) GUI.color = Color.gray; else GUI.color = new Color (0.8f, 1f, 0.8f, 1); if ( GUILayout.Button ( "<", "toolbarbutton", GUILayout.ExpandWidth (false))) { _DK_Race.Race.Add(RaceDataList[i]); EditorUtility.SetDirty(_DK_Race); AssetDatabase.SaveAssets(); } if ( _DK_Race.Race.Contains(RaceDataList[i]) ) GUI.color = Color.gray; else GUI.color = Color.white; if ( GUILayout.Button ( RaceDataList[i], Slim, GUILayout.ExpandWidth (true))) { } } } } } } // AutoDetectLib Only if ( EditorVariables.AutoDetLib == true ) { GUILayout.Label("AutoDetect Process Race's Section", GUILayout.ExpandWidth (true)); if ( GUILayout.Button ( "Done", GUILayout.ExpandWidth (true))) { EditorVariables.NewRaceName = ""; for(int i = 0; i < EditorVariables.RaceToApplyList.Count; i ++){ EditorVariables.NewRaceName = EditorVariables.NewRaceName+" -"+EditorVariables.RaceToApplyList[i]; } this.Close(); } // clear try{ using (new Horizontal()) { if ( GUILayout.Button ( "clear Destination's list", GUILayout.ExpandWidth (true))) { EditorVariables.RaceToApplyList.Clear(); } if ( GUILayout.Button ( "clear Races list", GUILayout.ExpandWidth (true))) { RaceDataList.Clear(); } if ( RaceDataList.Count != 0 && EditorVariables.RaceToApplyList.Count == 00 && GUILayout.Button ( "Add All", GUILayout.ExpandWidth (true))) { if ( RaceDataList.Count != 0 && EditorVariables.RaceToApplyList.Count == 00 ) EditorVariables.RaceToApplyList = RaceDataList; } } }catch(ArgumentException){} for(int i = 0; i < EditorVariables._RaceLibrary.raceElementList.Length; i ++){ if ( RaceDataList.Contains(EditorVariables._RaceLibrary.raceElementList[i].Race) ) { } else RaceDataList.Add(EditorVariables._RaceLibrary.raceElementList[i].Race); } using (new Horizontal()) { if (EditorVariables.RaceToApplyList.Count > 0 )using (new ScrollView(ref scroll1)) { for(int i = 0; i < EditorVariables.RaceToApplyList.Count; i ++){ using (new Horizontal()) { GUI.color = new Color (0.9f, 0.5f, 0.5f); if ( GUILayout.Button ( "X", "toolbarbutton", GUILayout.ExpandWidth (false))) { EditorVariables.RaceToApplyList.Remove(EditorVariables.RaceToApplyList[i]); } GUI.color = Color.white; if ( i < EditorVariables.RaceToApplyList.Count ) if ( GUILayout.Button ( EditorVariables.RaceToApplyList[i], Slim, GUILayout.ExpandWidth (true))) { } } } } if (RaceDataList.Count > 0 )using (new ScrollView(ref scroll)) { for(int i = 0; i < RaceDataList.Count; i ++){ using (new Horizontal()) { if ( EditorVariables.RaceToApplyList.Contains(RaceDataList[i]) ) GUI.color = Color.gray; else GUI.color = new Color (0.8f, 1f, 0.8f, 1); if ( GUILayout.Button ( "<", "toolbarbutton", GUILayout.ExpandWidth (false))) { EditorVariables.RaceToApplyList.Add(RaceDataList[i]); } if ( EditorVariables.RaceToApplyList.Contains(RaceDataList[i]) ) GUI.color = Color.gray; else GUI.color = Color.white; if ( GUILayout.Button ( RaceDataList[i], Slim, GUILayout.ExpandWidth (true))) { } } } } } } }
public static void OnSelectionChange() { if (Selection.activeObject && DK_UMA_Editor.ShowPrepare) { if (Selection.activeObject.GetType().ToString() == "DKRaceData" || Selection.activeObject.GetType().ToString() == "DKSlotData" || Selection.activeObject.GetType().ToString() == "DKOverlayData") { DK_UMA_Editor.SelectedPrefabName = Selection.activeObject.name; if (Selection.activeObject.GetType().ToString() == "DKRaceData") { DKRaceData SelectedData = (Selection.activeObject as DKRaceData); EditorVariables.SelectedElementName = SelectedData.raceName; DK_UMA_Editor._Name = SelectedData.Race; EditorVariables.SelectedElementGender = SelectedData.Gender; EditorVariables.SelectedElementObj = Selection.activeObject as GameObject; } if (Selection.activeObject.GetType().ToString() == "DKSlotData") { DKSlotData SelectedData = (Selection.activeObject as DKSlotData); EditorVariables.SelectedElementName = SelectedData.slotName; EditorVariables.SelectedElementGender = SelectedData.Gender; EditorVariables.overlayList = SelectedData.overlayList; EditorVariables.SelectedElementObj = Selection.activeObject as GameObject; EditorVariables.SelectedElementOverlayType = SelectedData.OverlayType; EditorVariables.SelectedElementWearWeight = SelectedData.WearWeight; EditorVariables.Replace = SelectedData.Replace; if (SelectedData.Place != null) { EditorVariables.SelectedElemPlace = SelectedData.Place; } } if (Selection.activeObject.GetType().ToString() == "DKOverlayData") { DKOverlayData SelectedData = (Selection.activeObject as DKOverlayData); EditorVariables.SelectedElementName = SelectedData.overlayName; EditorVariables.SelectedElementGender = SelectedData.Gender; EditorVariables.SelectedElementObj = Selection.activeObject as GameObject; EditorVariables.SelectedElementOverlayType = SelectedData.OverlayType; EditorVariables.SelectedElementWearWeight = SelectedData.WearWeight; if (SelectedData.Place != null) { EditorVariables.SelectedElemPlace = SelectedData.Place; } } } } if (DK_UMA_Editor.showModify) { // colors GameObject UMACustomObj = GameObject.Find("DKUMACustomization"); if (UMACustomObj != null) { EditorVariables.DK_DKUMACustomization = UMACustomObj.GetComponent <DKUMACustomization>(); if (Selection.activeGameObject != null) { foreach (Transform Child in Selection.activeGameObject.transform) { if (Child.gameObject.GetComponent <DKUMAData>() != null) { EditorVariables.DK_DKUMACustomization.EditedModel = Child; DK_UMA_Editor.EditedModel = Child; } } } } } if (Selection.activeGameObject && Selection.activeGameObject.GetComponent <DK_Race>() != null) { DK_Race _DK_Race = Selection.activeGameObject.GetComponent <DK_Race>(); DK_UMA_Editor._SpawnPerct = _DK_Race.SpawnPerct.ToString(); } EditorVariables.SelectedElemSlot = null; EditorVariables.SelectedElemOvlay = null; EditorVariables.SelectedElementObj = null; }
void OnGUI() { this.minSize = new Vector2(320, 500); #region fonts variables var bold = new GUIStyle("label"); var boldFold = new GUIStyle("foldout"); bold.fontStyle = FontStyle.Bold; bold.fontSize = 14; boldFold.fontStyle = FontStyle.Bold; var Slim = new GUIStyle("label"); Slim.fontStyle = FontStyle.Normal; Slim.fontSize = 10; var style = new GUIStyle("label"); style.wordWrap = true; #endregion fonts variables if (_SlotsAnatomyLibrary == null && EditorVariables.SlotsAnatomyLibraryObj) { _SlotsAnatomyLibrary = EditorVariables.SlotsAnatomyLibraryObj.GetComponent <DK_SlotsAnatomyLibrary>(); } GUILayout.Space(5); using (new Horizontal()) { GUI.color = Color.white; GUILayout.Label("Modify Anatomy Slots", "toolbarbutton", GUILayout.ExpandWidth(true)); GUI.color = Red; // if ( GUILayout.Button ( "X", "toolbarbutton", GUILayout.ExpandWidth (false))) { // } } GUILayout.Space(5); GUI.color = Color.white; if (Helper) { GUILayout.TextField("The Anatomy Parts are used during the creation of the UMA Model. " + "The engine check all the Anatomy parts to select the torso and its slot and overlays. " + "Each part determines what slot Element will be generated to be placed on it. " + "It is also used by the Overlay Element to associate with a slot.", 300, style, GUILayout.ExpandWidth(true), GUILayout.ExpandWidth(true)); } if (SelectedAnaPart != null) { using (new Horizontal()) { GUI.color = Color.white; GUILayout.Label("Anatomy Part :", GUILayout.ExpandWidth(false)); if (NewAnatomyName != "") { GUI.color = Green; } else { GUI.color = Red; } NewAnatomyName = GUILayout.TextField(NewAnatomyName, 50, GUILayout.ExpandWidth(true)); if (GUILayout.Button("Change", GUILayout.ExpandWidth(false))) { Debug.Log("Anatomy " + SelectedAnaPart.name + " changed to " + NewAnatomyName + "."); DK_SlotsAnatomyElement _DK_SlotsAnatomyElement = SelectedAnaPart.GetComponent <DK_SlotsAnatomyElement>(); _DK_SlotsAnatomyElement.dk_SlotsAnatomyElement.dk_SlotsAnatomyName = NewAnatomyName; SelectedAnaPart.name = NewAnatomyName; // SelectedAnaPart.gameObject.name = NewAnatomyName; Selection.activeObject.name = NewAnatomyName; AssetDatabase.RenameAsset(AssetDatabase.GetAssetPath(Selection.activeObject), NewAnatomyName + ".prefab"); Debug.Log(AssetDatabase.GetAssetPath(Selection.activeObject)); EditorUtility.SetDirty(SelectedAnaPart.gameObject); AssetDatabase.SaveAssets(); } } GUI.color = Color.yellow; if (Helper) { GUILayout.TextField("You can link 2 anatomy parts and configure a slot to remove the linked Anatomy part (ex.: Remove the feet when generating a boots slot).", 256, style, GUILayout.ExpandWidth(true), GUILayout.ExpandWidth(true)); } if (SelectedAnaPart != null) { using (new Horizontal()) { GUI.color = Color.white; GUILayout.Label("Link to :", GUILayout.ExpandWidth(false)); if (SelectedAnaPart.GetComponent <DK_SlotsAnatomyElement>().dk_SlotsAnatomyElement.Place != null) { GUILayout.TextField(SelectedAnaPart.GetComponent <DK_SlotsAnatomyElement>().dk_SlotsAnatomyElement.Place.name, 50, GUILayout.ExpandWidth(true)); } else { GUI.color = Color.white; GUILayout.Label("No Link", GUILayout.ExpandWidth(true)); } if (!ChooseLink) { if (GUILayout.Button("Select", GUILayout.ExpandWidth(false))) { ChooseLink = true; } GUI.color = Red; if (GUILayout.Button("X", GUILayout.ExpandWidth(false))) { SelectedAnaPart.GetComponent <DK_SlotsAnatomyElement>().dk_SlotsAnatomyElement.Place = null; } } else { GUI.color = Color.yellow; GUILayout.Label("Click an Element from the list bellow.", GUILayout.ExpandWidth(true)); GUI.color = Color.white; if (GUILayout.Button("Cancel", GUILayout.ExpandWidth(false))) { ChooseLink = false; } } } } // Gender GUI.color = Color.yellow; if (SelectedAnaPart != null && Helper) { GUILayout.TextField("You can specify a Gender or let it be usable by both (Both is recommended).", 256, style, GUILayout.ExpandWidth(true), GUILayout.ExpandWidth(true)); } if (SelectedAnaPart != null) { using (new Horizontal()) { if (NewPresetGender == "Both") { GUI.color = Green; } else { GUI.color = Color.gray; } if (GUILayout.Button("Both", GUILayout.ExpandWidth(true))) { NewPresetGender = "Both"; DK_Race = SelectedAnaPart.GetComponent("DK_Race") as DK_Race; DK_Race.Gender = NewPresetGender; DK_SlotsAnatomyElement _DK_SlotsAnatomyElement = SelectedAnaPart.GetComponent <DK_SlotsAnatomyElement>(); _DK_SlotsAnatomyElement.dk_SlotsAnatomyElement.ForGender = NewPresetGender; EditorUtility.SetDirty(SelectedAnaPart.gameObject); AssetDatabase.SaveAssets(); } if (NewPresetGender == "Female") { GUI.color = Green; } else { GUI.color = Color.gray; } if (GUILayout.Button("Female", GUILayout.ExpandWidth(true))) { NewPresetGender = "Female"; DK_Race = SelectedAnaPart.GetComponent("DK_Race") as DK_Race; DK_Race.Gender = NewPresetGender; DK_SlotsAnatomyElement _DK_SlotsAnatomyElement = SelectedAnaPart.GetComponent <DK_SlotsAnatomyElement>(); _DK_SlotsAnatomyElement.dk_SlotsAnatomyElement.ForGender = NewPresetGender; EditorUtility.SetDirty(SelectedAnaPart.gameObject); AssetDatabase.SaveAssets(); } if (NewPresetGender == "Male") { GUI.color = Green; } else { GUI.color = Color.gray; } if (GUILayout.Button("Male", GUILayout.ExpandWidth(true))) { NewPresetGender = "Male"; DK_Race = SelectedAnaPart.GetComponent("DK_Race") as DK_Race; DK_Race.Gender = NewPresetGender; DK_SlotsAnatomyElement _DK_SlotsAnatomyElement = SelectedAnaPart.GetComponent <DK_SlotsAnatomyElement>(); _DK_SlotsAnatomyElement.dk_SlotsAnatomyElement.ForGender = NewPresetGender; EditorUtility.SetDirty(SelectedAnaPart.gameObject); AssetDatabase.SaveAssets(); } } } GUI.color = Color.yellow; if (Helper) { GUILayout.TextField("Select the race(s) for the Anatomy Part.", 256, style, GUILayout.ExpandWidth(true), GUILayout.ExpandWidth(true)); } if (Selection.activeGameObject != null) { using (new Horizontal()) { GUI.color = Color.white; GUILayout.Label("For Race :", GUILayout.ExpandWidth(false)); if (NewAnatomyName != "") { GUI.color = Green; } else { GUI.color = Red; } if (GUILayout.Button("Open List", GUILayout.ExpandWidth(true))) { OpenRaceSelectEditor(); } GUILayout.Label("Spawn %", GUILayout.ExpandWidth(false)); if (_SpawnPerct != "" && _SpawnPerct != null) { _SpawnPerct = GUILayout.TextField(_SpawnPerct, 5, GUILayout.Width(30)); _SpawnPerct = Regex.Replace(_SpawnPerct, "[^0-9]", ""); } if (_SpawnPerct == "") { _SpawnPerct = "1"; } if (Convert.ToInt32(_SpawnPerct) > 100) { _SpawnPerct = "100"; } if (GUILayout.Button("Change", GUILayout.ExpandWidth(false))) { DK_Race _DK_Race = Selection.activeGameObject.GetComponent <DK_Race>(); Selection.activeGameObject.GetComponent <DK_SlotsAnatomyData>().SpawnPerct = Convert.ToInt32(_SpawnPerct); EditorUtility.SetDirty(SelectedAnaPart.gameObject); AssetDatabase.SaveAssets(); } } } GUILayout.Space(5); // Head ? GUI.color = Color.yellow; if (Helper) { GUILayout.TextField("The 'Head' part is used by the generator to place all the face elements such as the hair or the beard. Beware You need to assign a single 'Head' Anatomy part to only one slot.", 256, style, GUILayout.ExpandWidth(true), GUILayout.ExpandWidth(true)); } using (new Horizontal()) { GUI.color = Color.white; GUILayout.Label("Is ", GUILayout.ExpandWidth(false)); if (OverlayType == "Is Head Part") { GUI.color = Green; } else { GUI.color = Color.gray; } if (GUILayout.Button("Head", GUILayout.ExpandWidth(true))) { OverlayType = "Is Head Part"; DK_Race = SelectedAnaPart.GetComponent("DK_Race") as DK_Race; DK_Race.OverlayType = OverlayType; EditorUtility.SetDirty(SelectedAnaPart.gameObject); AssetDatabase.SaveAssets(); } GUI.color = Color.white; GUILayout.Label("? Is ", GUILayout.ExpandWidth(false)); if (OverlayType == "Is Head Elem") { GUI.color = Green; } else { GUI.color = Color.gray; } if (GUILayout.Button("Head Elem", GUILayout.ExpandWidth(true))) { OverlayType = "Is Head Elem"; DK_Race = SelectedAnaPart.GetComponent("DK_Race") as DK_Race; DK_Race.OverlayType = OverlayType; EditorUtility.SetDirty(SelectedAnaPart.gameObject); AssetDatabase.SaveAssets(); } GUI.color = Color.white; GUILayout.Label("? Is ", GUILayout.ExpandWidth(false)); if (OverlayType == "Is Torso Part") { GUI.color = Green; } else { GUI.color = Color.gray; } if (GUILayout.Button("Torso", GUILayout.ExpandWidth(true))) { OverlayType = "Is Torso Part"; DK_Race = SelectedAnaPart.GetComponent("DK_Race") as DK_Race; DK_Race.OverlayType = OverlayType; EditorUtility.SetDirty(SelectedAnaPart.gameObject); AssetDatabase.SaveAssets(); } GUI.color = Color.white; GUILayout.Label("?", GUILayout.ExpandWidth(false)); } // Overlay Type GUI.color = Color.yellow; if (Helper) { GUILayout.TextField("The Overlay Type is used by the Generator during the Model's creation. " + "All the 'Naked body parts' must be of the 'Flesh' Type, the Head slot must be of the 'Face' type.", 256, style, GUILayout.ExpandWidth(true), GUILayout.ExpandWidth(true)); } using (new Horizontal()) { GUI.color = Color.white; GUILayout.Label("Overlay Type :", GUILayout.ExpandWidth(false)); if (OverlayType == "Flesh") { GUI.color = Green; } else { GUI.color = Color.gray; } if (GUILayout.Button("Flesh", GUILayout.ExpandWidth(true))) { OverlayType = "Flesh"; DK_Race _DK_Race = SelectedAnaPart.gameObject.GetComponent <DK_Race>(); _DK_Race.OverlayType = "Flesh"; EditorUtility.SetDirty(SelectedAnaPart.gameObject); AssetDatabase.SaveAssets(); } if (OverlayType == "Face") { GUI.color = Green; } else { GUI.color = Color.gray; } if (GUILayout.Button("Face", GUILayout.ExpandWidth(true))) { OverlayType = "Face"; DK_Race _DK_Race = SelectedAnaPart.gameObject.GetComponent <DK_Race>(); _DK_Race.OverlayType = "Face"; EditorUtility.SetDirty(SelectedAnaPart.gameObject); AssetDatabase.SaveAssets(); } if (OverlayType == "Eyes") { GUI.color = Green; } else { GUI.color = Color.gray; } if (GUILayout.Button("Eyes", GUILayout.ExpandWidth(true))) { OverlayType = "Eyes"; DK_Race _DK_Race = SelectedAnaPart.gameObject.GetComponent <DK_Race>(); _DK_Race.OverlayType = "Eyes"; EditorUtility.SetDirty(SelectedAnaPart.gameObject); AssetDatabase.SaveAssets(); } if (OverlayType == "Hair") { GUI.color = Green; } else { GUI.color = Color.gray; } if (GUILayout.Button("Hair", GUILayout.ExpandWidth(true))) { OverlayType = "Hair"; DK_Race _DK_Race = SelectedAnaPart.gameObject.GetComponent <DK_Race>(); _DK_Race.OverlayType = "Hair"; EditorUtility.SetDirty(SelectedAnaPart.gameObject); AssetDatabase.SaveAssets(); } } } // List GUI.color = Color.yellow; if (Helper) { GUILayout.TextField("Select an Anatomy Part from the following list. The 'P' letter is about Prefab, gray means that the Anatomy has no Prefab, cyan means that it is ok. Click on a gray 'P' to create a prefab.", 256, style, GUILayout.ExpandWidth(true), GUILayout.ExpandWidth(true)); } using (new Horizontal()) { GUI.color = Color.white; if (GUILayout.Button("Add New", GUILayout.ExpandWidth(true))) { GameObject NewExpressionObj = (GameObject)Instantiate(Resources.Load("New_AnatomyPart"), Vector3.zero, Quaternion.identity); NewExpressionObj.name = "New Anatomy Part (Rename)"; Selection.activeGameObject = NewExpressionObj; PrefabUtility.CreatePrefab("Assets/DK Editors/DK_UMA_Editor/Prefabs/DK_SlotsAnatomy/" + NewExpressionObj.name + ".prefab", NewExpressionObj.gameObject); if (_SlotsAnatomyLibrary) { DestroyImmediate(_SlotsAnatomyLibrary.gameObject); } SlotsAnatomyLibraryObj = (GameObject)Instantiate(Resources.Load("DK_SlotsAnatomyLibrary"), Vector3.zero, Quaternion.identity); SlotsAnatomyLibraryObj.name = "DK_SlotsAnatomyLibrary"; _SlotsAnatomyLibrary = SlotsAnatomyLibraryObj.GetComponent <DK_SlotsAnatomyLibrary>(); DK_UMA = GameObject.Find("DK_UMA"); if (DK_UMA == null) { var goDK_UMA = new GameObject(); goDK_UMA.name = "DK_UMA"; DK_UMA = GameObject.Find("DK_UMA"); } SlotsAnatomyLibraryObj.transform.parent = DK_UMA.transform; // Find prefabs DirectoryInfo dir = new DirectoryInfo("Assets/DK Editors/DK_UMA_Editor/Prefabs/DK_SlotsAnatomy"); // Assign Prefabs FileInfo[] info = dir.GetFiles("*.prefab"); info.Select(f => f.FullName).ToArray(); // Action // Verify Folders objects GameObject SlotsAnatomy = GameObject.Find("Slots Anatomy"); if (DK_UMA == null) { var goDK_UMA = new GameObject(); goDK_UMA.name = "DK_UMA"; var goSlotsAnatomy = new GameObject(); goSlotsAnatomy.name = "Slots Anatomy"; goSlotsAnatomy.transform.parent = goDK_UMA.transform; } else if (SlotsAnatomy == null) { SlotsAnatomy = new GameObject(); SlotsAnatomy.name = "Slots Anatomy"; SlotsAnatomy.transform.parent = DK_UMA.transform; } SlotsAnatomy = GameObject.Find("Slots Anatomy"); foreach (FileInfo f in info) { // Instantiate the Element Prefab GameObject clone = PrefabUtility.InstantiateAttachedAsset(Resources.LoadAssetAtPath("Assets/DK Editors/DK_UMA_Editor/Prefabs/DK_SlotsAnatomy/" + f.Name, typeof(GameObject))) as GameObject; clone.name = f.Name; if (clone.name.Contains(".prefab")) { clone.name = clone.name.Replace(".prefab", ""); } foreach (Transform child in SlotsAnatomy.transform) { if (clone != null && clone.name == child.name) { GameObject.DestroyImmediate(clone); } } if (clone != null) { clone.transform.parent = SlotsAnatomy.transform; // add the Element to the List DK_SlotsAnatomyElement _SlotsAnatomyElement = clone.GetComponent <DK_SlotsAnatomyElement>(); _SlotsAnatomyElement.dk_SlotsAnatomyElement.dk_SlotsAnatomyName = clone.name; if (_SlotsAnatomyElement.dk_SlotsAnatomyElement.ElemAlreadyIn == false) { for (int i = 0; i < _SlotsAnatomyLibrary.dk_SlotsAnatomyElementList.Length; i++) { if (_SlotsAnatomyLibrary.dk_SlotsAnatomyElementList[i].dk_SlotsAnatomyElement != null && _SlotsAnatomyLibrary.dk_SlotsAnatomyElementList[i].dk_SlotsAnatomyElement.ElemAlreadyIn == true) { } } if (_SlotsAnatomyElement.dk_SlotsAnatomyElement.ElemAlreadyIn == false) { var list = new DK_SlotsAnatomyElement[_SlotsAnatomyLibrary.dk_SlotsAnatomyElementList.Length + 1]; Array.Copy(_SlotsAnatomyLibrary.dk_SlotsAnatomyElementList, list, _SlotsAnatomyLibrary.dk_SlotsAnatomyElementList.Length); GameObject _Prefab = PrefabUtility.GetPrefabParent(_SlotsAnatomyElement.gameObject) as GameObject; DK_SlotsAnatomyElement dk_SlotsAnatomyElement = _Prefab.GetComponent <DK_SlotsAnatomyElement>(); // add to list list[_SlotsAnatomyLibrary.dk_SlotsAnatomyElementList.Length] = dk_SlotsAnatomyElement; _SlotsAnatomyLibrary.dk_SlotsAnatomyElementList = list; // modify dk_SlotsAnatomyName if necessary if (dk_SlotsAnatomyElement.dk_SlotsAnatomyElement.dk_SlotsAnatomyName == "") { dk_SlotsAnatomyElement.dk_SlotsAnatomyElement.dk_SlotsAnatomyName = dk_SlotsAnatomyElement.transform.name; } // Add to Dictonary if (!ElemAlreadyIn) { _SlotsAnatomyLibrary.dk_SlotsAnatomyDictionary.Add(_SlotsAnatomyElement.dk_SlotsAnatomyElement.dk_SlotsAnatomyName, dk_SlotsAnatomyElement.dk_SlotsAnatomyElement); dk_SlotsAnatomyElement.dk_SlotsAnatomyElement.ElemAlreadyIn = false; } } } } } DestroyImmediate(SlotsAnatomy); DestroyImmediate(NewExpressionObj); } // Copy if (GUILayout.Button("Copy Selected", GUILayout.ExpandWidth(true))) { string Path = "Assets/DK Editors/DK_UMA_Editor/Prefabs/DK_SlotsAnatomy/"; SelectedAnaPart.dk_SlotsAnatomyElement.dk_SlotsAnatomyName = SelectedAnaPart.name + " (Copy)"; AssetDatabase.CopyAsset(Path + SelectedAnaPart.gameObject.name + ".prefab", Path + SelectedAnaPart.gameObject.name + " (Copy).prefab"); SelectedAnaPart.dk_SlotsAnatomyElement.dk_SlotsAnatomyName = SelectedAnaPart.dk_SlotsAnatomyElement.dk_SlotsAnatomyName.Replace(" (Copy)", ""); AssetDatabase.Refresh(); if (_SlotsAnatomyLibrary) { DestroyImmediate(_SlotsAnatomyLibrary.gameObject); } SlotsAnatomyLibraryObj = (GameObject)Instantiate(Resources.Load("DK_SlotsAnatomyLibrary"), Vector3.zero, Quaternion.identity); SlotsAnatomyLibraryObj.name = "DK_SlotsAnatomyLibrary"; _SlotsAnatomyLibrary = SlotsAnatomyLibraryObj.GetComponent <DK_SlotsAnatomyLibrary>(); DK_UMA = GameObject.Find("DK_UMA"); if (DK_UMA == null) { var goDK_UMA = new GameObject(); goDK_UMA.name = "DK_UMA"; DK_UMA = GameObject.Find("DK_UMA"); } SlotsAnatomyLibraryObj.transform.parent = DK_UMA.transform; // Find prefabs DirectoryInfo dir = new DirectoryInfo("Assets/DK Editors/DK_UMA_Editor/Prefabs/DK_SlotsAnatomy"); // Assign Prefabs FileInfo[] info = dir.GetFiles("*.prefab"); info.Select(f => f.FullName).ToArray(); // Action // Verify Folders objects GameObject SlotsAnatomy = GameObject.Find("Slots Anatomy"); if (DK_UMA == null) { var goDK_UMA = new GameObject(); goDK_UMA.name = "DK_UMA"; var goSlotsAnatomy = new GameObject(); goSlotsAnatomy.name = "Slots Anatomy"; goSlotsAnatomy.transform.parent = goDK_UMA.transform; } else if (SlotsAnatomy == null) { SlotsAnatomy = new GameObject(); SlotsAnatomy.name = "Slots Anatomy"; SlotsAnatomy.transform.parent = DK_UMA.transform; } SlotsAnatomy = GameObject.Find("Slots Anatomy"); foreach (FileInfo f in info) { // Instantiate the Element Prefab GameObject clone = PrefabUtility.InstantiateAttachedAsset(Resources.LoadAssetAtPath("Assets/DK Editors/DK_UMA_Editor/Prefabs/DK_SlotsAnatomy/" + f.Name, typeof(GameObject))) as GameObject; clone.name = f.Name; if (clone.name.Contains(".prefab")) { clone.name = clone.name.Replace(".prefab", ""); } foreach (Transform child in SlotsAnatomy.transform) { if (clone != null && clone.name == child.name) { GameObject.DestroyImmediate(clone); } } if (clone != null) { clone.transform.parent = SlotsAnatomy.transform; // add the Element to the List DK_SlotsAnatomyElement _SlotsAnatomyElement = clone.GetComponent <DK_SlotsAnatomyElement>(); _SlotsAnatomyElement.dk_SlotsAnatomyElement.dk_SlotsAnatomyName = clone.name; if (_SlotsAnatomyElement.dk_SlotsAnatomyElement.ElemAlreadyIn == false) { for (int i = 0; i < _SlotsAnatomyLibrary.dk_SlotsAnatomyElementList.Length; i++) { if (_SlotsAnatomyLibrary.dk_SlotsAnatomyElementList[i].dk_SlotsAnatomyElement != null && _SlotsAnatomyLibrary.dk_SlotsAnatomyElementList[i].dk_SlotsAnatomyElement.ElemAlreadyIn == true) { } } if (_SlotsAnatomyElement.dk_SlotsAnatomyElement.ElemAlreadyIn == false) { var list = new DK_SlotsAnatomyElement[_SlotsAnatomyLibrary.dk_SlotsAnatomyElementList.Length + 1]; Array.Copy(_SlotsAnatomyLibrary.dk_SlotsAnatomyElementList, list, _SlotsAnatomyLibrary.dk_SlotsAnatomyElementList.Length); GameObject _Prefab = PrefabUtility.GetPrefabParent(_SlotsAnatomyElement.gameObject) as GameObject; DK_SlotsAnatomyElement dk_SlotsAnatomyElement = _Prefab.GetComponent <DK_SlotsAnatomyElement>(); // add to list list[_SlotsAnatomyLibrary.dk_SlotsAnatomyElementList.Length] = dk_SlotsAnatomyElement; _SlotsAnatomyLibrary.dk_SlotsAnatomyElementList = list; // modify dk_SlotsAnatomyName if necessary if (dk_SlotsAnatomyElement.dk_SlotsAnatomyElement.dk_SlotsAnatomyName == "") { dk_SlotsAnatomyElement.dk_SlotsAnatomyElement.dk_SlotsAnatomyName = dk_SlotsAnatomyElement.transform.name; } // Add to Dictonary if (!ElemAlreadyIn) { _SlotsAnatomyLibrary.dk_SlotsAnatomyDictionary.Add(_SlotsAnatomyElement.dk_SlotsAnatomyElement.dk_SlotsAnatomyName, dk_SlotsAnatomyElement.dk_SlotsAnatomyElement); dk_SlotsAnatomyElement.dk_SlotsAnatomyElement.ElemAlreadyIn = false; } } } } } DestroyImmediate(SlotsAnatomy); } // Delete GUI.color = Red; if (GUILayout.Button("Delete Selected", GUILayout.ExpandWidth(true))) { AssetDatabase.DeleteAsset("Assets/DK Editors/DK_UMA_Editor/Prefabs/DK_SlotsAnatomy/" + SelectedAnaPart.gameObject.name + ".prefab"); AssetDatabase.Refresh(); if (_SlotsAnatomyLibrary) { DestroyImmediate(_SlotsAnatomyLibrary.gameObject); } SlotsAnatomyLibraryObj = (GameObject)Instantiate(Resources.Load("DK_SlotsAnatomyLibrary"), Vector3.zero, Quaternion.identity); SlotsAnatomyLibraryObj.name = "DK_SlotsAnatomyLibrary"; _SlotsAnatomyLibrary = SlotsAnatomyLibraryObj.GetComponent <DK_SlotsAnatomyLibrary>(); DK_UMA = GameObject.Find("DK_UMA"); if (DK_UMA == null) { var goDK_UMA = new GameObject(); goDK_UMA.name = "DK_UMA"; DK_UMA = GameObject.Find("DK_UMA"); } SlotsAnatomyLibraryObj.transform.parent = DK_UMA.transform; // Find prefabs DirectoryInfo dir = new DirectoryInfo("Assets/DK Editors/DK_UMA_Editor/Prefabs/DK_SlotsAnatomy"); // Assign Prefabs FileInfo[] info = dir.GetFiles("*.prefab"); info.Select(f => f.FullName).ToArray(); // Action // Verify Folders objects GameObject SlotsAnatomy = GameObject.Find("Slots Anatomy"); if (DK_UMA == null) { var goDK_UMA = new GameObject(); goDK_UMA.name = "DK_UMA"; var goSlotsAnatomy = new GameObject(); goSlotsAnatomy.name = "Slots Anatomy"; goSlotsAnatomy.transform.parent = goDK_UMA.transform; } else if (SlotsAnatomy == null) { SlotsAnatomy = new GameObject(); SlotsAnatomy.name = "Slots Anatomy"; SlotsAnatomy.transform.parent = DK_UMA.transform; } SlotsAnatomy = GameObject.Find("Slots Anatomy"); foreach (FileInfo f in info) { // Instantiate the Element Prefab GameObject clone = PrefabUtility.InstantiateAttachedAsset(Resources.LoadAssetAtPath("Assets/DK Editors/DK_UMA_Editor/Prefabs/DK_SlotsAnatomy/" + f.Name, typeof(GameObject))) as GameObject; clone.name = f.Name; if (clone.name.Contains(".prefab")) { clone.name = clone.name.Replace(".prefab", ""); } foreach (Transform child in SlotsAnatomy.transform) { if (clone != null && clone.name == child.name) { GameObject.DestroyImmediate(clone); } } if (clone != null) { clone.transform.parent = SlotsAnatomy.transform; // add the Element to the List DK_SlotsAnatomyElement _SlotsAnatomyElement = clone.GetComponent <DK_SlotsAnatomyElement>(); _SlotsAnatomyElement.dk_SlotsAnatomyElement.dk_SlotsAnatomyName = clone.name; if (_SlotsAnatomyElement.dk_SlotsAnatomyElement.ElemAlreadyIn == false) { for (int i = 0; i < _SlotsAnatomyLibrary.dk_SlotsAnatomyElementList.Length; i++) { if (_SlotsAnatomyLibrary.dk_SlotsAnatomyElementList[i].dk_SlotsAnatomyElement != null && _SlotsAnatomyLibrary.dk_SlotsAnatomyElementList[i].dk_SlotsAnatomyElement.ElemAlreadyIn == true) { } } if (_SlotsAnatomyElement.dk_SlotsAnatomyElement.ElemAlreadyIn == false) { var list = new DK_SlotsAnatomyElement[_SlotsAnatomyLibrary.dk_SlotsAnatomyElementList.Length + 1]; Array.Copy(_SlotsAnatomyLibrary.dk_SlotsAnatomyElementList, list, _SlotsAnatomyLibrary.dk_SlotsAnatomyElementList.Length); GameObject _Prefab = PrefabUtility.GetPrefabParent(_SlotsAnatomyElement.gameObject) as GameObject; DK_SlotsAnatomyElement dk_SlotsAnatomyElement = _Prefab.GetComponent <DK_SlotsAnatomyElement>(); // add to list list[_SlotsAnatomyLibrary.dk_SlotsAnatomyElementList.Length] = dk_SlotsAnatomyElement; _SlotsAnatomyLibrary.dk_SlotsAnatomyElementList = list; // modify dk_SlotsAnatomyName if necessary if (dk_SlotsAnatomyElement.dk_SlotsAnatomyElement.dk_SlotsAnatomyName == "") { dk_SlotsAnatomyElement.dk_SlotsAnatomyElement.dk_SlotsAnatomyName = dk_SlotsAnatomyElement.transform.name; } // Add to Dictonary if (!ElemAlreadyIn) { _SlotsAnatomyLibrary.dk_SlotsAnatomyDictionary.Add(_SlotsAnatomyElement.dk_SlotsAnatomyElement.dk_SlotsAnatomyName, dk_SlotsAnatomyElement.dk_SlotsAnatomyElement); dk_SlotsAnatomyElement.dk_SlotsAnatomyElement.ElemAlreadyIn = false; } } } } } DestroyImmediate(SlotsAnatomy); } } #region Search using (new Horizontal()) { GUI.color = Color.white; GUILayout.Label("Search for :", GUILayout.ExpandWidth(false)); SearchString = GUILayout.TextField(SearchString, 100, GUILayout.ExpandWidth(true)); } #endregion Search GUILayout.Space(5); using (new Horizontal()) { GUI.color = Color.cyan; GUILayout.Label("Anatomy Part", "toolbarbutton", GUILayout.Width(112)); GUILayout.Label("Race", "toolbarbutton", GUILayout.Width(50)); GUILayout.Label("Gender", "toolbarbutton", GUILayout.Width(50)); GUILayout.Label("Type", "toolbarbutton", GUILayout.Width(80)); GUILayout.Label("", "toolbarbutton", GUILayout.ExpandWidth(true)); } if (_SlotsAnatomyLibrary != null) { using (new ScrollView(ref scroll)) { for (int i = 0; i < _SlotsAnatomyLibrary.dk_SlotsAnatomyElementList.Length; i++) { DK_SlotsAnatomyElement dk_SlotsAnatomyElement = _SlotsAnatomyLibrary.dk_SlotsAnatomyElementList[i]; if (_SlotsAnatomyLibrary.dk_SlotsAnatomyElementList[i] != null) { _SlotsAnatomyLibrary.dk_SlotsAnatomyElementList[i].dk_SlotsAnatomyElement.ElemAlreadyIn = false; _SlotsAnatomyLibrary.dk_SlotsAnatomyElementList[i].dk_SlotsAnatomyElement.Selected = false; if ((SearchString == "" || _SlotsAnatomyLibrary.dk_SlotsAnatomyElementList[i].name.ToLower().Contains(SearchString.ToLower())) && dk_SlotsAnatomyElement != null) { using (new Horizontal(GUILayout.Width(80))) { // Prefab Verification myPath = PrefabUtility.GetPrefabObject(dk_SlotsAnatomyElement.gameObject).ToString(); if (myPath == "null") { GUI.color = Color.gray; } else { GUI.color = Color.cyan; } if (GUILayout.Button("P", "toolbarbutton", GUILayout.ExpandWidth(false))) { // Create Prefab if (myPath == "null") { PrefabUtility.CreatePrefab("Assets/DK Editors/DK_UMA_Editor/Prefabs/DK_SlotsAnatomy/" + dk_SlotsAnatomyElement.name + ".prefab", dk_SlotsAnatomyElement.gameObject); GameObject clone = PrefabUtility.InstantiateAttachedAsset(Resources.LoadAssetAtPath("Assets/DK Editors/DK_UMA_Editor/Prefabs/DK_SlotsAnatomy/" + dk_SlotsAnatomyElement.name + ".prefab", typeof(GameObject))) as GameObject; clone.name = dk_SlotsAnatomyElement.name; clone.transform.parent = dk_SlotsAnatomyElement.transform.parent; DestroyImmediate(dk_SlotsAnatomyElement.gameObject); } } // Element if (SelectedAnaPart == _SlotsAnatomyLibrary.dk_SlotsAnatomyElementList[i]) { GUI.color = Color.yellow; } else { GUI.color = Color.white; } if (ChooseLink && GUILayout.Button(_SlotsAnatomyLibrary.dk_SlotsAnatomyElementList[i].dk_SlotsAnatomyElement.dk_SlotsAnatomyName, "toolbarbutton", GUILayout.Width(95))) { SelectedAnaPart.dk_SlotsAnatomyElement.Place = _SlotsAnatomyLibrary.dk_SlotsAnatomyElementList[i]; EditorUtility.SetDirty(SelectedAnaPart.gameObject); AssetDatabase.SaveAssets(); ChooseLink = false; } if (!ChooseLink && GUILayout.Button(_SlotsAnatomyLibrary.dk_SlotsAnatomyElementList[i].dk_SlotsAnatomyElement.dk_SlotsAnatomyName, "toolbarbutton", GUILayout.Width(95))) { SelectedAnaPart = _SlotsAnatomyLibrary.dk_SlotsAnatomyElementList[i]; Selection.activeGameObject = SelectedAnaPart.gameObject; NewAnatomyName = _SlotsAnatomyLibrary.dk_SlotsAnatomyElementList[i].dk_SlotsAnatomyElement.dk_SlotsAnatomyName; NewPresetGender = _SlotsAnatomyLibrary.dk_SlotsAnatomyElementList[i].dk_SlotsAnatomyElement.ForGender; DK_Race = _SlotsAnatomyLibrary.dk_SlotsAnatomyElementList[i].GetComponent("DK_Race") as DK_Race; OverlayType = DK_Race.OverlayType; _SpawnPerct = Selection.activeGameObject.GetComponent <DK_SlotsAnatomyData>().SpawnPerct.ToString(); if (DK_Race.Place != null) { SelectedPlace = DK_Race.Place.ToString(); } else { SelectedPlace = ""; } } // Race if (_SlotsAnatomyLibrary.dk_SlotsAnatomyElementList[i].gameObject.GetComponent <DK_Race>() as DK_Race == null) { _SlotsAnatomyLibrary.dk_SlotsAnatomyElementList[i].gameObject.AddComponent <DK_Race>(); } DK_Race = _SlotsAnatomyLibrary.dk_SlotsAnatomyElementList[i].GetComponent("DK_Race") as DK_Race; if (DK_Race.Race.Count == 0) { GUI.color = Red; } if (DK_Race.Race.Count == 0 && GUILayout.Button("No Race", "toolbarbutton", GUILayout.Width(50))) { } GUI.color = Green; if (DK_Race.Race.Count == 1 && GUILayout.Button(DK_Race.Race[0], "toolbarbutton", GUILayout.Width(50))) { } if (DK_Race.Race.Count > 1 && GUILayout.Button("Multi", "toolbarbutton", GUILayout.Width(50))) { } // Gender if (DK_Race.Gender == "") { GUI.color = Red; } if (DK_Race.Gender == "") { GUILayout.Label("N", "Button"); } GUI.color = Green; if (DK_Race.Gender != "" && DK_Race.Gender == "Female") { GUILayout.Label("Female", "toolbarbutton", GUILayout.Width(50)); } if (DK_Race.Gender != "" && DK_Race.Gender == "Male") { GUILayout.Label("Male", "toolbarbutton", GUILayout.Width(50)); } if (DK_Race.Gender != "" && DK_Race.Gender == "Both") { GUILayout.Label("Both", "toolbarbutton", GUILayout.Width(50)); } // OverlayType if (_SlotsAnatomyLibrary.dk_SlotsAnatomyElementList[i].gameObject.GetComponent <DK_Race>() as DK_Race == null) { _SlotsAnatomyLibrary.dk_SlotsAnatomyElementList[i].gameObject.AddComponent <DK_Race>(); } DK_Race = _SlotsAnatomyLibrary.dk_SlotsAnatomyElementList[i].GetComponent("DK_Race") as DK_Race; if (DK_Race.OverlayType == "") { GUI.color = Color.gray; } if (DK_Race.OverlayType == "" && GUILayout.Button("No Type", "toolbarbutton", GUILayout.Width(80))) { } GUI.color = Green; if (DK_Race.OverlayType != "" && GUILayout.Button(DK_Race.OverlayType, "toolbarbutton", GUILayout.Width(80))) { } } } } } } } }