private void Start() { _valueCurrent = 1.0f; _valueActual = _valueCurrent; _bar = EnergyBarQuadrant.Create(this); _bar.SetSize(barSize.x, barSize.y); _bar.SetBarType(barType); _bar.SetColor(barColor); _bar.name = "Energy Bar Quadrant"; _bar.value = defaultValue; _bar.enabled = isActiveAndEnabled; _burnOffBar = _bar.Clone(this); _burnOffBar.name = "Burn Off Bar Quadrant"; _burnOffBar.SetColor(burnOffColor); _burnOffBar.value = 0.0f; _burnOnBar = _bar.Clone(this); _burnOnBar.name = "Burn On Bar Quadrant"; _burnOnBar.SetColor(burnOnColor); _burnOnBar.value = 0.0f; _posXMin = _bar.transform.localPosition.x; _posXMax = _bar.transform.localPosition.x + barSize.x; }
public EnergyBarQuadrant Clone(EnergyBar parent) { EnergyBarQuadrant clone = Create(parent); clone.SetSize(_imageTransform.rect.size); clone.SetBarType(_barType); clone.SetColor(_image.color); return(clone); }
static public EnergyBarQuadrant Create(EnergyBar parent) { GameObject quadrantObject = new GameObject("EnergyBarQuadrant"); quadrantObject.transform.parent = parent.transform; quadrantObject.transform.localPosition = Vector3.zero; quadrantObject.transform.localScale = Vector3.one; GameObject imageObject = new GameObject("Bar"); imageObject.AddComponent <Image>(); imageObject.transform.SetParent(quadrantObject.transform); imageObject.transform.localPosition = Vector3.zero; imageObject.transform.localScale = Vector3.one; EnergyBarQuadrant quadrant = quadrantObject.AddComponent <EnergyBarQuadrant>(); quadrant.Init(parent); quadrant.SetSize(100.0f, 20.0f); quadrant.SetBarType(EnergyBar.BarType.LeftToRight); quadrant.SetColor(Color.white); return(quadrant); }