Beispiel #1
0
    public static NoesisSettings Get()
    {
        if (_settings == null)
        {
            // Theme loading tries to load Noesis library and this is a bad point to allow that
            _noesisEnabled = false;

            _settings = Resources.Load <NoesisSettings>("NoesisSettings");

#if UNITY_EDITOR
            if (_settings == null)
            {
                if (Directory.GetFiles(Application.dataPath, "NoesisSettings.asset", SearchOption.AllDirectories).Length != 0)
                {
                    // In rare situations (for example when upgrading the project to a new version of Unity),
                    // NoesisSettings exists but Unity doesn't load it because it is not registered yet.
                    // In this case, we return a default instance without caching it
                    return((NoesisSettings)ScriptableObject.CreateInstance(typeof(NoesisSettings)));
                }

                _settings = (NoesisSettings)ScriptableObject.CreateInstance(typeof(NoesisSettings));
                _settings.applicationResources = UnityEditor.AssetDatabase.LoadAssetAtPath <NoesisXaml>("Assets/NoesisGUI/Theme/NoesisTheme.DarkBlue.asset");
                _settings.defaultFont          = UnityEditor.AssetDatabase.LoadAssetAtPath <NoesisFont>("Assets/NoesisGUI/Theme/Fonts/PT Root UI_Regular.asset");

                Directory.CreateDirectory(Application.dataPath + "/Resources");
                UnityEditor.AssetDatabase.CreateAsset(_settings, "Assets/Resources/NoesisSettings.asset");
                UnityEditor.AssetDatabase.SaveAssets();
                Debug.Log("A new settings file was created in 'Assets/Resources/NoesisSettings.assets'. Please move it to a different 'Resources' folder if needed");
            }
            else
            {
                NoesisUnity.SetLicense(_settings.licenseName, _settings.licenseKey);
            }
#endif

            _noesisEnabled = true;
        }

        return(_settings);
    }
Beispiel #2
0
 public void OnSave()
 {
     NoesisUnity.SetLicense(licenseName, licenseKey);
 }