public static void OpenWindow() { NPCMakerWindow window = (NPCMakerWindow)GetWindow(typeof(NPCMakerWindow)); window.minSize = window.maxSize = new Vector2(350, 175); window.Show(); }
public void DrawSettings(NPCData charData) { //Mientras sigamos retocando el codigo es preferible no estar haciendo el tamaño dinamico xq sino vamos a estar cambiando //todo el tiempo el calculo y es tedioso. //minSize = maxSize = new Vector2(515, (200 + (26 * (charData.npcClassType.intVariables.Count + charData.npcClassType.floatVariables.Count)))); Undo.RecordObject(charData, "CharData"); EditorGUILayout.Space(); EditorGUILayout.BeginVertical(EditorStyles.helpBox); EditorGUILayout.BeginHorizontal(); GUILayout.Label(new GUIContent("Name", "Enter the Name of the character"), _skin.GetStyle("Body"), GUILayout.Width(200)); charData.characterName = EditorGUILayout.TextField(charData.characterName); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); GUILayout.Label(new GUIContent("Prefab", "Enter the prefab for the character"), _skin.GetStyle("Body"), GUILayout.Width(200)); charData.prefab = (GameObject)EditorGUILayout.ObjectField(charData.prefab, typeof(GameObject), false); EditorGUILayout.EndHorizontal(); List <string> propertyNames = new List <string>(); foreach (var item in charData.npcClassType.intVariables) { propertyNames.Add(item.Key); } EditorGUILayout.Space(); EditorGUILayout.LabelField("Propertys", _skin.GetStyle("Title")); EditorGUILayout.Space(); for (int i = 0; i < propertyNames.Count; i++) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(propertyNames[i], _skin.GetStyle("Body"), GUILayout.Width(200)); charData.npcClassType.intVariables[propertyNames[i]] = EditorGUILayout.IntField(charData.npcClassType.intVariables[propertyNames[i]]); EditorGUILayout.EndVertical(); EditorGUILayout.Space(); } propertyNames.Clear(); foreach (var item in charData.npcClassType.floatVariables) { propertyNames.Add(item.Key); } for (int i = 0; i < propertyNames.Count; i++) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(propertyNames[i], _skin.GetStyle("Body"), GUILayout.Width(200)); charData.npcClassType.floatVariables[propertyNames[i]] = EditorGUILayout.FloatField(charData.npcClassType.floatVariables[propertyNames[i]]); EditorGUILayout.EndVertical(); EditorGUILayout.Space(); } EditorGUILayout.Space(); EditorGUILayout.LabelField("Components", _skin.GetStyle("Title")); EditorGUILayout.Space(); showComponents = EditorGUILayout.Foldout(showComponents, showComponents ? "Hide Components" : "Show Components"); if (showComponents) { ShowComponents(); } EditorGUILayout.Space(); string[] compoenentsStrings = new string[availableComponents.Count + 1]; compoenentsStrings[0] = "none"; for (int i = 0; i < availableComponents.Count; i++) { compoenentsStrings[i + 1] = availableComponents[i].GetType().ToString().Split('.')[1]; } EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Available Components", _skin.GetStyle("Body"), GUILayout.Width(200)); componentSelected = EditorGUILayout.Popup(componentSelected, compoenentsStrings); EditorGUILayout.EndHorizontal(); if (componentSelected != 0 && GUILayout.Button("Add component")) { componentsSelected.Add(availableComponents[componentSelected - 1]); availableComponents.RemoveAt(componentSelected - 1); componentSelected = 0; } EditorGUILayout.Space(); EditorGUILayout.EndVertical(); if (charData.characterName == null || charData.characterName.Length < 1) { EditorGUILayout.HelpBox("Name cannot be empty", MessageType.Warning); } else if (charData.prefab == null) { EditorGUILayout.HelpBox("Prefab cannot be empty", MessageType.Warning); } else if (GUILayout.Button("Save and Exit")) { SaveData(); charData.characterName = ""; charData.prefab = null; NPCMakerWindow.OpenWindow(); this.Close(); } }