public static T Create <T>(string name) where T : ScriptableObject { var path = SelectionUtils.GetSelectedPath(); var item = Create <T>(path, name); Selection.activeObject = item; return(item); }
public static ScriptableObject Create(Type type, string name) { if (!type.IsSubclassOf(typeof(ScriptableObject))) { return(null); } var path = SelectionUtils.GetSelectedPath(); var item = Create(type, path, name); AssetDatabase.Refresh(); Selection.activeObject = item; return(item); }
private void OnGUI() { _filterLine = EditorGUILayout.TextField("Search", _filterLine); if (!_filterLine.Equals(_prevFilterLine)) { Filter(); _prevFilterLine = _filterLine; } var noTypes = _filteredTypes.Count == 0; if (noTypes) { GUI.enabled = false; // EditorGUILayout.Popup("Type", 0, _typesNames.ToArray()); } else { GUI.enabled = true; } _selectedTypeIndex = EditorGUILayout.Popup("Type", _selectedTypeIndex, Enumerable.ToArray(_typesNames)); _selectedTypeIndex = _selectedTypeIndex < _filteredTypes.Count ? _selectedTypeIndex : 0; _selectedType = _selectedTypeIndex > -1 && _selectedTypeIndex < _filteredTypes.Count ? _filteredTypes[_selectedTypeIndex] : _defaultType; CheckName(); _newSOName = EditorGUILayout.TextField("New asset name", _newSOName); GUILayout.Label($"Current path: {Path.Combine(SelectionUtils.GetSelectedPath(), _newSOName)}.asset"); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Create")) { ScriptableObjectsEditorUtils.Create(_selectedType, _newSOName); Close(); } if (GUILayout.Button("Cancel")) { Close(); } EditorGUILayout.EndHorizontal(); GUI.enabled = true; }