コード例 #1
0
        //--------------------------------------------------------------------------------------------------
        // PUBLIC



        //--------------------------------------------------------------------------------------------------
        // PRIVATE

        private void UpdatePropertyBlock()
        {
            if (psr == null)
            {
                psr = this.GetComponent <ParticleSystemRenderer>();
            }
            if (psr != null)
            {
                MaterialPropertyBlock mpb = new MaterialPropertyBlock();
                psr.GetPropertyBlock(mpb);
                mpb.SetFloat("_InvFade", SoftParticleFactor);
                psr.SetPropertyBlock(mpb);
            }
        }
コード例 #2
0
    private void OnEnable()
    {
        m_Particle = GetComponent <ParticleSystemRenderer>();
        m_Particle.GetPropertyBlock(m_PropertyBlock);

        m_PropertyBlock.SetTexture("_MainTex", particleTexture);

        m_Particle.SetPropertyBlock(m_PropertyBlock);
    }
コード例 #3
0
 public void FixedUpdate()
 {
     if (effects)
     {
         float t = Mathf.Clamp01((float)remainingTime / (float)(lockTime - minFadeTime));
         effects.GetComponentInChildren <Light>().intensity = initialLightIntensity * t;
         ParticleSystem.MainModule main = effects.GetComponentInChildren <ParticleSystem>().main;
         ParticleSystemRenderer    particleSystemRenderer = effects.GetComponentInChildren <ParticleSystemRenderer>();
         particleSystemRenderer.GetPropertyBlock(materialPropertyBlock);
         materialPropertyBlock.SetColor("_TintColor", Color.Lerp(Color.black, initialColor, t));
         particleSystemRenderer.SetPropertyBlock(materialPropertyBlock);
     }
 }
コード例 #4
0
        private void Apply()
        {
            //IL_0018: Unknown result type (might be due to invalid IL or missing references)
            //IL_001e: Expected O, but got Unknown
            ParticleSystemRenderer component = this.GetComponent <ParticleSystemRenderer>();
            Material trailMaterial           = component.get_trailMaterial();

            if (!(null == trailMaterial))
            {
                MaterialPropertyBlock val = new MaterialPropertyBlock();
                component.GetPropertyBlock(val, 1);
                val.SetTexture(s_mainTexId, trailMaterial.get_mainTexture());
                component.SetPropertyBlock(val, 1);
            }
        }
コード例 #5
0
        /// <summary>
        /// Copy the value from MaterialPropertyBlock to CanvasRenderer (#41)
        /// </summary>
        void UpdateAnimatableMaterialProperties()
        {
#if UNITY_EDITOR
            if (!Application.isPlaying)
            {
                return;
            }
#endif
            if (0 == m_AnimatableProperties.Length)
            {
                return;
            }

            _renderer.GetPropertyBlock(s_Mpb);
            for (int i = 0; i < canvasRenderer.materialCount; i++)
            {
                var mat = canvasRenderer.GetMaterial(i);
                foreach (var ap in m_AnimatableProperties)
                {
                    switch (ap.type)
                    {
                    case ShaderPropertyType.Color:
                        mat.SetColor(ap.id, s_Mpb.GetColor(ap.id));
                        break;

                    case ShaderPropertyType.Vector:
                        mat.SetVector(ap.id, s_Mpb.GetVector(ap.id));
                        break;

                    case ShaderPropertyType.Float:
                    case ShaderPropertyType.Range:
                        mat.SetFloat(ap.id, s_Mpb.GetFloat(ap.id));
                        break;

                    case ShaderPropertyType.Texture:
                        mat.SetTexture(ap.id, s_Mpb.GetTexture(ap.id));
                        break;
                    }
                }
            }
        }