Example #1
0
    public int GetPanel(HudType _hudType)
    {
        //find exsit.
        foreach (KeyValuePair <int, HudBase> tempHud in hudDic)
        {
            if (tempHud.Value._type == _hudType)
            {
                return(tempHud.Key);
            }
        }

        int id = InstanceHepler.Get();

        HudBase _hudbase = HudLoader.Instance.Load <HudBase>(_hudType.ToString());

        _hudbase._type = _hudType;

        if (_hudbase != null)
        {
            _hudbase.tran.parent           = tran;
            _hudbase.tran.localPosition    = Vector3.zero;
            _hudbase.tran.localEulerAngles = Vector3.zero;
            _hudbase.tran.localScale       = Vector3.one;

            if (!hudDic.ContainsKey(id))
            {
                hudDic.Add(id, _hudbase);
            }
            else
            {
                Debug.Log("exsit instance id : " + id);
            }
        }
        else
        {
            id = -1;
        }

        return(id);
    }
Example #2
0
 GameObject GetHudPrefab(HudType type)
 {
     return(Resources.Load <GameObject>("Prefabs/Hud/" + type.ToString()));
 }