// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 // Unity using UnityEditor; namespace AWS.GameKit.Editor.Utils { /// /// A wrapper for a pair of dark-theme and light-theme objects. /// /// Use this class when you need to use one of two objects depending on whether the Unity Editor Theme is Dark or Light. /// /// The type of object to wrap. public class EditorThemeAware : IGettable { /// /// The object to use when the Unity Editor theme is Dark. /// public T DarkThemeObject { get; } /// /// The object to use when the Unity Editor theme is Light. /// public T LightThemeObject { get; } /// /// Create a new EditorThemeAware wrapper for the two provided objects. /// /// The object to use when the Unity Editor theme is Dark. /// The object to use when the Unity Editor theme is Light. public EditorThemeAware(T darkThemeObject, T lightThemeObject) { DarkThemeObject = darkThemeObject; LightThemeObject = lightThemeObject; } /// /// Get the object matching the current Unity Editor theme. /// /// The DarkThemeObject if the Unity Editor theme is "Dark", otherwise the LightThemeObject. public virtual T Get() { return EditorGUIUtility.isProSkin ? DarkThemeObject : LightThemeObject; } } }