public void HUD(GameObject target, int count, HUDType hType = HUDType.DamageEnemy, float time = 0f) { string str = (count != 0) ? "" + Mathf.Abs(count) : ""; if (hudDic.ContainsKey(target)) { hudDic[target].Add(str, time, hType); } else { HUDText hudTxt = NGUITools.AddChild(mHudPanel, HUDTextPrefab).GetComponent <HUDText>(); GameObject go = Instantiate(Resources.Load("HUD/HUD Point"), Vector3.zero, Quaternion.identity) as GameObject; go.transform.parent = target.transform; Transform mHitPoint = target.GetComponent <CharacterState>().mHitPoint; go.transform.localPosition = mHitPoint == null ? Vector3.up * 0.5f : mHitPoint.localPosition; hudTxt.GetComponent <UIFollowTarget>().target = go.transform; hudTxt.Add(str, time, hType); hudDic.Add(target, hudTxt); } }
protected virtual void initialize() { GameObject hud = Instantiate(GameController.instance.HUD) as GameObject; hud.transform.parent = Camera.main.transform; hud.transform.localRotation = Quaternion.identity; hud.transform.localScale = new Vector3(1f, 1f, 1f); HUD = hud.GetComponent <HUDText>(); HUD.GetComponent <UIFollowTarget>().target = this.transform; hudHealth = hud.transform.Find("Healthbar").GetComponent <UISlider>(); HUD.transform.Find("Nickname").GetComponent <UILabel>().enabled = false; if (!InputController.instance.showDamages) { HUD.enabled = false; } if (!InputController.instance.showHealthbars) { UISprite foreground = HUD.transform.Find("Healthbar").Find("Foreground").GetComponent <UISprite>(); UISprite background = HUD.transform.Find("Healthbar").Find("Background").GetComponent <UISprite>(); foreground.enabled = false; background.enabled = false; } }
void initHudText() { hudtextGo = HudTextParent._instacne.createHudText(); hudtext = hudtextGo.GetComponent<HUDText>(); followtarget = hudtext.GetComponent<UIFollowTarget>(); followtarget.target = hudtextFollow.transform; followtarget.gameCamera = Camera.main; StartCoroutine(setUIcamera()); }
// Use this for initialization void Start () { cc = this.GetComponent<CharacterController>(); agent = this.GetComponent<NavMeshAgent>(); normal = bodyrender.material.color; hudtextGo = HudTextParent._instacne.createHudText(); hudtext = hudtextGo.GetComponent<HUDText>(); followtarget = hudtext.GetComponent<UIFollowTarget>(); followtarget.target = hudtextFollow.transform; followtarget.gameCamera = Camera.main; cur_animName = animName_Idle; animate_attack_now = animName_Idle; initHpBar(); StartCoroutine(setUIcamera()); }