Ejemplo n.º 1
0
    protected override void Awake()
    {
        base.Awake();

        // Not interested in non singleton instance
        if (instance != this)
        {
            return;
        }

        // Create instances
        m_addressBook         = AddComponentBasedOnPlatform <AddressBook>();
        m_networkConnectivity = AddComponentBasedOnPlatform <NetworkConnectivity>();
        m_sharing             = AddComponentBasedOnPlatform <Sharing>();
        m_UI      = AddComponentBasedOnPlatform <UI>();
        m_utility = AddComponentBasedOnPlatform <Utility>();

#if !NATIVE_PLUGINS_LITE_VERSION
        m_billing             = AddComponentBasedOnPlatform <Billing>();
        m_mediaLibrary        = AddComponentBasedOnPlatform <MediaLibrary>();
        m_notificationService = AddComponentBasedOnPlatform <NotificationService>();
        m_twitter             = AddComponentBasedOnPlatform <Twitter>();
        m_webView             = AddComponentBasedOnPlatform <WebViewNative>();
#endif
    }
Ejemplo n.º 2
0
    private void AddBindingComponentsIfRequired()
    {
        if (m_bindingComponentsAlreadyAdded)
        {
            return;
        }

        m_bindingComponentsAlreadyAdded = true;

        // Create compoennts
        addressBook         = AddComponentBasedOnPlatform <AddressBook>();
        networkConnectivity = AddComponentBasedOnPlatform <NetworkConnectivity>();
        sharing             = AddComponentBasedOnPlatform <Sharing>();
        userInterface       = AddComponentBasedOnPlatform <UI>();
        utility             = AddComponentBasedOnPlatform <Utility>();

#if !NATIVE_PLUGINS_LITE_VERSION
        billing             = AddComponentBasedOnPlatform <Billing>();
        mediaLibrary        = AddComponentBasedOnPlatform <MediaLibrary>();
        notificationService = AddComponentBasedOnPlatform <NotificationService>();
        twitter             = AddComponentBasedOnPlatform <Twitter>();
        webview             = AddComponentBasedOnPlatform <WebViewNative>();
        gameServices        = AddComponentBasedOnPlatform <GameServices>();
#endif
    }
