Beispiel #1
0
    void Start()
    {
        GameObject btn = this.gameObject;

        if (null == target)
        {
            target = btn;
        }

        EventTriggerListener.Get(btn).onDown += (bt) =>
        {
            GameObject copy = UIUtils.AddChild(btn.transform.parent.gameObject, target);
            copy.transform.position = target.transform.position;
            int siblineIndex = btn.transform.GetSiblingIndex();
            copy.transform.SetSiblingIndex(siblineIndex);
            Image img = copy.GetComponent <Image>();
            if (null != img)
            {
                img.material = null;
                img.DOFade(0, 1);
            }

            copy.transform.DOScale(Vector3.one * scale, 1);
            Destroy(copy, 1);
        };
    }
Beispiel #2
0
 void GenerateTextToShow(int showNumber)
 {
     if (null != unitText)
     {
         GameObject textGameObject = UIUtils.AddChild(this.gameObject, unitText.gameObject);
         Text       text           = textGameObject.GetComponent <Text>();
         text.text = showNumber.ToString();
     }
 }
Beispiel #3
0
    public GameObject SetUseBlackMask(GameObject target)
    {
        GameObject    go   = UIUtils.AddChild(target, "Prefabs/UI/UseBlackMask");
        RectTransform rect = go.GetComponent <RectTransform>();

        rect.offsetMax = Vector2.zero;
        rect.offsetMin = Vector2.zero;
        rect.SetAsFirstSibling();
        return(go);
    }
Beispiel #4
0
        public void LoadMsg(string key, System.Action <UIMsgBase> callback)
        {
            UIMsgBase dialog = FindMsgInCache(key);

            if (dialog == null)
            {
                string assetName = key + "Msg";
                string abName    = AppConst.ResDir + "Prefabs/UI/Msg/" + assetName + ".prefab";
                ResManager.LoadPrefab(abName, delegate(UnityEngine.Object[] objs)
                {
                    if (objs.Length == 0)
                    {
                        return;
                    }
                    GameObject newSceneGameObject = objs[0] as GameObject;
                    if (newSceneGameObject != null)
                    {
                        newSceneGameObject = UIUtils.AddChild(MsgRoot, newSceneGameObject);
                        if (newSceneGameObject.activeSelf == true)
                        {
                            Debug.Log("newSceneGameObject activity true:" + newSceneGameObject.name);
                        }
                        else
                        {
                            Debug.Log("newSceneGameObject activity false:" + newSceneGameObject.name);
                        }
                        if (newSceneGameObject != null)
                        {
                            dialog = newSceneGameObject.GetComponent <UIMsgBase>();
                            dialog.InitializeScene();
                            callback(dialog);
                        }
                        else
                        {
                            Debug.LogWarning("UISystem::LoadDialog() Failed to add new scene to parent UISystem with name: " + key);
                        }
                    }
                    else
                    {
                        Debug.LogWarning("UISystem::LoadDialog() Failed to load new scene with name: " + key);
                    }
                });
            }
            else
            {
                callback(dialog);
            }
        }
Beispiel #5
0
    public GameObject SetUseNav(GameObject target)
    {
        GameObject obj = Resources.Load <GameObject>("Prefabs/UI/TopNavSub");
        GameObject nav = UIUtils.AddChild(target, obj);

        if (nav != null)
        {
            RectTransform tempRect = obj.GetComponent <RectTransform>();
            RectTransform rect     = nav.GetComponent <RectTransform>();
            rect.offsetMax = tempRect.offsetMax;
            rect.offsetMin = tempRect.offsetMin;

            TopNavSub navSub = nav.GetComponent <TopNavSub>();
            navSub.BackButtonClickAction = OnBackPressed;
        }
        return(nav);
    }
Beispiel #6
0
    public void Show(string tipsInfo)
    {
        GameObject tips = FindDisactive();

        if (null == tips)
        {
            tips = UIUtils.AddChild(root, tipsPrefab);
            caches.Add(tips);
        }

        if (null != tips)
        {
            UIUtils.SetActive(tips, true);
            StartCoroutine(delayHide(tips));
            RectTransform rect = tips.GetComponent <RectTransform>();
            rect.SetAsLastSibling();
            Text txt = tips.GetComponentInChildren <Text>();
            txt.text = tipsInfo;
        }
    }
    /// <summary>
    /// 加载UI界面
    /// </summary>
    /// <param name="strPrefabePath"></param>
    /// <returns></returns>
    public UIDialogBase LoadScene(string strPrefabePath)
    {
        UIDialogBase dialog = FindInCache(strPrefabePath);


        if (dialog == null)
        {
            GameObject newSceneGameObject = Resources.Load <GameObject>(strPrefabePath);

            if (newSceneGameObject != null)
            {
                newSceneGameObject = UIUtils.AddChild(this.gameObject, newSceneGameObject);
                if (newSceneGameObject != null)
                {
                    dialog = newSceneGameObject.GetComponent <UIDialogBase>();
                    if (dialog == null)
                    {
                        newSceneGameObject.name = newSceneGameObject.name.Replace("(Clone)", "");
                        dialog = PPPUIBase.addScript(newSceneGameObject, newSceneGameObject.name) as UIDialogBase;
                    }

                    if (dialog != null)
                    {
                        dialog.name = strPrefabePath;
                        dialog.InitializeScene();
                    }
                }
                else
                {
                    PPP.pppShow(true, "UISystem::LoadDialog() Failed to add new scene to parent UISystem with name: " + strPrefabePath);
                }
            }
            else
            {
                PPP.pppShow(true, "UISystem::LoadDialog() Failed to load new scene with name: " + strPrefabePath);
            }
        }

        return(dialog);
    }
