////////////////////////////////////////////////////////////////////////////////////////////////
 private void DisposeLibrary()
 {
     if (_library != null)
     {
         _library.Dispose();
         _library = null;
     }
 }
 ////////////////////////////////////////////////////////////////////////////////////////////////
 private void RegisterFunctions(Noesis.Library lib)
 {
     _loadXAML = lib.Find<LoadXAMLDelegate>("Noesis_LoadXAML");
     _tryLoadXAML = lib.Find<LoadXAMLDelegate>("Noesis_TryLoadXAML");
     _initKernel = lib.Find<InitKernelDelegate>("Noesis_Init");
     _shutdownKernel = lib.Find<ShutdownKernelDelegate>("Noesis_Shutdown");
     _tickKernel = lib.Find<TickKernelDelegate>("Noesis_Tick");
     _registerSoftwareKeyboardCallbacks = lib.Find<RegisterSoftwareKeyboardCallbacksDelegate>(
         "Noesis_RegisterSoftwareKeyboardCallbacks");
 }
    ////////////////////////////////////////////////////////////////////////////////////////////////
    private void Init()
    {
#if UNITY_EDITOR
        if (PlayerPrefs.HasKey("NoesisErrors"))
        {
            Debug.LogWarning("<color=green>NoesisGUI:</color> Please, fix all XAML errors before hitting PLAY");
        }
#endif
        UnityInitDevice();

#if UNITY_EDITOR
        try
        {
            _library = new Noesis.Library(UnityEngine.Application.dataPath +
                "/Editor/NoesisGUI/BuildTool/Noesis");

            RegisterFunctions(_library);
            Noesis.Error.RegisterFunctions(_library);
            Noesis.Log.RegisterFunctions(_library);
            Noesis.Extend.RegisterFunctions(_library);
            Noesis.UIRenderer.RegisterFunctions(_library);
            Noesis.NoesisGUI_PINVOKE.RegisterFunctions(_library);
#endif
            DoInit();

            _isInitialized = true;
#if UNITY_EDITOR
        }
        catch (System.Exception e)
        {
            Shutdown();
            throw e;
        }
#endif

        // To avoid that this GameObject is destroyed when a new scene is loaded
        DontDestroyOnLoad(gameObject);
    }
 ////////////////////////////////////////////////////////////////////////////////////////////////
 public new static void RegisterFunctions(Library lib)
 {
     _CreateUIPropertyMetadata = lib.Find <CreateUIPropertyMetadataDelegate>(
         "Noesis_CreateUIPropertyMetadata");
 }