Ejemplo n.º 3
0
        /// <summary>
        /// Clears all stored cached URL responses.
        /// </summary>
        public void ClearCache()
        {
            WebViewNative _webViewNative = NPBinding.WebView;

            if (_webViewNative != null)
            {
                _webViewNative.Platform.ClearCache();
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Stops loading the current page contents.
        /// </summary>
        public void StopLoading()
        {
            WebViewNative _webViewNative = NPBinding.WebView;

            if (_webViewNative != null)
            {
                _webViewNative.Platform.StopLoading(_tag: this.UniqueID);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Reloads the current page.
        /// </summary>
        public void Reload()
        {
            WebViewNative _webViewNative = NPBinding.WebView;

            if (_webViewNative != null)
            {
                _webViewNative.Platform.Reload(_tag: this.UniqueID);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Destroys the web view instance.
        /// </summary>
        /// <remarks>
        /// <c>DidDestroyEvent</c> event will be called when object is destroyed.
        /// </remarks>
        public void Destroy()
        {
            WebViewNative _webViewNative = NPBinding.WebView;

            if (_webViewNative != null)
            {
                _webViewNative.Platform.Destroy(_tag: this.UniqueID);
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Executes a JavaScript string.
        /// </summary>
        /// <param name="_javaScript">The JavaScript string to evaluate.</param>
        public void EvaluateJavaScriptFromString(string _javaScript)
        {
            WebViewNative _webViewNative = NPBinding.WebView;

            if (_webViewNative != null)
            {
                _webViewNative.Platform.EvaluateJavaScriptFromString(
                    _tag: this.UniqueID,
                    _javaScript: _javaScript
                    );
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Destroys the web view instance.
        /// </summary>
        /// <remarks>
        /// <c>DidDestroyEvent</c> event will be called when object is destroyed.
        /// </remarks>
        public void Destroy()
        {
            WebViewNative _webViewNative = NPBinding.WebView;

            if (_webViewNative != null)
            {
                _webViewNative.Platform.Destroy(_tag: this.UniqueID);
            }


            //  OnDidDestroy();
            if (DidDestroyEvent != null)
            {
                DidDestroyEvent(this);
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Registers the specified scheme, after which web view will start to listen for custom URL.
        /// </summary>
        /// <description>
        /// This approach is used for communicating web view with Unity.
        /// When web view starts loading contents, it will check against registered schemes.
        /// And incase if a match is found, web view will raise <c>DidReceiveMessageEvent</c> along with URL information.
        /// </description>
        /// <param name="_URLSchemeName">The scheme name of the URL.</param>
        public void AddNewURLSchemeName(string _URLSchemeName)
        {
            if (string.IsNullOrEmpty(_URLSchemeName))
            {
                DebugUtility.Logger.LogError(Constants.kDebugTag, "[WebView] Failed to add URL scheme");
                return;
            }

            WebViewNative _webViewNative = NPBinding.WebView;

            if (_webViewNative != null)
            {
                _webViewNative.Platform.AddNewURLSchemeName(
                    _tag: this.UniqueID,
                    _newURLSchemeName: _URLSchemeName
                    );
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Connects to a given URL and asynchronous loads the content.
        /// </summary>
        /// <param name="_URL">A URL identifying the location of the content to load.</param>
        /// <remarks>
        /// \note Don’t use this method to load local HTML files, instead use <see cref="LoadHTMLStringContentsOfFile"/>.
        /// </remarks>
        public void LoadRequest(string _URL)
        {
            if (string.IsNullOrEmpty(_URL) || !_URL.Contains("://"))
            {
                DebugUtility.Logger.LogError(Constants.kDebugTag, "[WebView] Load request failed, please use a valid URL");
                return;
            }

            WebViewNative _webViewNative = NPBinding.WebView;

            if (_webViewNative != null)
            {
                _webViewNative.Platform.LoadRequest(
                    _tag: this.UniqueID,
                    _URL: _URL
                    );
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Loads the webpage contents.
        /// </summary>
        /// <param name="_HTMLString">The contents of the webpage.</param>
        /// <param name="_baseURL">The base URL for the content.</param>
        public void LoadHTMLString(string _HTMLString, string _baseURL = null)
        {
            // Invalid HTML string
            if (string.IsNullOrEmpty(_HTMLString))
            {
                DebugUtility.Logger.LogError(Constants.kDebugTag, "[WebView] Failed to load HTML contents, HTMLString=" + _HTMLString);
                return;
            }

            WebViewNative _webViewNative = NPBinding.WebView;

            if (_webViewNative != null)
            {
                _webViewNative.Platform.LoadHTMLString(
                    _tag: this.UniqueID,
                    _HTMLString: _HTMLString,
                    _baseURL: _baseURL
                    );
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Loads the webpage contents from the given data.
        /// </summary>
        /// <param name="_byteArray">The data to use as the contents of the webpage.</param>
        /// <param name="_MIMEType">The MIME type of the content.</param>
        /// <param name="_textEncodingName">The content's character encoding name.</param>
        /// <param name="_baseURL">The base URL for the content.</param>
        public void LoadData(byte[] _byteArray, string _MIMEType, string _textEncodingName, string _baseURL)
        {
            if (_byteArray == null)
            {
                DebugUtility.Logger.LogError(Constants.kDebugTag, "[WebView] Load data failed");
                return;
            }

            WebViewNative _webViewNative = NPBinding.WebView;

            if (_webViewNative != null)
            {
                _webViewNative.Platform.LoadData(
                    _tag: this.UniqueID,
                    _byteArray: _byteArray,
                    _MIMEType: _MIMEType,
                    _textEncodingName: _textEncodingName,
                    _baseURL: _baseURL
                    );
            }
        }
Ejemplo n.º 13
0
    protected override void Init()
    {
        base.Init();

        // Not interested in non singleton instance
        if (instance != this)
        {
            return;
        }

        // Create compoennts
#if USES_ADDRESS_BOOK
        if (addressBook == null)
        {
            addressBook = AddComponentBasedOnPlatformOnlyIfRequired <AddressBook>();
        }
#endif

#if USES_BILLING
        if (billing == null)
        {
            billing = AddComponentBasedOnPlatformOnlyIfRequired <Billing>();
        }
#endif

#if USES_CLOUD_SERVICES
        if (cloudServices == null)
        {
            cloudServices = AddComponentBasedOnPlatformOnlyIfRequired <CloudServices>();
        }
#endif

#if USES_GAME_SERVICES
        if (gameServices == null)
        {
            gameServices = AddComponentBasedOnPlatformOnlyIfRequired <GameServices>();
        }
#endif

#if USES_MEDIA_LIBRARY
        if (mediaLibrary == null)
        {
            mediaLibrary = AddComponentBasedOnPlatformOnlyIfRequired <MediaLibrary>();
        }
#endif

#if USES_NETWORK_CONNECTIVITY
        if (networkConnectivity == null)
        {
            networkConnectivity = AddComponentBasedOnPlatformOnlyIfRequired <NetworkConnectivity>();
        }
#endif

#if USES_NOTIFICATION_SERVICE
        if (notificationService == null)
        {
            notificationService = CachedGameObject.AddComponentIfNotFound <NotificationService>();
        }
#endif

#if USES_SHARING
        if (sharing == null)
        {
            sharing = AddComponentBasedOnPlatformOnlyIfRequired <Sharing>();
        }
#endif

#if USES_TWITTER
        if (twitter == null)
        {
            twitter = AddComponentBasedOnPlatformOnlyIfRequired <Twitter>();
        }
#endif

        if (userInterface == null)
        {
            userInterface = AddComponentBasedOnPlatformOnlyIfRequired <UI>();
        }

        if (utility == null)
        {
            utility = CachedGameObject.AddComponentIfNotFound <Utility>();
        }

#if USES_WEBVIEW
        if (webview == null)
        {
            webview = CachedGameObject.AddComponentIfNotFound <WebViewNative>();
        }
#endif

#if USES_SOOMLA_GROW
        if (soomlaGrowService == null)
        {
            soomlaGrowService = AddComponentBasedOnPlatformOnlyIfRequired <SoomlaGrowService>();
        }
#endif
    }