示例#1
0
 protected void SetVector3Value(Vector3 val)
 {
     _ignoreChanges = true;
     if (_v3property != null)
     {
         _v3property.SetValue(val);
     }
     if (_v2property != null)
     {
         _v2property.SetValue(new Vector2(val.x, val.y));
     }
     if (_transformProperty != null && _transformProperty.GetValue() != null)
     {
         _transformProperty.GetValue().position = val;
     }
     if (_componentProperty != null && _componentProperty.GetValue() != null)
     {
         _componentProperty.GetValue().transform.position = val;
     }
     if (_gameObjectProperty != null && _gameObjectProperty.GetValue() != null)
     {
         _gameObjectProperty.GetValue().transform.position = val;
     }
     _ignoreChanges = false;
 }
示例#2
0
    protected override void OnChange()
    {
        base.OnChange();

        if (_uiTexture && _shader != null && _shader.GetValue() != null)
        {
            _uiTexture.shader = _shader.GetValue();
        }
    }
示例#3
0
    protected override void OnChange()
    {
        base.OnChange();

        if (_clip == null)
        {
            _animation.Stop();
        }
        else if (!string.IsNullOrEmpty(_clip.GetValue()))
        {
            _animation.Play(_clip.GetValue());
        }
    }
示例#4
0
    protected override void OnChange()
    {
        base.OnChange();

        if (_activateProperty != null)
        {
            bool val = _activateProperty.GetValue();

            foreach (var r in _renderers)
            {
                r.gameObject.SetActive(val);
            }

            foreach (var particle in _particles)
            {
                if (val)
                {
                    particle.gameObject.SetActive(val);
                    particle.Play();
                    if (_animation != null)
                    {
                        _animation.Play();
                    }
                }
                else
                {
                    particle.Stop();
                    particle.Clear();
                    particle.gameObject.SetActive(val);
                }
            }
        }
    }
示例#5
0
    protected override void OnChange()
    {
        if (_ignoreChanges)
        {
            return;
        }

        Color newColor = Color.white;

        if (_colorProperty != null)
        {
            newColor = _colorProperty.GetValue();
        }
        else if (_hexProperty != null && !HexToColor(_hexProperty.GetValue(), out newColor))
        {
            return;
        }

        if (_widget != null)
        {
            _widget.color = newColor;
        }

        if (_graphic != null)
        {
            _graphic.color = newColor;
        }

        if (_colorButton != null)
        {
            _colorButton.normal = newColor;
        }
    }
示例#6
0
    private void ApplyVolume()
    {
        var v = _volume * ((_masterVolumeProperty == null) ? 1 : _masterVolumeProperty.GetValue());

        foreach (var s in _audioSources)
        {
            s.volume = v;
        }
    }
示例#7
0
    protected override void OnChange()
    {
        base.OnChange();

        //Debug.Log ("NguiAlpha, CHANGE");

        if (_alpha == null)
        {
            return;
        }

        if (_canvasGroup != null)
        {
            //Debug.Log ("NguiAlpha, On change");
            _canvasGroup.alpha = _alpha.GetValue();
        }
        else if (_image != null)
        {
            _image.CrossFadeAlpha(_alpha.GetValue(), 0, true);
        }
    }
示例#8
0
    protected override void OnChange()
    {
        base.OnChange();

        //Debug.Log ("NguiAlpha, CHANGE");

        if (_canvasGroup != null && _alpha != null)
        {
            //Debug.Log ("NguiAlpha, On change");
            _canvasGroup.alpha = _alpha.GetValue();
        }
    }
示例#9
0
    protected override void OnChange()
    {
        base.OnChange();

        if (_grayscale == null)
        {
            return;
        }

        foreach (var sprite in _sprites)
        {
            ApplyNewValue(sprite, _grayscale.GetValue());
        }

        if (scanTexts)
        {
            foreach (var text in _texts)
            {
                ApplyNewValue(text, _grayscale.GetValue());
            }
        }
    }
示例#10
0
    protected Vector3 GetVector3Value()
    {
        if (_v3property != null)
        {
            return(_v3property.GetValue());
        }

        if (_v2property != null)
        {
            var v2 = _v2property.GetValue();
            return(new Vector3(v2.x, v2.y, 0));
        }

        if (_t2property != null)
        {
            var t2 = _t2property.GetValue();
            return(new Vector3(t2.width, t2.height, 0));
        }

        if (_transformProperty != null)
        {
            var t = _transformProperty.GetValue();
            if (t != null)
            {
                return(t.position);
            }
        }

        if (_componentProperty != null)
        {
            var c = _componentProperty.GetValue();
            if (c != null)
            {
                return(c.transform.position);
            }
        }

        if (_gameObjectProperty != null)
        {
            var go = _gameObjectProperty.GetValue();
            if (go != null)
            {
                return(go.transform.position);
            }
        }

        return(Vector3.zero);
    }
    protected override void OnChange()
    {
        base.OnChange();

        if (_activateProperty != null)
        {
            bool val = _activateProperty.GetValue();

            foreach (var particle in _particles)
            {
                if (val)
                {
                    particle.Play();
                }
                else
                {
                    particle.Stop();
                    particle.Clear();
                }
            }
        }
    }
