Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEditor;
- using UnityEngine;
- public class WeaponCreationWindow : EditorWindow
- {
- public WeaponSettings settings;
- private SerializedObject _serializedObject;
- [MenuItem("Generic Survival Shooter Game/Weapons/Creation")]
- public static void ShowWindow() => GetWindowWithRect(typeof(WeaponCreationWindow),
- new Rect(0, 0, 500, 350), true, "Weapon Creation Window");
- private void OnEnable() => _serializedObject = new SerializedObject(this);
- private void OnDisable() => _serializedObject.Dispose();
- private void OnGUI()
- {
- EditorGUILayout.BeginVertical();
- EditorGUILayout.BeginHorizontal();
- GUILayout.Space(20);
- SerializedProperty sp = _serializedObject.FindProperty("settings");
- EditorGUILayout.PropertyField(sp);
- _serializedObject.ApplyModifiedProperties();
- GUILayout.Space(10);
- EditorGUILayout.EndHorizontal();
- EditorGUILayout.EndVertical();
- GUILayout.Space(30);
- if (GUILayout.Button("Create Weapon"))
- {
- WeaponCreator.CreateWeaponObject(settings);
- Debug.Log(settings.weaponName + " Was created");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement