60 lines
2.1 KiB
C#
60 lines
2.1 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEditor;
|
|
|
|
namespace Akila.FPSFramework
|
|
{
|
|
[CustomEditor(typeof(SettingApplier))]
|
|
public class SettingApplierEditor : Editor
|
|
{
|
|
[System.Obsolete]
|
|
public override void OnInspectorGUI()
|
|
{
|
|
SettingApplier settingApplier = (SettingApplier)target;
|
|
SettingsManager settingsManager = FindObjectOfType<SettingsManager>();
|
|
|
|
EditorGUI.BeginChangeCheck();
|
|
Undo.RecordObject(settingApplier, "Chnaged setting applier");
|
|
|
|
if (!settingsManager)
|
|
{
|
|
EditorGUILayout.HelpBox("Couldn't find any game object with the component 'Settings Manager. Please add the component anywhere in your scene to show this component's properties.", MessageType.Warning);
|
|
return;
|
|
}
|
|
|
|
List<string> options = new List<string>();
|
|
|
|
foreach (var preset in settingsManager.settingsPresets)
|
|
{
|
|
if (!preset)
|
|
{
|
|
EditorGUILayout.HelpBox("Couldn't find a preset assigned to the field 'Settings Preset' in the component 'Settings Manager. Please assign any preset into your settings manager component to show this component's properties.", MessageType.Warning);
|
|
return;
|
|
}
|
|
|
|
|
|
foreach (SettingSection section in preset.sections)
|
|
{
|
|
string s = section.name;
|
|
|
|
foreach (SettingOption option in section.options)
|
|
{
|
|
string o = option.name;
|
|
options.Add($"{preset.name}/{s}/{o}");
|
|
}
|
|
}
|
|
}
|
|
|
|
options.Add("None");
|
|
|
|
settingApplier.selectedPathIndex = EditorGUILayout.Popup("Path", settingApplier.selectedPathIndex, options.ToArray());
|
|
settingApplier.path = options[settingApplier.selectedPathIndex];
|
|
|
|
if (EditorGUI.EndChangeCheck())
|
|
{
|
|
EditorUtility.SetDirty(settingApplier);
|
|
}
|
|
}
|
|
}
|
|
} |