public static UIHUD Create(StructUIHUD uihuid, Transform parent) { // 实例化 GameObject go = Instantiate(Resources.Load <GameObject>(prefabPath)) as GameObject; UIHUD monster = go.GetComponent <UIHUD>(); monster.Init(uihuid, parent); return(monster); }
void Init(StructUIHUD uihuid, Transform parent) { if (uihuid.FollowObject == null) { Debug.LogError("followObj==null"); Destroy(gameObject); return; } if (parent == null) { Debug.LogError("parent is null"); return; } MyStructUIHUD = uihuid; _followedTarget = MyStructUIHUD.FollowObject.transform; transform.parent = parent; transform.localPosition = Vector3.zero; transform.localRotation = Quaternion.identity; transform.localScale = Vector3.one; // 摄像机 _gameCamera = NGUITools.FindCameraForLayer(MyStructUIHUD.FollowObject.layer); _uiCamera = NGUITools.FindCameraForLayer(parent.gameObject.layer); //设置当前hp进度条 OnEventHPChange(MyStructUIHUD.CurHP, MyStructUIHUD.MaxHP); //设置名字 SetName(MyStructUIHUD); //名字颜色 SetNameColor(MyStructUIHUD.NameColor); //hp刻度条 BaseHPScale = BaseHPScale == 0 ? (int)uihuid.MaxHP / UIHUD.Param_min : BaseHPScale; SetHPScale(BaseHPScale, (int)uihuid.MaxHP); //类型标识 SetHeroFeature(uihuid); _mpBar.gameObject.SetActive(MyStructUIHUD.IsActiveMP); }
/// <summary> /// 设置英雄特性标志 /// </summary> /// <param name="uihuid"></param> void SetHeroFeature(StructUIHUD uihuid) { }
public void SetName(StructUIHUD value) { _actorName.gameObject.SetActive(value.IsActiveActorName); _actorName.text = value.ActorName; }