public static bool UnityObjectField <T>(ref T curValue, string label, params GUILayoutOption[] guiLayout) where T : Object { BeginIndentSpaces(); T newValue = (T)EditorGUILayout.ObjectField(label, curValue, typeof(T), false, guiLayout); if (typeof(T).IsSubclassOf(typeof(ScriptableObject))) { if (GUILayout.Button("✚", GUILayout.MaxWidth(ARRAY_CONTROL_WIDTH))) { ObjectCreatorWindow.InitialiseWindow(typeof(T)); } } EndIndentSpaces(); FinishedElementDrawingCall(); if (newValue != curValue) { ShouldBeDirty(); curValue = newValue; return(true); } return(false); }
public static void InitialiseWindow(Type baseType) { if (!baseType.IsSubclassOf(ScriptableObjectBaseType) && baseType != ScriptableObjectBaseType) { throw new ArgumentException($"Cannot initiate Object Creation window with a type not inheriting from {nameof(ScriptableObject)}. (Given: {baseType.Name})"); } ObjectCreatorWindow creatorWindow = GetWindow <ObjectCreatorWindow>("Object Creation", true, typeof(EditorWindow).Assembly.GetType("UnityEditor.InspectorWindow")); creatorWindow.titleContent.image = EditorGUIUtility.IconContent("Toolbar Plus").image; creatorWindow.Initialise(baseType); creatorWindow.Show(); }