Мои Уведомления
Привет, !
Мой Аккаунт Мои Финансы Мои Подписки Мои Настройки Выход
Руководство API скрипты

Объявление

public void OnGUI(string searchContext);

Параметры

searchContext Контекст поиска для окна настроек. Используется для отображения или скрытия соответствующих свойств.

Описание

Используйте эту функцию для рисования пользовательского интерфейса на основе IMGUI. Это предполагает, что вы не добавили никаких дочерних элементов в rootElement, переданный функции OnActivate.

using UnityEditor; using UnityEngine; using UnityEngine.UIElements; class SimpleIMGUISettingsProvider : SettingsProvider { SerializedObject m_Settings; const string k_MyCustomSettingsPath = "Assets/Editor/MyCustomSettings.asset"; public SimpleIMGUISettingsProvider(string path, SettingsScope scope = SettingsScope.User) : base(path, scope) {} public override void OnActivate(string searchContext, VisualElement rootElement) { // Called when the user clicks on the MyCustom element in the Settings window. m_Settings = new SerializedObject(AssetDatabase.LoadAssetAtPath(k_MyCustomSettingsPath)); } public override void OnDeactivate() { // User selected another setting or closed the Settings window. m_Settings = null; } public override void OnGUI(string searchContext) { // Use IMGUI to display UI: EditorGUILayout.PropertyField(m_Settings.FindProperty("m_Number"), new GUIContent("My Number")); EditorGUILayout.PropertyField(m_Settings.FindProperty("m_SomeString"), new GUIContent("Some string")); m_Settings.ApplyModifiedPropertiesWithoutUndo(); } }
Вы можете отблагодарить автора, за перевод документации на русский язык. ₽ Спасибо
API скрипты 2021.3