Beispiel #8
0
    public UIDialogBase LoadScene(UIDialog key)
    {
        UIDialogBase dialog = FindInCache(key);

        if (dialog == null)
        {
            string     strPrefabeName     = Utils.GetEnumDes(key);
            GameObject newSceneGameObject = Resources.Load(strPrefabeName) as GameObject;

            if (newSceneGameObject != null)
            {
                newSceneGameObject = UIUtils.AddChild(this.gameObject, newSceneGameObject);
                if (newSceneGameObject.activeSelf == true)
                {
                    Debug.Log("newSceneGameObject activity true:" + newSceneGameObject.name);
                }
                else
                {
                    Debug.Log("newSceneGameObject activity false:" + newSceneGameObject.name);
                }
                if (newSceneGameObject != null)
                {
                    dialog = newSceneGameObject.GetComponent <UIDialogBase>();
                    dialog.InitializeScene();
                }
                else
                {
                    Debug.LogWarning("UISystem::LoadDialog() Failed to add new scene to parent UISystem with name: " + key);
                }
            }
            else
            {
                Debug.LogWarning("UISystem::LoadDialog() Failed to load new scene with name: " + key);
            }
        }

        return(dialog);
    }
Beispiel #9
0
 public GameObject AddChild(MonoBehaviour parent, MonoBehaviour prefab)
 {
     return(UIUtils.AddChild(parent, prefab));
 }
Beispiel #10
0
    /* Load the scene and return the instanced scene. Now by name! */
    public UISceneBase LoadScene(UIPage page, bool hideScene = false)
    {
        // Find the scene in the loaded list
        for (int idx = 0; idx < LoadedScenes.Count; idx++)
        {
            // NEW: find by name instead of enum
            if (LoadedScenes[idx] != null &&
                LoadedScenes[idx].Page == page)
            {
                return(LoadedScenes[idx]);
            }
        }

        if (page != UIPage.Null)
        {
            string     strPrefabeName     = GetEnumDes(page);
            GameObject newSceneGameObject = Resources.Load(strPrefabeName) as GameObject;

            if (newSceneGameObject != null)
            {
                newSceneGameObject = UIUtils.AddChild(this.gameObject, newSceneGameObject);
                if (newSceneGameObject.activeSelf == true)
                {
                    Debug.Log("newSceneGameObject activity true:" + newSceneGameObject.name);
                }
                else
                {
                    Debug.Log("newSceneGameObject activity false:" + newSceneGameObject.name);
                }
                if (newSceneGameObject != null)
                {
                    UISceneBase newScene = newSceneGameObject.GetComponent <UISceneBase>();

                    if (newScene != null)
                    {
                        newScene.Page = page;

                        LoadedScenes.Add(newScene);
                        // Allow the scene to initialize itself
                        newScene.InitializeScene();

                        // Hide the scene if requested
                        if (hideScene == true)
                        {
                            newScene.HideScene();
                        }

                        return(newScene);
                    }
                    else
                    {
                        Debug.LogWarning("UISystem::LoadScene() Failed to instance new scene with name: " + page);
                    }
                }
                else
                {
                    Debug.LogWarning("UISystem::LoadScene() Failed to add new scene to parent UISystem with name: " + page);
                }
            }
            else
            {
                Debug.LogWarning("UISystem::LoadScene() Failed to load new scene with name: " + page);
            }
        }
        else
        {
            Debug.LogWarning("UISystem::LoadScene() No Scene Data for scene with name: " + page);
        }

        return(null);
    }
Beispiel #11
0
        public void LoadPage(string page, System.Action <UIPageBase> func, bool hidePage = false)
        {
            for (int idx = 0; idx < LoadedPages.Count; idx++)
            {
                if (LoadedPages[idx] != null &&
                    LoadedPages[idx].name == page)
                {
                    func(LoadedPages[idx]);
                }
            }

            if (!string.IsNullOrEmpty(page))
            {
                string assetName = page + "Page";
                string abName    = AppConst.ResDir + "Prefabs/UI/Page/" + assetName + ".prefab";
                ResManager.LoadPrefab(abName, delegate(UnityEngine.Object[] objs)
                {
                    if (objs.Length == 0)
                    {
                        return;
                    }
                    GameObject newPageGameObject = objs[0] as GameObject;
                    if (newPageGameObject != null)
                    {
                        newPageGameObject = UIUtils.AddChild(PageRoot, newPageGameObject);
                        if (newPageGameObject.activeSelf == true)
                        {
                            Debug.Log("newPageGameObject activity true:" + newPageGameObject.name);
                        }
                        else
                        {
                            Debug.Log("newPageGameObject activity false:" + newPageGameObject.name);
                        }
                        if (newPageGameObject != null)
                        {
                            UIPageBase newPage = newPageGameObject.GetComponent <UIPageBase>();

                            if (newPage != null)
                            {
                                LoadedPages.Add(newPage);
                                // Allow the Page to initialize itself
                                newPage.InitializePage();

                                // Hide the Page if requested
                                if (hidePage == true)
                                {
                                    newPage.HidePage();
                                }

                                func(newPage);
                            }
                            else
                            {
                                Debug.LogWarning("UISystem::LoadPage() Failed to instance new Page with name: " + page);
                            }
                        }
                        else
                        {
                            Debug.LogWarning("UISystem::LoadPage() Failed to add new Page to parent UISystem with name: " + page);
                        }
                    }
                    else
                    {
                        Debug.LogWarning("UISystem::LoadPage() Failed to load new Page with name: " + page);
                    }
                });
            }
            else
            {
                Debug.LogWarning("UISystem::LoadPage() No Page Data for Page with name: " + page);
            }
        }