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);
            }
        }
    }
示例#2
0
    public void UpdateMaterial(Transform transformTarget)
    {
        if (transformTarget != null)
        {
            if (!RemoveWhenDisable)
            {
                ObjectPoolManager.Unspawn(gameObject, RemoveAfterTime);
            }
            fadeInOutShaderColor = GetComponents <FadeInOutShaderColor>();
            fadeInOutShaderFloat = GetComponents <FadeInOutShaderFloat>();
            uvTextureAnimator    = GetComponent <UVTextureAnimator>();
            renderParent         = transform.parent.GetComponentsInChildren <MeshRenderer>();

            //for(int i = 0; i < renderParent.Length; i++)
            //{
            //    if(renderParent[i].tag.Equals("IgnoreAddMaterial"))
            //    {

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

                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);
                }
            }
        }
    }
    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);
            }
        }
    }
示例#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);
            }
        }
    }
示例#5
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);
        }
    }
示例#6
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);
        }
    }