Inheritance: MonoBehaviour
    public void UpdateMaterial(Transform transformTarget)
    {
        if (transformTarget != null)
        {
            if (!RemoveWhenDisable)
            {
                Destroy(gameObject, RemoveAfterTime);
            }
            fadeInOutShaderColor = GetComponents <FadeInOutShaderColor>();
            fadeInOutShaderFloat = GetComponents <FadeInOutShaderFloat>();
            uvTextureAnimator    = GetComponent <UVTextureAnimator>();
            renderParent         = transform.parent.GetComponent <Renderer>();

            var materials    = renderParent.sharedMaterials;
            var length       = materials.Length + 1;
            var newMaterials = new Material[length];

            materials.CopyTo(newMaterials, 0);
            renderParent.material        = Material;
            instanceMat                  = renderParent.material;
            newMaterials[length - 1]     = instanceMat;
            renderParent.sharedMaterials = newMaterials;

            if (materialQueue != -1)
            {
                instanceMat.renderQueue = materialQueue;
            }

            if (fadeInOutShaderColor != null)
            {
                foreach (var inOutShaderColor in fadeInOutShaderColor)
                {
                    inOutShaderColor.UpdateMaterial(instanceMat);
                }
            }

            if (fadeInOutShaderFloat != null)
            {
                foreach (var inOutShaderFloat in fadeInOutShaderFloat)
                {
                    inOutShaderFloat.UpdateMaterial(instanceMat);
                }
            }

            if (uvTextureAnimator != null)
            {
                uvTextureAnimator.SetInstanceMaterial(instanceMat, Vector2.zero);
            }
        }
    }
示例#2
0
    public void UpdateMaterial(RaycastHit hit)
    {
        Transform transform = hit.get_transform();

        if (transform != null)
        {
            Object.Destroy(base.get_gameObject(), this.RemoveAfterTime);
            this.fadeInOutShaderColor = base.GetComponents <FadeInOutShaderColor>();
            this.fadeInOutShaderFloat = base.GetComponents <FadeInOutShaderFloat>();
            this.uvTextureAnimator    = base.GetComponent <UVTextureAnimator>();
            this.renderParent         = base.get_transform().get_parent().GetComponent <Renderer>();
            Material[] sharedMaterials = this.renderParent.get_sharedMaterials();
            int        num             = sharedMaterials.Length + 1;
            Material[] array           = new Material[num];
            sharedMaterials.CopyTo(array, 0);
            this.renderParent.set_material(this.Material);
            this.instanceMat = this.renderParent.get_material();
            array[num - 1]   = this.instanceMat;
            this.renderParent.set_sharedMaterials(array);
            if (this.UsePointMatrixTransform)
            {
                Matrix4x4 matrix4x = Matrix4x4.TRS(hit.get_transform().InverseTransformPoint(hit.get_point()), Quaternion.Euler(180f, 180f, 0f), this.TransformScale);
                this.instanceMat.SetMatrix("_DecalMatr", matrix4x);
            }
            if (this.materialQueue != -1)
            {
                this.instanceMat.set_renderQueue(this.materialQueue);
            }
            if (this.fadeInOutShaderColor != null)
            {
                for (int i = 0; i < this.fadeInOutShaderColor.Length; i++)
                {
                    this.fadeInOutShaderColor[i].UpdateMaterial(this.instanceMat);
                }
            }
            if (this.fadeInOutShaderFloat != null)
            {
                for (int j = 0; j < this.fadeInOutShaderFloat.Length; j++)
                {
                    this.fadeInOutShaderFloat[j].UpdateMaterial(this.instanceMat);
                }
            }
            if (this.uvTextureAnimator != null)
            {
                this.uvTextureAnimator.SetInstanceMaterial(this.instanceMat, hit.get_textureCoord());
            }
        }
    }
    private IEnumerator UpdateCorutine()
    {
        UVTextureAnimator uVTextureAnimator = null;

        while (uVTextureAnimator.isVisible && (uVTextureAnimator.IsLoop || uVTextureAnimator.allCount != uVTextureAnimator.count))
        {
            uVTextureAnimator.UpdateCorutineFrame();
            if (!uVTextureAnimator.IsLoop && uVTextureAnimator.allCount == uVTextureAnimator.count)
            {
                break;
            }
            yield return(new WaitForSeconds(uVTextureAnimator.deltaFps));
        }
        uVTextureAnimator.isCorutineStarted       = false;
        uVTextureAnimator.currentRenderer.enabled = false;
    }
