// Goes through the list of ad functions, starting where we left off, // and keeps on trying until one plays, or none of them at all would play private static void PlayNextAvailableAdInList(AdFunction[] adFunctionList, string placementName, bool incentivized) { for (int maxTries = adFunctionList.Length; maxTries >= 0; --maxTries) { int index = StackIndex++; bool played = adFunctionList[index](placementName, incentivized); #if DEBUG_ADVERTISING if (highlightedLine != null) { highlightedLine.Unhighlight(); } debugLine[index].SetCurrentTime(); debugLine[index].SetPlacement(string.Format("{0} {1}", incentivized ? "\u2605 " : "", placementName)); debugLine[index].SetResult(played ? "Played" : "Failed"); highlightedLine = debugLine[index].HighlightLine(); #endif if (played) { return; } } }
// If we are debugging the ad slots, this updates the user interface public static void UpdateAdSlotsUI() { #if DEBUG_ADVERTISING int slots = m_AdSlotName.Length; // Create a grid of information so we can see what is going on AdDebuggingSettings settings = AdDebuggingSettings.Instance; // Start by creating a canvas if (debugCanvas == null) { debugCanvas = GameObject.Instantiate(settings.diagnosticCanvasPrefab, Vector3.zero, Quaternion.identity) as GameObject; debugCanvas.name = "Ad Diagnostic Canvas"; GameObject.DontDestroyOnLoad(debugCanvas); } // Get the item that'll be the parent of all others here Transform lineParent = debugCanvas.transform.GetChild(0); int childCount = lineParent.transform.childCount; // Delete any children from the previous time this function ran for (int i = childCount; i > 0; --i) { GameObject child = lineParent.transform.GetChild(i - 1).gameObject; child.SetActive(false); GameObject.Destroy(child); } // Create a list of lines that output debugging information debugLine = new AdDebugLine[slots]; AdDebugLine header = CreateDebugLine <AdDebugLine>(lineParent, settings.diagnosticLinePrefab, "Table header"); header.MakeHeader(); for (int i = 0; i < slots; ++i) { debugLine[i] = CreateDebugLine <AdDebugLine>(lineParent, settings.diagnosticLinePrefab, string.Format("{0} {1}", "Ad Diagnostic Line", i + 1)); debugLine[i].SetProvider(m_AdSlotName[i]); } // Finally, create a line for text output loadingTimeOutput = CreateDebugLine <Text>(lineParent, settings.diagnosticTextOutputLinePrefab, "Loading times"); UpdateLoadingTimeOutput(); #endif }