//TODO/NOTE the way I handle this, it wont work withscaling because I'm reading base scale from BaseDimension... public override void update_parameters(float aDeltaTime) { mCurrentPercentage = mCurrentPercentage * (1 - SoftInterpolation) + mPercentage * (SoftInterpolation); //TODO the right way to do this is to use SoftColor to cache the desired color //and actually set it over here blending against the meter color. //SoftColor = (new Color(0.5f, 0, 0, 0.2f))*mCurrentPercentage + (new Color(0,0,0.5f,0.2f))*(1-mCurrentPercentage); //hack //base.SoftColor = new Color32(0/2, 81/2, 229/2,(int)(.8*255/2f)); if (Style == FillStyle.DU) { Material m = PrimaryGameObject.GetComponentInChildren <Renderer>().material; m.mainTextureScale = new Vector2(1f, mCurrentPercentage); //m.mainTextureOffset = new Vector2(0, mCurrentPercentage == 0 ? 0 : 1/mCurrentPercentage); m.mainTextureOffset = new Vector2(0, 0); //float scaleX = Mathf.Cos(Time.time) * 0.5F + 1; //float scaleY = Mathf.Sin(Time.time) * 0.5F + 1; //PrimaryGameObject.GetComponentInChildren<Renderer>().material.mainTextureScale = new Vector2(scaleX, scaleY); Vector2 dim = mImage.PixelDimension; dim.y = mImage.BaseDimension.y * mCurrentPercentage; mImage.PixelDimension = dim; } else { throw new UnityException("Peter was too lazy to implement this fill style"); } this.SoftInterpolation = 1; base.update_parameters(aDeltaTime); }
public virtual void set_color(Color aColor) { if (PrimaryGameObject != null) { foreach (Renderer e in PrimaryGameObject.GetComponentsInChildren <Renderer>()) { try { e.material.SetColor("_TintColor", aColor); } catch { } try { e.material.color = aColor; } catch { } } /* * Renderer rend = PrimaryGameObject.GetComponentInChildren<Renderer>(); * if (rend != null) * { * try { rend.material.SetColor("_TintColor", aColor); } * catch { } * try { rend.material.color = aColor; } * catch { } * }*/ } }