示例#4
0
    private void AddMaterialObject(RaycastHit hit)
    {
        if (!RemoveWhenDisable)
        {
            ObjectPoolManager.Unspawn(gameObject, RemoveAfterTime);
        }
        fadeInOutShaderColor = GetComponents <FadeInOutShaderColor>();
        fadeInOutShaderFloat = GetComponents <FadeInOutShaderFloat>();
        uvTextureAnimator    = GetComponent <UVTextureAnimator>();
        renderParent         = transform.parent.GetComponentsInChildren <Renderer>();

        foreach (Renderer render in renderParent)
        {
            StartCoroutine(AddAndRemove(render));

            if (UsePointMatrixTransform)
            {
                var m = Matrix4x4.TRS(hit.transform.InverseTransformPoint(hit.point), Quaternion.Euler(180, 180, 0f), TransformScale);
                //m *= transform.localToWorldMatrix;
                instanceMat.SetMatrix("_DecalMatr", m);
            }
            if (materialQueue != -1)
            {
                instanceMat.renderQueue = materialQueue;
            }

            if (fadeInOutShaderColor != null)
            {
                foreach (var inOutShaderColor in fadeInOutShaderColor)
                {
                    inOutShaderColor.UpdateMaterial(instanceMat);
                }
            }

            if (fadeInOutShaderFloat != null)
            {
                foreach (var inOutShaderFloat in fadeInOutShaderFloat)
                {
                    inOutShaderFloat.UpdateMaterial(instanceMat);
                }
            }
            if (uvTextureAnimator != null)
            {
                uvTextureAnimator.SetInstanceMaterial(instanceMat, hit.textureCoord);
            }
        }
    }
    public void UpdateMaterial(Transform transformTarget)
    {
        if (!Object.op_Inequality((Object)transformTarget, (Object)null))
        {
            return;
        }
        if (!this.RemoveWhenDisable)
        {
            Object.Destroy((Object)((Component)this).get_gameObject(), this.RemoveAfterTime);
        }
        this.fadeInOutShaderColor = (FadeInOutShaderColor[])((Component)this).GetComponents <FadeInOutShaderColor>();
        this.fadeInOutShaderFloat = (FadeInOutShaderFloat[])((Component)this).GetComponents <FadeInOutShaderFloat>();
        this.uvTextureAnimator    = (UVTextureAnimator)((Component)this).GetComponent <UVTextureAnimator>();
        this.renderParent         = (Renderer)((Component)((Component)this).get_transform().get_parent()).GetComponent <Renderer>();
        Material[] sharedMaterials = this.renderParent.get_sharedMaterials();
        int        length          = sharedMaterials.Length + 1;

        Material[] materialArray = new Material[length];
        sharedMaterials.CopyTo((Array)materialArray, 0);
        this.renderParent.set_material(this.Material);
        this.instanceMat          = this.renderParent.get_material();
        materialArray[length - 1] = this.instanceMat;
        this.renderParent.set_sharedMaterials(materialArray);
        if (this.materialQueue != -1)
        {
            this.instanceMat.set_renderQueue(this.materialQueue);
        }
        if (this.fadeInOutShaderColor != null)
        {
            foreach (FadeInOutShaderColor inOutShaderColor in this.fadeInOutShaderColor)
            {
                inOutShaderColor.UpdateMaterial(this.instanceMat);
            }
        }
        if (this.fadeInOutShaderFloat != null)
        {
            foreach (FadeInOutShaderFloat inOutShaderFloat in this.fadeInOutShaderFloat)
            {
                inOutShaderFloat.UpdateMaterial(this.instanceMat);
            }
        }
        if (!Object.op_Inequality((Object)this.uvTextureAnimator, (Object)null))
        {
            return;
        }
        this.uvTextureAnimator.SetInstanceMaterial(this.instanceMat, Vector2.get_zero());
    }
