Ei kuvausta
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

XCSettingsEditor.cs 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using UnityEditor;
  2. using UnityEngine;
  3. using XCharts.Runtime;
  4. namespace XCharts.Editor
  5. {
  6. [CustomEditor(typeof(XCSettings))]
  7. public class XCSettingsEditor : UnityEditor.Editor
  8. {
  9. internal class Styles
  10. {
  11. public static readonly GUIContent defaultFontAssetLabel = new GUIContent("Default Font Asset", "The Font Asset that will be assigned by default to newly created text objects when no Font Asset is specified.");
  12. public static readonly GUIContent defaultFontAssetPathLabel = new GUIContent("Path: Resources/", "The relative path to a Resources folder where the Font Assets and Material Presets are located.\nExample \"Fonts & Materials/\"");
  13. }
  14. }
  15. #if UNITY_2018_3_OR_NEWER
  16. class XCResourceImporterProvider : SettingsProvider
  17. {
  18. XCResourcesImporter m_ResourceImporter;
  19. public XCResourceImporterProvider() : base("Project/XCharts", SettingsScope.Project)
  20. { }
  21. public override void OnGUI(string searchContext)
  22. {
  23. if (m_ResourceImporter == null)
  24. m_ResourceImporter = new XCResourcesImporter();
  25. m_ResourceImporter.OnGUI();
  26. }
  27. public override void OnDeactivate()
  28. {
  29. if (m_ResourceImporter != null)
  30. m_ResourceImporter.OnDestroy();
  31. }
  32. static UnityEngine.Object GetSettings()
  33. {
  34. return Resources.Load<XCSettings>("XCSettings");
  35. }
  36. [SettingsProviderGroup]
  37. static SettingsProvider[] CreateXCSettingsProvider()
  38. {
  39. var providers = new System.Collections.Generic.List<SettingsProvider> { new XCResourceImporterProvider() };
  40. if (GetSettings() != null)
  41. {
  42. var provider = new AssetSettingsProvider("Project/XCharts/Settings", GetSettings);
  43. provider.PopulateSearchKeywordsFromGUIContentProperties<XCSettingsEditor.Styles>();
  44. providers.Add(provider);
  45. }
  46. return providers.ToArray();
  47. }
  48. }
  49. #endif
  50. }