示例#1
0
        public HUDText ShowText(string text, Vector3 pos, string configId, Sprite image, bool isPlayEndHide = true)
        {
            if (!isInit)
            {
                Init();
            }
            if (string.IsNullOrEmpty(text) || AppConst.GlobalCahce.Main3DCamera == null || !AppConst.GlobalCahce.Main3DCamera.enabled)
            {
                return(null);
            }

            MotionTextModel model = null;

            configId = path + configId;
            if (!motionTextModels.TryGetValue(configId, out model))
            {
                model = Resources.Load <MotionTextModel>(configId);
                motionTextModels.Add(configId, model);
            }

            if (model != null)
            {
                var hudtext = _HudTextPool.Get() as GameObject;
                if (hudtext != null)
                {
                    var hudTextComp = hudtext.GetComponent <HUDText>();
                    if (hudTextComp != null)
                    {
                        hudTextComp.FollowGameObject = null;
                        hudTextComp.IsFollow         = false;
                        hudTextComp.IsPlayEndHide    = isPlayEndHide;
                        hudTextComp.RectTrans.SetParent(
                            model.isOnTopLayer ? AppConst.GlobalCahce.PanelHUD.GetChild(1) : AppConst.GlobalCahce.PanelHUD.GetChild(0), false);
                        pos.x += Random.Range(-model.randomNum, model.randomNum);
                        pos.y += Random.Range(-model.randomNum, model.randomNum);
                        pos.z += Random.Range(-model.randomNum, model.randomNum);
                        pos.x += model.offect.x;
                        pos.y += model.offect.y;
                        pos.z += model.offect.z;
                        hudTextComp.StartPos = pos;
                        Vector3 uipos = TranslatePosToUIPos(pos);
                        hudTextComp.Show(text, uipos, model);
                        currentShowHudTexts.Add(hudTextComp);
                        return(hudTextComp);
                    }
                }
            }
            return(null);
        }
示例#2
0
 private void OnGUI()
 {
     if (GUILayout.Button("Active Object(Sphere)"))
     {
         UnityObjectPool pool = PoolManager.Instance.GetPool("Sphere");
         GameObject      go   = pool.Get();
         go.SetActive(true);
     }
     if (GUILayout.Button("Active Object(Cube)"))
     {
         UnityObjectPool pool = PoolManager.Instance.GetPool("Cube");
         GameObject      go   = pool.Get();
         go.SetActive(true);
         Timer.Startup(3, (t) => {
             pool.Recycle(go);
         });
     }
     if (GUILayout.Button("Active Object(Capsule)"))
     {
         UnityObjectPool pool = PoolManager.Instance.GetPool("Capsule");
         GameObject      go   = pool.Get();
         go.SetActive(true);
         Timer.Startup(3, (t) => {
             pool.Recycle(go);
         });
     }
     if (GUILayout.Button("Release Pool(Group:NoCapsule)"))
     {
         PoolManager.Instance.ReleasePoolsByGroup("NoCapsule", true);
     }
     if (GUILayout.Button("Release Pool(Group:Default)"))
     {
         PoolManager.Instance.ReleasePoolsByDefaultGroup();
     }
 }
示例#3
0
    public void ShowText(string text, Vector3 pos, int configId)
    {
        if (string.IsNullOrEmpty(text) || Main.Main3DCamera == null || !Main.Main3DCamera.enabled)
        {
            return;
        }

        var configs = FontConfigFiles;

        if (EntryPoint.Instance.GetUserLanguageCode() == "KR")
        {
            configs = KRFontConfigFiles;
        }

        if (configs == null || configId >= configs.Length || configId < 0)
        {
            Common.HobaDebuger.LogWarningFormat("HUD Text Config id is wrong");
            return;
        }

        GBMFontAndMotionTextModel model = null;

        if (!_ModelCache.TryGetValue(configId, out model))
        {
            model = Resources.Load <GBMFontAndMotionTextModel>(configs[configId]);
            _ModelCache.Add(configId, model);
        }

        if (model != null)
        {
            var hudtext = _HudTextPool.Get() as GameObject;
            //hudtext.SetActive(true);
            var hudTextComp = hudtext.GetComponent <HUDText>();
            if (hudTextComp != null)
            {
                if (model._IsOnTopLayer)
                {
                    hudTextComp.RectTrans.SetParent(transform.GetChild(1), false);
                }
                else
                {
                    hudTextComp.RectTrans.SetParent(transform.GetChild(0), false);
                }

                pos.x += UnityEngine.Random.Range(-model._XRandomNum, model._XRandomNum);
                pos.y += UnityEngine.Random.Range(-model._XRandomNum, model._XRandomNum);
                pos.z += UnityEngine.Random.Range(-model._XRandomNum, model._XRandomNum);

                Vector3 uipos = TranslatePosToUIPos(pos);

                //Debug.LogWarning("uipos " + uipos);
                hudTextComp.Show(text, uipos, model);
            }
        }
    }