示例#6
0
    public void UpdateMaterial(RaycastHit hit)
    {
        var hitGO = hit.transform;
        if (hitGO!=null) {
          if (!RemoveWhenDisable) Destroy(gameObject, RemoveAfterTime);
          fadeInOutShaderColor = GetComponents<FadeInOutShaderColor>();
          fadeInOutShaderFloat = GetComponents<FadeInOutShaderFloat>();
          uvTextureAnimator = GetComponent<UVTextureAnimator>();
          renderParent = transform.parent.GetComponent<Renderer>();

          var materials = renderParent.sharedMaterials;
          var length = materials.Length + 1;
          var newMaterials = new Material[length];

          materials.CopyTo(newMaterials, 0);
          renderParent.material = Material;
          instanceMat = renderParent.material;
          newMaterials[length - 1] = instanceMat;
          renderParent.sharedMaterials = newMaterials;

          if (UsePointMatrixTransform) {
        var m = Matrix4x4.TRS(hit.transform.InverseTransformPoint(hit.point), Quaternion.Euler(180, 180, 0f), TransformScale);
        //m *= transform.localToWorldMatrix;
        instanceMat.SetMatrix("_DecalMatr", m);
          }
          if (materialQueue!=-1)
        instanceMat.renderQueue = materialQueue;

          if (fadeInOutShaderColor!=null) {
        foreach (var inOutShaderColor in fadeInOutShaderColor) {
          inOutShaderColor.UpdateMaterial(instanceMat);
        }
          }

          if (fadeInOutShaderFloat!=null) {
        foreach (var inOutShaderFloat in fadeInOutShaderFloat) {
          inOutShaderFloat.UpdateMaterial(instanceMat);
        }
          }

          if (uvTextureAnimator!=null)
        uvTextureAnimator.SetInstanceMaterial(instanceMat, hit.textureCoord);
        }
    }
示例#7
0
    public void UpdateMaterial(Transform transformTarget)
    {
        if (transformTarget!=null) {
          if (!RemoveWhenDisable) Destroy(gameObject, RemoveAfterTime);
          fadeInOutShaderColor = GetComponents<FadeInOutShaderColor>();
          fadeInOutShaderFloat = GetComponents<FadeInOutShaderFloat>();
          uvTextureAnimator = GetComponent<UVTextureAnimator>();
          renderParent = transform.parent.GetComponent<Renderer>();

          var materials = renderParent.sharedMaterials;
          var length = materials.Length + 1;
          var newMaterials = new Material[length];

          materials.CopyTo(newMaterials, 0);
          renderParent.material = Material;
          instanceMat = renderParent.material;
          newMaterials[length - 1] = instanceMat;
          renderParent.sharedMaterials = newMaterials;

          if (materialQueue!=-1)
        instanceMat.renderQueue = materialQueue;

          if (fadeInOutShaderColor!=null) {
        foreach (var inOutShaderColor in fadeInOutShaderColor) {
          inOutShaderColor.UpdateMaterial(instanceMat);
        }
          }

          if (fadeInOutShaderFloat!=null) {
        foreach (var inOutShaderFloat in fadeInOutShaderFloat) {
          inOutShaderFloat.UpdateMaterial(instanceMat);
        }
          }

          if (uvTextureAnimator!=null)
        uvTextureAnimator.SetInstanceMaterial(instanceMat, Vector2.zero);
        }
    }