コード例 #1
0
 public static void CloseUI(string uiClass, Action <Intent> onCloseOver = null)
 {
     if (m_instance.defaultParent == null)
     {
         lhDebug.LogError((object)"LaoHan: defaultParent is null");
         return;
     }
     if (!m_instance.m_uiLibrary.ContainsKey(uiClass))
     {
         lhDebug.LogWarning((object)("LaoHan: m_uiLibrary dont has this Class : < " + uiClass + " > "));
     }
     else
     {
         if (!m_instance.m_uiPath.ContainsKey(uiClass))
         {
             lhDebug.LogError((object)("LaoHan: uiPath dont has this Class: < " + uiClass + " >"));
         }
         else
         {
             lhUIBase uiBase = m_instance.m_uiLibrary[uiClass];
             uiBase.gameObject.SetActive(false);
             if (uiBase.uiState != EUIState.Close)
             {
                 uiBase.Close(onCloseOver);
             }
             else
             {
                 lhDebug.LogWarning((object)("LaoHan: Class < " + uiClass + " > UIState < " + uiBase.uiState + " >"));
             }
         }
     }
 }
コード例 #2
0
 public static void DestroyUI(string uiClass, Action <Intent> onDestroyOver = null)
 {
     if (m_instance.defaultParent == null)
     {
         lhDebug.LogError((object)"LaoHan: defaultParent is null");
         return;
     }
     if (!m_instance.m_uiLibrary.ContainsKey(uiClass))
     {
         lhDebug.LogWarning((object)("LaoHan: m_uiLibrary dont has this Class : < " + uiClass + " > "));
     }
     else
     {
         if (!m_instance.m_uiPath.ContainsKey(uiClass))
         {
             lhDebug.LogError((object)("LaoHan: uiPath dont has this Class: < " + uiClass + " >"));
         }
         else
         {
             lhUIBase uiBase = m_instance.m_uiLibrary[uiClass];
             uiBase.gameObject.SetActive(false);
             if (uiBase.uiState != EUIState.Destroy)
             {
                 m_instance.m_uiMessageHandler -= uiBase.ReceiveMessage;
                 m_instance.m_uiLibrary.Remove(uiClass);
                 uiBase.Destroy(onDestroyOver);
                 UnityEngine.Object.Destroy(uiBase.gameObject);
             }
             else
             {
                 lhDebug.LogWarning((object)("LaoHan: Class < " + uiClass + " > UIState < " + uiBase.uiState + " >"));
             }
         }
     }
 }
コード例 #3
0
 public static void DestoryUtility(string uiClass, lhUIBase utilityBase, Action <Intent> onDestroyOver = null)
 {
     if (!m_instance.m_utilityLibrary.ContainsKey(uiClass))
     {
         lhDebug.LogError((object)("LaoHan: uiClass < " + uiClass + " > dont in utilityLibrary"));
         return;
     }
     m_instance.m_utilityLibrary.Remove(uiClass);
     utilityBase.Destroy(onDestroyOver);
     UnityEngine.Object.Destroy(utilityBase.gameObject);
 }
コード例 #4
0
        public static void EnterUI(string uiClass, Transform parent, Action <lhUIBase> onEnterOver = null, Action <Intent> onCloseOver = null, bool closeCurrentUI = true)
        {
            if (!m_instance.m_uiLibrary.ContainsKey(uiClass))
            {
                if (!m_instance.m_uiPath.ContainsKey(uiClass))
                {
                    lhDebug.LogError((object)("LaoHan: uiPath dont has this Class: < " + uiClass + " >"));
                    return;
                }
                lhResources.Load(m_instance.m_uiPath[uiClass].uiPath, (o) =>
                {
                    GameObject obj = o as GameObject;

                    lhUIBase uiBase = (m_instance.lhInstantiate((GameObject)obj)).GetComponent <lhUIBase>();
                    m_instance.SetRectTransform(uiBase.rectTransform, parent);
                    uiBase.gameObject.SetActive(false);
                    uiBase.Initialize(() =>
                    {
                        if (closeCurrentUI)
                        {
                            if (m_instance.m_currentUI != null)
                            {
                                m_instance.m_currentUI.Close(onCloseOver);
                            }
                            m_instance.m_currentUI = uiBase;
                        }
                        m_instance.m_uiLibrary.Add(uiClass, uiBase);
                        if (onEnterOver != null)
                        {
                            onEnterOver(uiBase);
                        }
                        m_instance.m_uiMessageHandler += uiBase.ReceiveMessage;
                    });
                });
            }
            else
            {
                lhUIBase uiBase = m_instance.m_uiLibrary[uiClass];
                //uiBase.gameObject.SetActive(true);
                if (closeCurrentUI && m_instance.m_currentUI != null)
                {
                    m_instance.m_currentUI.Close(onCloseOver);
                    m_instance.m_currentUI = uiBase;
                }
                if (onEnterOver != null)
                {
                    onEnterOver(uiBase);
                }
            }
        }