void CalculatePlatformSize(GUIBase_Platform platform) { //Spocitame cim prenasobit vysku aby sedela na vysku scutecne obrazovky. //Drzime aspect ratio, takze prenasobime sirku stejnou konstantou. //Pote spocitame rozil mezi vyslednou sirkou a sirkou obrazovky a o polovinu to posuneme v x-ose (pokud je sirka vetsi nez obrazovka, orezeme, pokud memsi, posuneme na stred). // Fit menu on screen Vector3 scale = new Vector3((float)Screen.width / platform.m_Width, (float)Screen.height / platform.m_Height, 1.0f); Transform trans = platform.transform; if (ForcePreserveAspectRatio) { Vector3 platformShift = trans.position; //platformShift.x = (scale.x - scale.y) * platform.m_Width ; platformShift.y = (scale.y - scale.x) * platform.m_Height * 0.5f; //m_UiCamera.transform.position = new Vector3(-, m_UiCamera.transform.position.y, m_UiCamera.transform.position.z); scale.y = scale.x; trans.position = platformShift; } // Debug.Log("Screen: " + Screen.width + ":" + Screen.height + ", platform: " + platform.m_Width + ":" + platform.m_Height + " Scale = " + scale.x + "," + scale.y); //Debug.Log("scale = " + scale.x + ", " + scale.y + ", " + scale.z); trans.localScale = scale; // search for all GUIBase_Layouts and GUIBase_Pivots under this platform foreach (GUIBase_Layout l in platform.Layouts) { l.SetPlatformSize(platform.m_Width, platform.m_Height, scale.x, scale.y); } }
public void UnregisterPlatform(GUIBase_Platform platform) { int idx = m_Platforms.IndexOf(platform); if (idx == -1) { return; } m_Platforms.RemoveAt(idx); }
//--------------------------------------------------------- public GUIBase_Platform FindPlatform(string platformName) { GameObject gObj = GameObject.Find(platformName); if (gObj) { GUIBase_Platform platform = gObj.GetComponent <GUIBase_Platform>(); return(platform); } return(null); }
void GuiInit() { if (BuildInfo.Version.Stage == BuildInfo.Stage.Release) { return; } if (!MFGuiManager.Instance) { return; } GUIBase_Platform p = MFGuiManager.Instance.FindPlatform("Gui_16_9"); if (!p) { return; } m_PivotOther = MFGuiManager.Instance.GetPivot(s_PivotOtherName); if (!m_PivotOther) { //Debug.LogError("'" + s_PivotOtherName + "' not found!!! Assert should come now"); return; } m_LayoutOther = m_PivotOther.GetLayout(s_LayoutOtherName); if (!m_LayoutOther) { //Debug.LogError("'" + s_LayoutOtherName + "' not found!!! Assert should come now"); return; } // DIRTY fix if (m_LayoutOther.GetWidget(s_FPSName, false) == null) { return; } m_FPS = GuiBaseUtils.PrepareNumber(m_LayoutOther, s_FPSName); if (!m_FPS) { return; } Show(true); Initialised = true; }
//--------------------------------------------------------- public void RegisterPlatform(GUIBase_Platform platform) { if (m_Platforms.Contains(platform) == true) { return; } m_Platforms.Add(platform); platform.Pivots = platform.GetComponentsInChildren <GUIBase_Pivot>(); platform.Layouts = platform.GetComponentsInChildren <GUIBase_Layout>(); CalculatePlatformSize(platform); }
void WaitForLogGui() { // TODO - potrebuji robustni test, jestli uz byl level obsahujici GUI doloadovan a vse z nej bylo inicializovano // To co nasleduje rozhodne ROBUSTNI test neni // snazim se najit root platformu a pokud tam je, mela by byt zaregistrovana (ze sveho Startu), podivam se, jestli se uz updatla // To znamena, ze vse uz je loadle, zaregistrovane a uz se updatuje... // Debug.Log("mission waitfor gui"); GUIBase_Platform p = MFGuiManager.Instance.FindPlatform("Gui_16_9"); if (p && p.IsInitialized()) { GuiHUD.StoreControlsPositions(); StartCoroutine(PrepareForStart()); } else { Invoke("WaitForLogGui", 0.1f); } }