Ejemplo n.º 1
0
    void Update()
    {
        if (_charge > 0.0f)
        {
            const float MARGIN = 20;

            GUITexture guiTexture = gameObject.guiTexture;
            if (guiTexture != null)
            {
                if (_chargeGuiTexture == null)
                {
                    _chargeGuiTexture = (GUITexture)GUITexture.Instantiate(guiTexture);

                    GUIText[] childArray = _chargeGuiTexture.GetComponentsInChildren <GUIText>();
                    foreach (GUIText child in childArray)
                    {
                        GameObject.Destroy(child);
                    }

                    Vector3 pos = _chargeGuiTexture.transform.position;
                    pos.z = 2.0f;
                    _chargeGuiTexture.transform.position = pos;

                    Color color = _chargeGuiTexture.color;
                    _chargeGuiTexture.color = _chargeTextureColor;

                    Rect pixelInset = _chargeGuiTexture.pixelInset;
                    pixelInset.x                += MARGIN;
                    pixelInset.y                += MARGIN;
                    pixelInset.width            -= (MARGIN * 2);
                    pixelInset.height           -= (MARGIN * 2);
                    _chargeGuiTexture.pixelInset = pixelInset;

                    if (_chargeTexture != null)
                    {
                        _chargeGuiTexture.texture = _chargeTexture;
                    }
                }
                _chargeGuiTexture.enabled = true;

                Rect currentInset = _chargeGuiTexture.pixelInset;
                currentInset.width           = Mathf.Lerp(0.0f, guiTexture.pixelInset.width - (MARGIN * 2), _charge);
                _chargeGuiTexture.pixelInset = currentInset;
            }
        }
        else
        {
            if (_chargeGuiTexture != null)
            {
                _chargeGuiTexture.enabled = false;
            }
        }
    }
Ejemplo n.º 2
0
 private void SetArrows()
 {
     Arrow[] test = m_GUITexture.GetComponentsInChildren <Arrow> ();
     if (m_Page == 0)
     {
         test[0].SetLeft();
         test[1].SetLeft();
     }
     else if (m_Page == m_Textures.Length - 1)
     {
         test[0].SetRight();
         test[1].SetRight();
     }
     else
     {
         test[0].SetMiddle();
         test[1].SetMiddle();
     }
 }