A game about forced loneliness, made by TACStudios
1using System.Collections.Generic;
2using UnityEditor;
3
4namespace Unity.VisualScripting
5{
6 [Plugin(BoltFlow.ID)]
7 public sealed class BoltFlowResources : PluginResources
8 {
9 private BoltFlowResources(BoltFlow plugin) : base(plugin)
10 {
11 icons = new Icons(this);
12 }
13
14 public Icons icons { get; private set; }
15
16
17 public override void LateInitialize()
18 {
19 base.LateInitialize();
20
21 icons.Load();
22 }
23
24 public class Icons
25 {
26 public Icons(BoltFlowResources resources)
27 {
28 this.resources = resources;
29 }
30
31 private readonly Dictionary<UnitCategory, EditorTexture> unitCategoryIcons = new Dictionary<UnitCategory, EditorTexture>();
32
33 private readonly BoltFlowResources resources;
34
35 public EditorTexture graph { get; private set; }
36 public EditorTexture unit { get; private set; }
37 public EditorTexture flowMacro { get; private set; }
38 public EditorTexture unitCategory { get; private set; }
39
40 public EditorTexture controlPortConnected { get; private set; }
41 public EditorTexture controlPortUnconnected { get; private set; }
42 public EditorTexture valuePortConnected { get; private set; }
43 public EditorTexture valuePortUnconnected { get; private set; }
44 public EditorTexture invalidPortConnected { get; private set; }
45 public EditorTexture invalidPortUnconnected { get; private set; }
46
47 public EditorTexture coroutine { get; private set; }
48
49 public void Load()
50 {
51 graph = typeof(FlowGraph).Icon();
52 unit = typeof(IUnit).Icon();
53 flowMacro = resources.LoadIcon("FlowMacro.png");
54 unitCategory = resources.LoadIcon("UnitCategory.png");
55
56 var portResolutions = new[] { new TextureResolution(9, 12), new TextureResolution(12, 24) };
57 var portOptions = CreateTextureOptions.PixelPerfect;
58
59 controlPortConnected = resources.LoadTexture("ControlPortConnected.png", portResolutions, portOptions);
60 controlPortUnconnected = resources.LoadTexture("ControlPortUnconnected.png", portResolutions, portOptions);
61 valuePortConnected = resources.LoadTexture("ValuePortConnected.png", portResolutions, portOptions);
62 valuePortUnconnected = resources.LoadTexture("ValuePortUnconnected.png", portResolutions, portOptions);
63 invalidPortConnected = resources.LoadTexture("InvalidPortConnected.png", portResolutions, portOptions);
64 invalidPortUnconnected = resources.LoadTexture("InvalidPortUnconnected.png", portResolutions, portOptions);
65
66 coroutine = resources.LoadIcon("Coroutine.png");
67 }
68
69 public EditorTexture UnitCategory(UnitCategory category)
70 {
71 if (category == null)
72 {
73 return unitCategory;
74 }
75
76 if (!unitCategoryIcons.ContainsKey(category))
77 {
78 var path = $"{category.name}.png";
79
80 EditorTexture editorTexture = LoadSharedIcon(path, false);
81
82 if (editorTexture == null)
83 {
84 editorTexture = unitCategory;
85 }
86
87 unitCategoryIcons.Add(category, editorTexture);
88 }
89
90 return unitCategoryIcons[category];
91 }
92 }
93 }
94}