コード例 #1
0
    /// <summary>
    /// 初始化NPC头顶血条
    /// </summary>
    private void InitHeadBar()
    {
        if (RoleHeadBarRoot.Instance == null)
        {
            return;
        }

        if (m_CurrNPCEntity == null)
        {
            return;
        }

        if (m_HeadBarPos == null)
        {
            return;
        }

        //开始克隆预设
        m_HeadBar = ResourcesMgr.Instance.Load(ResourcesMgr.ResourceType.UIOther, "NPCHeadBar");

        m_HeadBar.transform.parent = RoleHeadBarRoot.Instance.gameObject.transform;

        m_HeadBar.transform.localScale = Vector3.one;

        m_npcHeadBarView = m_HeadBar.GetComponent <NPCHeadBarView>();

        m_npcHeadBarView.Init(m_HeadBarPos, m_CurrNPCEntity.Name);
    }
コード例 #2
0
    /// <summary>
    /// 初始化头顶UI条
    /// </summary>
    private void InitHeadBar()
    {
        if (RoleHeadBarRoot.Instance == null)
        {
            return;
        }
        //克隆预设
        m_HeadBar = ResourcesManager.Instance.Load(ResourcesManager.ResourceType.UIOther, "NPCHeadBar");
        m_HeadBar.transform.SetParent(RoleHeadBarRoot.Instance.gameObject.transform);
        m_HeadBar.transform.localScale = Vector3.one;


        NPCHeadBarView npcHeadBarView = m_HeadBar.GetComponent <NPCHeadBarView>();

        //给预设赋值
        npcHeadBarView.Init(m_HeadBarTrans, m_CurrNPCDataEntity);
    }
コード例 #3
0
    /// <summary>
    /// 克隆头顶UI的prefab,然后给prefab赋值
    /// </summary>
    public void InitRoleHeadUI()
    {
        if (NPCHeadUI != null)
        {
            Debug.Log("NPC head已生成!");
            return;
        }
        if (UIRoleHeadItems.Instance != null && modelHeadPoint != null)
        {
            //克隆部分
            NPCHeadUI = ResourcesManager.Instance.Load(ResourcesManager.ResourceType.UIOTHER, "NPCHeadUGUI");
            NPCHeadUI.transform.parent        = UIRoleHeadItems.Instance.gameObject.transform;
            NPCHeadUI.transform.localScale    = Vector3.one;
            NPCHeadUI.transform.localPosition = Vector3.zero;
            headBar = NPCHeadUI.GetComponent <NPCHeadBarView>();

            headBar.Init(modelHeadPoint, NPCName);
        }
    }