using System.Collections; using System.Collections.Generic; using UnityEngine; public class CreatHaemalUI : MonoBehaviour { private GameObject prefabs; public GameObject haemal; private Transform Haemalpanel; // Use this for initialization void Start() { Haemalpanel = GameObject.Find("Canvas").transform.Find("HaemalPanel").transform; //因为指挥中心不在主场景 if (CurrentUserInfo.role!=Role.总队指挥中心&&CurrentUserInfo.role!=Role.支队指挥中心) { prefabs = Resources.Load("Common/BGBlood"); haemal = Instantiate(prefabs, Haemalpanel); haemal.name = gameObject.name; haemal.GetComponent().TargetObj = gameObject; if (GetComponent().gameObjType == CloneObjType.wounded) { haemal.GetComponent().Haemal = 50; } if (GetComponent().gameObjType == CloneObjType.trappedPerson) { haemal.GetComponent().Haemal = 100; } } } // Update is called once per frame void Update() { } public void OnDestroy() { if (haemal != null) { Destroy(haemal); } } public void OnDisable() { if(haemal!=null) { haemal.gameObject.SetActive(false); } } }