void Awake() { cam = Camera.main; cameraTransform = cam.transform; for (int i = 0; i < transform.childCount; i++) { healthBars.Add(transform.GetChild(i)); } _Instance = this; if (prefab == null) { prefab = (GameObject)Resources.Load("Prefabs/FloatingDamage"); } if (_config == null) { _config = (FloatBarConfig)Resources.Load("FloatBarConfig"); } config = _config; poolTrans = _CreateTrans("HealthbarPool"); showTrans = _CreateTrans("HealthbarRoot"); }
void Awake() { config = FloatBarManager.config; if (healthVolume == null) { healthVolume = transform.Find("Health").GetComponent <Image>(); } if (backGround == null) { backGround = transform.Find("Background").GetComponent <Image>(); } if (healthInfo == null) { healthInfo = transform.Find("HealthInfo").GetComponent <Text>(); } rectTransform = GetComponent <RectTransform>(); canvasGroup = GetComponent <CanvasGroup>(); healInfoRectTrans = healthInfo.rectTransform; healthInfo.resizeTextForBestFit = true; healInfoRectTrans.anchoredPosition = Vector2.zero; healthInfo.resizeTextMinSize = 1; healthInfo.resizeTextMaxSize = 500; healthInfoPosition = healthInfo.rectTransform.anchoredPosition; rawSizeDelta = rectTransform.sizeDelta; canvasGroup.alpha = config.fullAlpha; canvasGroup.interactable = false; canvasGroup.blocksRaycasts = false; if (healthInfoAlignment == HealthInfoAlignment.Top) { healInfoRectTrans.anchoredPosition = healthInfoPosition; } else if (healthInfoAlignment == HealthInfoAlignment.Center) { healInfoRectTrans.anchoredPosition = Vector2.zero; } else { healInfoRectTrans.anchoredPosition = -healthInfoPosition; } }