Advertisement
jamieTheCoder

ConnectedAssetScriptableObjectWindow

Jan 26th, 2023
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.11 KB | None | 0 0
  1. using UnityEngine;
  2. using UnityEditor;
  3.  
  4. public class ConnectedAssetScriptableObjectWindow : ExtendedEditorWindow
  5. {
  6. #if UNITY_EDITOR
  7.     //most of this came from https://www.youtube.com/watch?v=c_3DXBrH-Is
  8.     [MenuItem("Window/Example")]
  9.     public static void ShowWindow(ConnectedAssetScriptableObject connectedAssetScriptableObject) {
  10.         ConnectedAssetScriptableObjectWindow window = GetWindow<ConnectedAssetScriptableObjectWindow>("Connected Asset Editor");
  11.         window.serializedObject = new SerializedObject(connectedAssetScriptableObject);
  12.  
  13.     }
  14.  
  15.     private void OnGUI() {
  16.         currentProperty = serializedObject.FindProperty("connectedAssetWithInputList");
  17.         EditorGUILayout.BeginHorizontal();
  18.         EditorGUILayout.BeginVertical("box",GUILayout.MaxWidth(150),GUILayout.ExpandHeight(true));
  19.         DrawSidebar(currentProperty);
  20.         EditorGUILayout.EndVertical();
  21.         EditorGUILayout.BeginVertical("box",GUILayout.ExpandHeight(true));
  22.         if(selectedProperty != null) {
  23.             DrawSelectedPropertiesPanel();
  24.         } else {
  25.             EditorGUILayout.LabelField("Select an item from the list");
  26.         }
  27.         EditorGUILayout.EndHorizontal();
  28.         EditorGUILayout.EndVertical();
  29.         EditorGUILayout.BeginHorizontal();
  30.         if (GUILayout.Button("Add New Item")) {
  31.             currentProperty.arraySize++;
  32.         }
  33.         if (GUILayout.Button("Remove Item")) {
  34.             currentProperty.arraySize--;
  35.         }
  36.         EditorGUILayout.EndHorizontal();
  37.         if (GUILayout.Button("Create Connected Assets")) {
  38.            
  39.         }
  40.  
  41.         void DrawSelectedPropertiesPanel() {
  42.             currentProperty = selectedProperty;
  43.  
  44.             EditorGUILayout.BeginVertical();
  45.             DrawField("BasePath", true);
  46.             EditorGUILayout.BeginHorizontal();
  47.             DrawField("NameExtension", true);
  48.             DrawField("Path", true);
  49.             EditorGUILayout.EndHorizontal();
  50.             EditorGUILayout.Space(20);
  51.             DrawField("connectedAsset", true);
  52.             EditorGUILayout.EndVertical();
  53.         }
  54.     }
  55. #endif
  56. }
  57.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement