public static bool ShowPageIfWindowOpen([NotNull] string url, WebpageLoadFailed onFailToLoadUrl = null) { if (TryFindExistingInstance(out instance)) { #if DEV_MODE Debug.Log("onFailToLoadNextUrl = " + StringUtils.ToString(onFailToLoadUrl)); #endif if (!instance.autoUpdateEnabled) { #if DEV_MODE Debug.Log("PowerInspectorDocumentationWindow.ShowPageIfWindowOpen(" + url + ") - won't show because autoUpdateEnabled was false."); #endif return(false); } instance.onFailToLoadNextUrl = onFailToLoadUrl; instance.OpenUrl(url); return(true); } #if DEV_MODE && DEBUG_SHOW_IF_OPEN Debug.Log("PowerInspectorDocumentationWindow.ShowPageIfWindowOpen(" + url + ") - won't show because window was not open."); #endif return(false); }
public static void Open(bool focus, [CanBeNull] string url, [CanBeNull] WebpageLoadFailed onFailToLoadUrl) { if (instance == null && !TryFindExistingInstance(out instance)) { instance = CreateInstance <PowerInspectorDocumentationWindow>(); instance.titleContent = new GUIContent("Power Inspector Documentation"); instance.minSize = new Vector2(width, height); instance.maxSize = new Vector2(width, height); instance.ShowUtility(); } if (focus) { #if DEV_MODE Debug.Log("Focusing PowerInspectorDocumentationWindow"); #endif instance.Focus(); } if (!string.IsNullOrEmpty(url)) { #if DEV_MODE Debug.Log("onFailToLoadNextUrl = " + StringUtils.ToString(onFailToLoadUrl)); #endif instance.onFailToLoadNextUrl = onFailToLoadUrl; instance.OpenUrl(url); } }
/// <summary> /// Opens the documentation page in the Power Inspector documentation window. /// </summary> /// <param name="url"> The URL of the page in full. </param> /// <param name="onFailToLoadUrl"> (Optional) Callback that is invoked if loading the url fails. </param> public static void OpenUrl(string url, WebpageLoadFailed onFailToLoadUrl = null) { if (OnRequestingOpenWindow != null) { OnRequestingOpenWindow(url, onFailToLoadUrl); } #if DEV_MODE else { UnityEngine.Debug.LogError("PowerInspectorDocumentation OnRequestingOpenWindow was null - can't open documentation page"); } #endif }
/// <summary> /// Show url in documentation window if it is currently open and auto-update is enabled. /// </summary> /// <param name="url"> Full url of the page. </param> /// <param name="onFailToLoadUrl"> (Optional) Callback that is invoked if loading the url fails. If null then errors will be logged to console instead. </param> /// <returns> True if window was open and auto-updating was enabled. </returns> public static bool ShowUrlIfWindowOpen(string url, WebpageLoadFailed onFailToLoadUrl = null) { if (OnRequestingShowPageIfWindowOpen != null) { return(OnRequestingShowPageIfWindowOpen(url, onFailToLoadUrl)); } #if DEV_MODE else { UnityEngine.Debug.LogError("PowerInspectorDocumentation OnRequestingShowPageIfWindowOpen was null - can't open documentation page"); } #endif return(false); }
/// <summary> /// Opens the documentation page in the Power Inspector documentation window. /// </summary> /// <param name="url"> The URL of the page in full. </param> /// <param name="onFailToLoadUrl"> (Optional) Callback that is invoked if loading the url fails. </param> public static void OpenUrl(string url, WebpageLoadFailed onFailToLoadUrl = null) { #if UNITY_2020_1_OR_NEWER // WebView class no longer exists in Unity 2020.1 or later ShowExternalDocumentation(url); #else if (OnRequestingOpenWindow != null) { OnRequestingOpenWindow(url, onFailToLoadUrl); } #if DEV_MODE else { UnityEngine.Debug.LogError("PowerInspectorDocumentation OnRequestingOpenWindow was null - can't open documentation page"); } #endif #endif }
/// <summary> /// Show url in documentation window if it is currently open and auto-update is enabled. /// </summary> /// <param name="url"> Full url of the page. </param> /// <param name="onFailToLoadUrl"> (Optional) Callback that is invoked if loading the url fails. If null then errors will be logged to console instead. </param> /// <returns> True if window was open and auto-updating was enabled. </returns> public static bool ShowUrlIfWindowOpen(string url, WebpageLoadFailed onFailToLoadUrl = null) { #if !UNITY_2020_1_OR_NEWER // WebView class no longer exists in Unity 2020.1 or later if (OnRequestingShowPageIfWindowOpen != null) { return(OnRequestingShowPageIfWindowOpen(url, onFailToLoadUrl)); } #if DEV_MODE else { UnityEngine.Debug.LogError("PowerInspectorDocumentation OnRequestingShowPageIfWindowOpen was null - can't open documentation page"); } #endif #endif return(false); }
private void OnFailedToLoadWebpage(string failedToLoadUrl) { if (onFailToLoadNextUrl != null) { var callback = onFailToLoadNextUrl; #if DEV_MODE Debug.Log("onFailToLoadNextUrl = null"); #endif onFailToLoadNextUrl = null; callback(failedToLoadUrl); return; } DrawGUI.Active.DisplayDialog("Failed to Load Webpage", "Failed to load webpage:\n" + failedToLoadUrl + ".\n\nPlease make sure you are connected to the internet.", "Ok"); OpenUrl(PowerInspectorDocumentation.PreferencesUrl); }
/// <summary> /// Shows the feature documentation page in the Power Inspector documentation window if it is already open and has auto update enabled. /// </summary> /// <param name="pageName"> The name of the page. </param> /// <param name="onFailToLoadUrl"> (Optional) Callback that is invoked if loading the url fails. </param> public static bool ShowFeatureIfWindowOpen(string pageName, WebpageLoadFailed onFailToLoadUrl = null) { return(ShowUrlIfWindowOpen(GetFeatureUrl(pageName), onFailToLoadUrl)); }
/// <summary> /// Shows the preferences documentation page in the Power Inspector documentation window if it is already open and has auto update enabled. /// </summary> /// <param name="pageName"> The name of the page. </param> /// <param name="onFailToLoadUrl"> (Optional) Callback that is invoked if loading the url fails. </param> public static bool ShowPreferencesIfWindowOpen(string pageName, WebpageLoadFailed onFailToLoadUrl = null) { return(ShowUrlIfWindowOpen(GetPreferencesUrl(pageName), onFailToLoadUrl)); }
public static void OpenWindow([NotNull] string url = "", WebpageLoadFailed onFailToLoadUrl = null) { Open(false, url, onFailToLoadUrl); }
public static void OpenWindow([NotNull] string url = "", WebpageLoadFailed onFailToLoadUrl = null) { #if !UNITY_2020_1_OR_NEWER // WebView class no longer exists in Unity 2020.1 or later Open(false, url, onFailToLoadUrl); #endif }