コード例 #1
0
ファイル: EPate.cs プロジェクト: Tunging/ColaFrameWork
 public EPateBase(GameObject prefab, GameObject attachTarget, EPateColor color, float offsetH)
 {
     pateObj        = CommonHelper.InstantiateGoByPrefab(prefab, null);
     this.pateColor = color;
     AttachTarget(attachTarget, offsetH);
     HUDComponent = this.pateObj.GetComponent <UGUIHUDFollowTarget>();
 }
コード例 #2
0
    public GameObject CreateFromCache <T>(GameObject targetObj, GameObject prefab, float offsetH = 0, bool isVisible = true) where T : EPateBase
    {
        var                 cacheRoot = GetCacheRoot(typeof(T));
        GameObject          pate      = null;
        UGUIHUDFollowTarget hudFollow = null;

        if (null != cacheRoot)
        {
            if (cacheRoot.ChildCount() > 0)
            {
                var hudObj = cacheRoot.GetChild(0); //每次取栈顶
                hudFollow        = hudObj.GetComponent <UGUIHUDFollowTarget>();
                hudFollow.target = targetObj.transform;
                hudFollow.offset = new Vector3(0, offsetH, 0);
                var root = CommonHelper.GetUIMgr().GetHUDTopBoardRoot();
                hudObj.transform.SetParent(root.transform, false);
                pate = hudObj.FindChildByPath("pate");
            }
            else
            {
                pate = CommonHelper.InstantiateGoByPrefab(prefab, null);
                AttachTarget(targetObj, offsetH, pate);
                hudFollow = pate.GetComponent <UGUIHUDFollowTarget>();
            }
            pate.SetActive(true);
            hudFollow.SetVisible(isVisible);
        }

        return(pate);
    }
コード例 #3
0
ファイル: EPate.cs プロジェクト: Tunging/ColaFrameWork
    public virtual void Release()
    {
        this.release = true;
        if (null != pateObj)
        {
            var hud  = this.pateObj.transform.parent;
            var root = EPateCacheMgr.Instance.GetCacheRoot(this.GetType());
            hud.transform.SetParent(root.transform, false);
            hud.gameObject.SetActive(false);
            pateObj = null;
        }

        if (null != HUDComponent)
        {
            HUDComponent.target = null;
            HUDComponent        = null;
        }
    }