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); } }
private static bool TryFindExistingInstance(out PowerInspectorDocumentationWindow existingInstance) { if (instance != null) { existingInstance = instance; return(true); } var existingInstances = Resources.FindObjectsOfTypeAll <PowerInspectorDocumentationWindow>(); if (existingInstances.Length > 0) { existingInstance = existingInstances[0]; return(true); } existingInstance = null; return(false); }