Hi All, Hey I just noticed that if you save a palette in unity it gets stored in what looks like a scriptable object - Just wondering, is there a way to access the colours stored within it? Could be really handy! Thanks! Pete
You can set up a thing to figure out the type of whatever you've clicked: Code (csharp): public static class EditorCommands { [MenuItem("Commands/Get Type Of Selected")] public static void GetTypeOfSelected() { Debug.Log(Selection.activeObject?.GetType().Name); } } Using that, you'll find that the type of a palette is a ColorPresetLibrary. Now, is that a type we can work with? There's several ways you can do it, but if you have a code editor that's competent, you can just search for the name and find a decompiled version of the type: Code (csharp): namespace UnityEditor { internal class ColorPresetLibrary : PresetLibrary ... } Well, it's internal, so we don't have access to it from scripts. Time to just open the asset in a text editor and check what it looks like: Code (csharp): %YAML 1.1 %TAG !u! tag:unity3d.com,2011: --- !u!114 &1 MonoBehaviour: m_ObjectHideFlags: 52 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 0} m_Enabled: 1 m_EditorHideFlags: 1 m_Script: {fileID: 12323, guid: 0000000000000000e000000000000000, type: 0} m_Name: m_EditorClassIdentifier: m_Presets: - m_Name: m_Color: {r: 1, g: 1, b: 1, a: 1} - m_Name: m_Color: {r: 0.9705882, g: 0.007136685, b: 0.007136685, a: 1} - m_Name: m_Color: {r: 0.13559689, g: 0.4712593, b: 0.5588235, a: 1} Well, that's easy to work with! I'd suggest just grabbing that text file, look for all lines starting with "m_Color", and parse them into colors. It should be pretty straight-forward to create that as a helper-method. Give a call if you need more input.