DecalCreator.CreateFluidDecal (Frameshift.Decal.DecalType, UnityEngine.Vector3, UnityEngine.Vector3, UnityEngine.GameObject, UnityEngine.Material) Method

DecalFramework

DropDown image DropDownHover image Collapse image Expand image CollapseAll image ExpandAll image Copy image CopyHover image

Creates fluid decal mesh and fluid game object with render sub-system

Namespace: Frameshift.Decal
Assembly: Frameshift.Decal (in Frameshift.Decal.dll)

Expand  imageSyntax

C#
public static GameObject CreateFluidDecal( 
DecalType decalType
Vector3 point
Vector3 forward
GameObject obj
Material materialOverride 
);

Parameters

decalType

Type of Decal that will be created.

point

Point in world space where Decal will be calculated.

forward

Direction of decal. Usually -hit.normal.

obj

GameObject on which Decal will be created.

materialOverride

Material override for Decal

Return Value

Decal Object and render sub-system

Expand image Example

 CopyCode imageCopy Code
 
RaycastHit hit; 
Ray ray = Camera.main.ViewportPointToRay(new Vector3(0.5F, 0.5F, 0)); 
bool wasHit = Physics.Raycast(ray, out hit); 
 
if (wasHit) 

Material m = null; 
if (hit.collider.gameObject.renderer) 

//Get material instanse 
m = Instantiate(i_flow.i_material) as Material; 
 
//Get bump from hited surface 
 
if(hit.collider.gameObject.renderer.sharedMaterial.HasProperty("_BumpMap")) 

Texture2D bumpMap = 
hit.collider.gameObject.renderer.sharedMaterial.GetTexture("_BumpMap") as 
Texture2D; 
Vector2 bumpScale = 
hit.collider.gameObject.renderer.sharedMaterial.GetTextureScale("_BumpMap"); 
Vector2 bumpOffset = 
hit.collider.gameObject.renderer.sharedMaterial.GetTextureOffset("_BumpMap"); 
//Setup new bump 
m.SetTexture("_SourceBumpMap", bumpMap); 
m.SetTextureScale("_SourceBumpMap", bumpScale); 
m.SetTextureOffset("_SourceBumpMap", bumpOffset); 

else 

m.SetTexture("_SourceBumpMap", null); 

//Flow decal 
DecalCreator.CreateFluidDecal(i_flow, hit.point, ray.direction, 
hit.collider.gameObject, m); 


Expand image Platforms

Unity 2.6.1

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

Expand image See Also