public override void BaseGUI() { BeginBox(); GUILayout.BeginHorizontal(); GUILayout.Label(ContentProperties.ID, GUILayout.Width(100)); instance.SetID(EditorGUILayout.TextField(instance.GetID())); GUI.SetNextControlName(""); if (GenerateIDButton()) { string id = System.Guid.NewGuid().ToString().ToUpper(); id = id.Replace("-", ""); instance.SetID(id); GUI.FocusControl(""); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label(ContentProperties.DisplayName, GUILayout.Width(100)); instance.SetDisplayName(EditorGUILayout.TextField(instance.GetDisplayName())); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label(ContentProperties.Description, GUILayout.Width(100)); instance.SetDescription(EditorGUILayout.TextArea(instance.GetDescription())); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label(ContentProperties.Group, GUILayout.Width(100)); instance.SetGroup(EditorGUILayout.TextField(instance.GetGroup())); if (inventory != null) { GUI.SetNextControlName(ContentProperties.Group.text); if (ListButton()) { InventoryGroup[] groups = inventory.GetGroups().ToArray(); if (groups != null && groups.Length > 0) { GenericMenu popup = new GenericMenu(); for (int i = 0; i < groups.Length; i++) { popup.AddItem(new GUIContent(groups[i].GetName()), false, (x) => { instance.SetGroup(x.ToString()); }, groups[i].GetName()); } popup.ShowAsContext(); } GUI.FocusControl(ContentProperties.Group.text); } } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label(ContentProperties.Image, GUILayout.Width(100)); instance.SetImage((Sprite)EditorGUILayout.ObjectField(instance.GetImage(), typeof(Sprite), false)); GUILayout.EndHorizontal(); GUILayout.Space(3); IncreaseIndentLevel(); BeginSubBox(); dropPropertiesFoldout = EditorGUILayout.Foldout(dropPropertiesFoldout, ContentProperties.DropProperties, true); if (dropPropertiesFoldout) { DropProperties dropProperties = instance.GetDropProperties(); dropProperties.SetDropObject(ObjectField <GameObject>(ContentProperties.DropObject, dropProperties.GetDropObject(), false)); dropProperties.SetForce(EditorGUILayout.FloatField(ContentProperties.Force, dropProperties.GetForce())); dropProperties.SetSoundEffect(ObjectField <AudioClip>(ContentProperties.SoundEffect, dropProperties.GetSoundEffect(), false)); dropProperties.SetDistance(EditorGUILayout.FloatField(ContentProperties.Distance, dropProperties.GetDistance())); dropProperties.SetRotation(EditorGUILayout.Vector3Field(ContentProperties.Rotation, dropProperties.GetRotation())); instance.SetDropProperties(dropProperties); } EndSubBox(); DecreaseIndentLevel(); EndBox(); }
public override void BaseGUI() { BeginBox(); if (instance.GetWeapon() == null) { instance.SetWeapon((WeaponID)EditorGUILayout.ObjectField("Weapon ID", instance.GetWeapon(), typeof(WeaponID), false)); UEditorHelpBoxMessages.Error("Current weapon object not active in Unreal FPS system.", "For create Weapon ID asset press right mouse button on Project window and select Create > Unreal FPS > Weapon > Weapon ID."); } else { string weaponName = instance.GetWeapon() != null?instance.GetWeapon().name : "Weapon"; GUILayout.BeginHorizontal(); GUILayout.Space(3); GUILayout.Label(weaponName, GUILayout.Width(70)); GUILayout.Space(EditorGUIUtility.labelWidth - 90); instance.SetWeapon((WeaponID)EditorGUILayout.ObjectField(instance.GetWeapon(), typeof(WeaponID), false)); if (GUILayout.Button("", GUI.skin.GetStyle("OL Minus"), GUILayout.Width(20))) { instance.SetWeapon(null); } GUILayout.Space(3); GUILayout.EndHorizontal(); GUILayout.Space(10); GUILayout.Label(weaponName + " Properties", UEditorStyles.SectionHeaderLabel); GUILayout.Space(5); BeginSubBox(); GUILayout.Space(3); IncreaseIndentLevel(); string weaponDisplayFoldoutName = weaponDisplayFoldout ? "Hide " + weaponName + " Properties" : "Edit " + weaponName + " Properties"; weaponDisplayFoldout = EditorGUILayout.Foldout(weaponDisplayFoldout, weaponDisplayFoldoutName, true); if (weaponDisplayFoldout && instance.GetWeapon() != null) { GUILayout.BeginHorizontal(); GUILayout.Space(17); GUILayout.Label(ContentProperties.ID, GUILayout.Width(100)); instance.GetWeapon().SetID(EditorGUILayout.TextField(instance.GetWeapon().GetID())); GUI.SetNextControlName(""); if (GenerateIDButton()) { string id = System.Guid.NewGuid().ToString().ToUpper(); id = id.Replace("-", ""); instance.GetWeapon().SetID(id); GUI.FocusControl(""); } GUILayout.EndHorizontal(); instance.GetWeapon().SetDisplayName(EditorGUILayout.TextField(ContentProperties.DisplayName, instance.GetWeapon().GetDisplayName())); GUILayout.BeginHorizontal(); GUILayout.Label(ContentProperties.Description, GUILayout.Width(100)); instance.GetWeapon().SetDescription(EditorGUILayout.TextArea(instance.GetWeapon().GetDescription())); GUILayout.EndHorizontal(); if (inventory == null) { instance.GetWeapon().SetGroup(EditorGUILayout.TextField(ContentProperties.Group, instance.GetWeapon().GetGroup())); } else { GUILayout.BeginHorizontal(); instance.GetWeapon().SetGroup(EditorGUILayout.TextField(ContentProperties.Group, instance.GetWeapon().GetGroup())); GUI.SetNextControlName(ContentProperties.Group.text); if (ListButton()) { InventoryGroup[] groups = inventory.GetGroups().ToArray(); if (groups != null && groups.Length > 0) { GenericMenu popup = new GenericMenu(); for (int i = 0; i < groups.Length; i++) { popup.AddItem(new GUIContent(groups[i].GetName()), false, (x) => { instance.GetWeapon().SetGroup(x.ToString()); }, groups[i].GetName()); } popup.ShowAsContext(); } GUI.FocusControl(ContentProperties.Group.text); } GUILayout.EndHorizontal(); } instance.GetWeapon().SetImage((Sprite)EditorGUILayout.ObjectField(ContentProperties.Image, instance.GetWeapon().GetImage(), typeof(Sprite), false)); IncreaseIndentLevel(); BeginSubBox(); dropPropertiesFoldout = EditorGUILayout.Foldout(dropPropertiesFoldout, ContentProperties.DropProperties, true); if (dropPropertiesFoldout) { DropProperties dropProperties = instance.GetWeapon().GetDropProperties(); dropProperties.SetDropObject(ObjectField <GameObject>(ContentProperties.DropObject, dropProperties.GetDropObject(), false)); dropProperties.SetForce(EditorGUILayout.FloatField(ContentProperties.Force, dropProperties.GetForce())); dropProperties.SetSoundEffect(ObjectField <AudioClip>(ContentProperties.SoundEffect, dropProperties.GetSoundEffect(), false)); dropProperties.SetDistance(EditorGUILayout.FloatField(ContentProperties.Distance, dropProperties.GetDistance())); dropProperties.SetRotation(EditorGUILayout.Vector3Field(ContentProperties.Rotation, dropProperties.GetRotation())); instance.GetWeapon().SetDropProperties(dropProperties); } EndSubBox(); DecreaseIndentLevel(); } GUILayout.Space(3); EndSubBox(); DecreaseIndentLevel(); } EndBox(); }
private static void NewWeaponGUI() { GUILayout.BeginVertical(EditorStyles.helpBox); GUILayout.Space(5); GUILayout.Label(ContentProperties.BaseOptions, UEditorStyles.SectionHeaderLabel); GUILayout.Space(7); GUILayout.BeginHorizontal(); GUILayout.Label(ContentProperties.ID, GUILayout.Width(100)); weaponID.SetID(EditorGUILayout.TextField(weaponID.GetID())); GUI.SetNextControlName(""); if (UEditor.GenerateIDButton()) { string id = System.Guid.NewGuid().ToString().ToUpper(); id = id.Replace("-", ""); weaponID.SetID(id); GUI.FocusControl(""); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label(ContentProperties.DisplayName, GUILayout.Width(100)); weaponID.SetDisplayName(EditorGUILayout.TextField(weaponID.GetDisplayName())); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label(ContentProperties.Description, GUILayout.Width(100)); weaponID.SetDescription(EditorGUILayout.TextArea(weaponID.GetDescription())); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label(ContentProperties.Group, GUILayout.Width(100)); weaponID.SetGroup(EditorGUILayout.TextField(weaponID.GetGroup())); if (inventory != null) { GUI.SetNextControlName(ContentProperties.Group.text); if (UEditor.ListButton()) { InventoryGroup[] groups = inventory.GetGroups().ToArray(); if (groups != null && groups.Length > 0) { GenericMenu popup = new GenericMenu(); for (int i = 0; i < groups.Length; i++) { popup.AddItem(new GUIContent(groups[i].GetName()), false, (x) => { weaponID.SetGroup(x.ToString()); }, groups[i].GetName()); } popup.ShowAsContext(); } GUI.FocusControl(ContentProperties.Group.text); } } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label(ContentProperties.Image, GUILayout.Width(100)); weaponID.SetImage((Sprite)EditorGUILayout.ObjectField(weaponID.GetImage(), typeof(Sprite), false)); GUILayout.EndHorizontal(); GUILayout.Space(10); GUILayout.Label(ContentProperties.DropProperties, UEditorStyles.SectionHeaderLabel); GUILayout.Space(7); DropProperties dropProperties = weaponID.GetDropProperties(); dropProperties.SetDropObject(UEditor.ObjectField <GameObject>(ContentProperties.DropObject, dropProperties.GetDropObject(), false)); dropProperties.SetForce(EditorGUILayout.FloatField(ContentProperties.Force, dropProperties.GetForce())); dropProperties.SetSoundEffect(UEditor.ObjectField <AudioClip>(ContentProperties.SoundEffect, dropProperties.GetSoundEffect(), false)); dropProperties.SetDistance(EditorGUILayout.FloatField(ContentProperties.Distance, dropProperties.GetDistance())); GUILayout.BeginHorizontal(); GUILayout.Label(ContentProperties.Rotation, GUILayout.Width(145)); dropProperties.SetRotation(EditorGUILayout.Vector3Field(GUIContent.none, dropProperties.GetRotation())); GUILayout.EndHorizontal(); weaponID.SetDropProperties(dropProperties); GUILayout.Space(5); UEditor.HorizontalLine(); GUILayout.Space(5); if (UEditor.Button("Create", "Right", GUILayout.Width(70))) { string path = EditorUtility.SaveFilePanelInProject("Create new Property", weaponID.GetDisplayName(), "", ""); if (!string.IsNullOrEmpty(path)) { string name = System.IO.Path.GetFileName(path); path = path.Replace(name, ""); ScriptableObjectUtility.CreateAsset(weaponID, path, name); OnEnable(); } } GUILayout.Space(5); GUILayout.EndVertical(); }