Advertisement
PedroArthurr

using UnityEditor; using UnityEngine; public class WeaponCreationWindow : EditorWindow { public

May 7th, 2022
1,143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.20 KB | None | 0 0
  1. using UnityEditor;
  2. using UnityEngine;
  3.  
  4. public class WeaponCreationWindow : EditorWindow
  5. {
  6.     public WeaponSettings settings;
  7.     private SerializedObject _serializedObject;
  8.  
  9.     [MenuItem("Generic Survival Shooter Game/Weapons/Creation")]
  10.  
  11.     public static void ShowWindow() => GetWindowWithRect(typeof(WeaponCreationWindow),
  12.         new Rect(0, 0, 500, 350), true, "Weapon Creation Window");
  13.  
  14.     private void OnEnable() => _serializedObject = new SerializedObject(this);
  15.  
  16.     private void OnDisable() => _serializedObject.Dispose();
  17.  
  18.     private void OnGUI()
  19.     {
  20.         EditorGUILayout.BeginVertical();
  21.         EditorGUILayout.BeginHorizontal();
  22.         GUILayout.Space(20);
  23.  
  24.         SerializedProperty sp = _serializedObject.FindProperty("settings");
  25.         EditorGUILayout.PropertyField(sp);
  26.         _serializedObject.ApplyModifiedProperties();
  27.  
  28.         GUILayout.Space(10);
  29.         EditorGUILayout.EndHorizontal();
  30.         EditorGUILayout.EndVertical();
  31.  
  32.         GUILayout.Space(30);
  33.  
  34.         if (GUILayout.Button("Create Weapon"))
  35.         {
  36.             WeaponCreator.CreateWeaponObject(settings);
  37.  
  38.             Debug.Log(settings.weaponName + " Was created");
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement