Jump to content
This site uses cookies! Learn More

This site uses cookies!

armedunity.com uses cookies to improve user experience.

By continuing to use this site, you agree to allow us to store cookies on your computer.

  • 0
Sign in to follow this  
fpsarmedunity

stop image effect to play after a certain time

Question

 
Hi I purchased Camera filers pack form ssset store
Please login or register to see this link.
 
is a set of filter that  can be used like image effects 
 
the use is very simpe.. place the image effect scirpt on camera ad after call it form scirpt...
 
I fugured how to set the waterdrop effect when player exit form underwater easily but my problem is that effect continue obviusly to play since it  not has a timer to stop it
so i would to know a simple way to can stop script form play after a ceratin time to stop waterdrop effect ..and a solution that can be used in a generic way  to set a time for effect  to be played--
 
do you think is there a simple way to acheive that?
 
here the scirpt waterdrop scrotp as sample
 
 
using UnityEngine;
using System.Collections;
 
[ExecuteInEditMode]
[AddComponentMenu ("Camera Filter Pack/AAA/WaterDrop")]
public class CameraFilterPack_AAA_WaterDrop : MonoBehaviour {
#region Variables
public Shader SCShader;
private float TimeX = 1.0f;
[Range(8, 64)]
public float Distortion = 8.0f;
[Range(0, 7)]
public float SizeX = 1.0f;
[Range(0, 7)]
public float SizeY = 0.5f;
[Range(0, 10)]
public float Speed = 1f;
private Material SCMaterial;
private Texture2D Texture2;
 
#endregion
 
#region Properties
Material material
{
get
{
if(SCMaterial == null)
{
SCMaterial = new Material(SCShader);
SCMaterial.hideFlags = HideFlags.HideAndDontSave;
}
return SCMaterial;
}
}
#endregion
void Start () 
{
 
Texture2 = Resources.Load ("CameraFilterPack_WaterDrop") as Texture2D;
 
SCShader = Shader.Find("CameraFilterPack/AAA_WaterDrop");
 
if(!SystemInfo.supportsImageEffects)
{
enabled = false;
return;
}
}
 
void OnRenderImage (RenderTexture sourceTexture, RenderTexture destTexture)
{
if(SCShader != null)
{
TimeX+=Time.deltaTime;
if (TimeX>100)  TimeX=0;
material.SetFloat("_TimeX", TimeX);
material.SetFloat("_Distortion", Distortion);
material.SetFloat("_SizeX", SizeX);
material.SetFloat("_SizeY", SizeY);
material.SetFloat("_Speed", Speed);
material.SetTexture("_MainTex2", Texture2);
 
Graphics.Blit(sourceTexture, destTexture, material);
}
else
{
Graphics.Blit(sourceTexture, destTexture);
}
 
 
}
 
void Update () 
{
 
#if UNITY_EDITOR
if (Application.isPlaying!=true)
{
SCShader = Shader.Find("CameraFilterPack/AAA_WaterDrop");
Texture2 = Resources.Load ("CameraFilterPack_WaterDrop") as Texture2D;
 
}
#endif
 
}
 
void OnDisable ()
{
if(SCMaterial)
{
DestroyImmediate(SCMaterial);
}
 
}
 
 
}
 

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0

nevermind solved with a coroutine on fpscontroller scritp

 

btw  could i do if i would to add a fade/dissolve attribute to this shader?

Share this post


Link to post
Share on other sites

  • 0

I saw that it uses texture for rain. Maybe you could play with alpha to fade it ++

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...