private void AddPopUp() { WindowController window = Instantiate(m_window, m_windowContainer).GetComponent <WindowController>(); AdData data = m_adb.RequestRandom(); window.Initialize(data, CloseWindow); if (ProgramManager.instance.ConsolidateActive) { RectTransform winRect = window.GetComponent <RectTransform>(); winRect.anchoredPosition = Settings.ConsolodatePosition; if (ProgramManager.instance.PredictionActive) { ProgramManager.instance.Predict(); } } else { if (ProgramManager.instance.PredictionActive) { Vector2 pos = ProgramManager.instance.PredictionPos; RectTransform winRect = window.GetComponent <RectTransform>(); if (pos.y + (winRect.rect.height / 2) > Screen.height / 2) { pos.y = (Screen.height / 2) - (winRect.rect.height / 2); } winRect.anchoredPosition = pos; ProgramManager.instance.Predict(); } else { Vector2 pos = UnityEngine.Random.insideUnitCircle * (new Vector2(Screen.width, Screen.height) / 2); RectTransform winRect = window.GetComponent <RectTransform>(); if (pos.y + (winRect.rect.height / 2) > Screen.height / 2) { pos.y = (Screen.height / 2) - (winRect.rect.height / 2); } winRect.anchoredPosition = pos; } } m_currentWindows.Add(window); }
public void AddWindow(GameObject windowGo, AdData.Function func) { WindowController window = Instantiate(windowGo, m_windowContainer).GetComponent <WindowController>(); window.Initialize(func, CloseWindow); if (window.programWindow) { window.GetComponent <RectTransform>().anchoredPosition = Vector2.zero; } else { Vector2 pos = UnityEngine.Random.insideUnitCircle * (new Vector2(Screen.width, Screen.height) / 2); RectTransform winRect = window.GetComponent <RectTransform>(); if (pos.y + (winRect.rect.height / 2) > Screen.height / 2) { pos.y = (Screen.height / 2) - (winRect.rect.height / 2); } winRect.anchoredPosition = pos; } m_currentWindows.Add(window); }