2021-01-11 08:54:28 +08:00
using UnityEditor ;
using UnityEngine ;
2022-02-19 22:37:57 +08:00
using XCharts.Runtime ;
2021-01-11 08:54:28 +08:00
2021-12-24 13:33:09 +08:00
namespace XCharts.Editor
2021-01-11 08:54:28 +08:00
{
2021-11-23 13:20:07 +08:00
[CustomEditor(typeof(XCSettings))]
2021-12-24 13:33:09 +08:00
public class XCSettingsEditor : UnityEditor . Editor
2021-01-11 08:54:28 +08:00
{
2022-03-26 18:30:55 +08:00
internal class Styles
{
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." ) ;
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/\"" ) ;
}
2021-01-11 08:54:28 +08:00
}
#if UNITY_2018_3_OR_NEWER
2021-11-23 13:20:07 +08:00
class XCResourceImporterProvider : SettingsProvider
2021-01-11 08:54:28 +08:00
{
2021-11-23 13:20:07 +08:00
XCResourcesImporter m_ResourceImporter ;
2021-01-11 08:54:28 +08:00
2022-05-22 22:17:38 +08:00
public XCResourceImporterProvider ( ) : base ( "Project/XCharts" , SettingsScope . Project )
{ }
2021-01-11 08:54:28 +08:00
public override void OnGUI ( string searchContext )
{
if ( m_ResourceImporter = = null )
2021-11-23 13:20:07 +08:00
m_ResourceImporter = new XCResourcesImporter ( ) ;
2021-01-11 08:54:28 +08:00
m_ResourceImporter . OnGUI ( ) ;
}
public override void OnDeactivate ( )
{
if ( m_ResourceImporter ! = null )
m_ResourceImporter . OnDestroy ( ) ;
}
static UnityEngine . Object GetSettings ( )
{
2021-11-23 13:20:07 +08:00
return Resources . Load < XCSettings > ( "XCSettings" ) ;
2021-01-11 08:54:28 +08:00
}
[SettingsProviderGroup]
2021-11-23 13:20:07 +08:00
static SettingsProvider [ ] CreateXCSettingsProvider ( )
2021-01-11 08:54:28 +08:00
{
2022-01-07 09:48:59 +08:00
var providers = new System . Collections . Generic . List < SettingsProvider > { new XCResourceImporterProvider ( ) } ;
2021-01-11 08:54:28 +08:00
if ( GetSettings ( ) ! = null )
{
var provider = new AssetSettingsProvider ( "Project/XCharts/Settings" , GetSettings ) ;
2021-11-23 13:20:07 +08:00
provider . PopulateSearchKeywordsFromGUIContentProperties < XCSettingsEditor . Styles > ( ) ;
2021-01-11 08:54:28 +08:00
providers . Add ( provider ) ;
}
return providers . ToArray ( ) ;
}
}
#endif
}