A game about forced loneliness, made by TACStudios
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using UnityEditor;
5using UnityEngine;
6
7namespace Unity.VisualScripting
8{
9 internal class LinkerPropertyProviderSettings
10 {
11 private readonly PluginConfigurationItemMetadata _linkerSettings;
12
13 private const string Title = "Linker generation settings";
14
15 private readonly GUIContent[] _toggleTargetsLabel =
16 {
17 new GUIContent("Scan graph assets"),
18 new GUIContent("Scan scenes"),
19 new GUIContent("Scan prefabs")
20 };
21
22 private Array _options = Enum.GetValues(typeof(BoltCoreConfiguration.LinkerScanTarget));
23 private List<bool> _settings;
24
25 public LinkerPropertyProviderSettings(BoltCoreConfiguration coreConfig)
26 {
27 _linkerSettings = coreConfig.GetMetadata(nameof(LinkerPropertyProviderSettings));
28
29 _settings = new List<bool>((List<bool>)_linkerSettings.value);
30 }
31
32 private void SaveIfNeeded()
33 {
34 var settings = (List<bool>)_linkerSettings.value;
35
36 if (!_settings.SequenceEqual(settings))
37 {
38 _linkerSettings.value = new List<bool>(_settings);
39
40 _linkerSettings.SaveImmediately();
41 }
42 }
43
44 public void OnGUI()
45 {
46 GUILayout.Space(5f);
47
48 GUILayout.Label(Title, EditorStyles.boldLabel);
49
50 GUILayout.Space(5f);
51
52 var label = "Scan for types to be added to link.xml";
53
54 GUILayout.BeginHorizontal(EditorStyles.helpBox);
55 GUILayout.Label(EditorGUIUtility.IconContent("console.infoicon"), GUILayout.ExpandWidth(true));
56 GUILayout.Box(label, EditorStyles.wordWrappedLabel);
57 GUILayout.EndHorizontal();
58
59 GUILayout.Space(5f);
60
61 foreach (var option in _options)
62 {
63 _settings[(int)option] = GUILayout.Toggle(_settings[(int)option], _toggleTargetsLabel[(int)option]);
64 GUILayout.Space(5f);
65 }
66
67 SaveIfNeeded();
68 }
69 }
70}