示例#12
0
    protected override void OnChange()
    {
        base.OnChange();

        var aspect = (height == 0) ? 1 : (width / height);

        var imageWidth  = width;
        var imageHeight = height;

        if (_texture != null && _texture.GetValue() != null)
        {
            imageWidth  = _texture.GetValue().width;
            imageHeight = _texture.GetValue().height;
        }

        var imageAspect = (imageHeight == 0) ? 1 : (imageWidth / imageHeight);

        var spriteWidth  = 0.0f;
        var spriteHeight = 0.0f;

        if (_texture != null && _texture.GetValue() != null)
        {
            switch (alignment)
            {
            case ALIGNMENT.STRETCH:
                spriteWidth  = width;
                spriteHeight = height;
                break;

            case ALIGNMENT.UNIFORM_STRETCH:
                if ((aspect > imageAspect) ^ stretchOutside)
                {
                    spriteHeight = height;
                    spriteWidth  = (imageHeight == 0) ? 0 : (imageWidth * spriteHeight / imageHeight);
                }
                else
                {
                    spriteWidth  = width;
                    spriteHeight = (imageWidth == 0) ? 0 : (imageHeight * spriteWidth / imageWidth);
                }
                break;

            case ALIGNMENT.SOURCE_SIZE:
                spriteWidth  = imageWidth;
                spriteHeight = imageHeight;
                break;
            }
        }

        spriteWidth  = Mathf.Max(spriteWidth, 0.001f);
        spriteHeight = Mathf.Max(spriteHeight, 0.001f);

        if (_uiTexture != null)
        {
            if (_texture != null)
            {
#if NGUI_2
                _uiTexture.material.mainTexture = _texture.GetValue();
#else
                _uiTexture.mainTexture = _texture.GetValue();
#endif
            }
            if (alignment != ALIGNMENT.NONE)
            {
#if NGUI_2
                _uiTexture.transform.localScale = new Vector3(spriteWidth, spriteHeight, 1);
#else
                _uiTexture.width  = (int)spriteWidth;
                _uiTexture.height = (int)spriteHeight;
#endif
            }
        }
    }
示例#13
0
    protected override void OnChange()
    {
        base.OnChange();

        var aspect = (height == 0) ? 1 : (width / height);

        var imageWidth  = width;
        var imageHeight = height;

        if (_texture != null && _texture.GetValue() != null)
        {
            imageWidth  = _texture.GetValue().width;
            imageHeight = _texture.GetValue().height;
        }

        var imageAspect = (imageHeight == 0) ? 1 : (imageWidth / imageHeight);

        var spriteWidth  = 0.0f;
        var spriteHeight = 0.0f;

        if (_texture != null && _texture.GetValue() != null)
        {
            switch (alignment)
            {
            case ALIGNMENT.STRETCH:
                spriteWidth  = width;
                spriteHeight = height;
                break;

            case ALIGNMENT.UNIFORM_STRETCH:
                if ((aspect > imageAspect) ^ stretchOutside)
                {
                    spriteHeight = height;
                    spriteWidth  = (imageHeight == 0) ? 0 : (imageWidth * spriteHeight / imageHeight);
                }
                else
                {
                    spriteWidth  = width;
                    spriteHeight = (imageWidth == 0) ? 0 : (imageHeight * spriteWidth / imageWidth);
                }
                break;

            case ALIGNMENT.SOURCE_SIZE:
                spriteWidth  = imageWidth;
                spriteHeight = imageHeight;
                break;
            }
        }

        spriteWidth  = Mathf.Max(spriteWidth, 0.001f);
        spriteHeight = Mathf.Max(spriteHeight, 0.001f);

        if (_uiTexture != null)
        {
            if (_texture != null)
            {
                _uiTexture.mainTexture = _texture.GetValue();
            }
            if (alignment != ALIGNMENT.NONE)
            {
                _uiTexture.width  = (int)spriteWidth;
                _uiTexture.height = (int)spriteHeight;
            }
        }

        if (_rawImage != null)
        {
            if (_texture != null)
            {
                _rawImage.texture = _texture.GetValue();
                if (_texture.GetValue() != null)
                {
                    _rawImage.color = new Color(_rawImage.color.r, _rawImage.color.g, _rawImage.color.b, 1);
                }
                else
                {
                    _rawImage.color = new Color(_rawImage.color.r, _rawImage.color.g, _rawImage.color.b, 0);
                }
            }
            else
            {
                _rawImage.color = new Color(_rawImage.color.r, _rawImage.color.g, _rawImage.color.b, 0);
            }
            if (alignment != ALIGNMENT.NONE)
            {
                _rawImage.rectTransform.sizeDelta = new Vector2(spriteWidth, spriteHeight);
            }
        }



        if (_texture != null && _texture.GetValue() == null && _prevTexture != null)
        {
            _prevTexture = null;
            if (_uiTexture != null)
            {
                _uiTexture.mainTexture = null;
            }
            if (_rawImage != null)
            {
                _rawImage.texture = null;
            }
        }

        if (_texture != null)
        {
            _prevTexture = _texture.GetValue();
        }

        if (hideIfEmpty)
        {
            if (_uiTexture != null && _texture != null)
            {
                Debug.Log(_texture.GetValue());
            }
            _uiTexture.enabled = _texture.GetValue() != null;
        }
    }