Seaside Studios
HomeOverviewFAQsContactReview
VFX Toolkit
VFX Toolkit
  • What is All In 1 VFX Toolkit
  • Overview
  • Setup and Render Pipelines
  • First Steps (Must Read)
  • Asset Component Features
  • Shader Structure and Usage
  • Advanced Configuration and Key Rendering Concepts
  • Particle System Helper Component
  • Asset Window
  • Textures Setup
  • Saving Prefabs
  • Screen Distortion and Creating Distortion Maps
  • Custom Vertex Streams and Custom Data Auto Setup
  • How to Animate Materials
  • Custom Scaled Time
  • Scripting
  • Visual Effect Graph (Vfx Graph)
  • How to Enable/Disable Effects at Runtime
  • Random Seed
  • Render Material To Image
  • Premade Textures, Meshes and Materials
  • Helper Scripts and Other Utilities
  • Lit Shader
  • Effects and Properties Breakdown
  • Custom Gradient Property Drawer
  • Running out of Shader Keywords
  • Considerations
  • FAQ (Frequently Asked Questions)
  • Credits
Powered by GitBook
On this page

Scripting

PreviousCustom Scaled TimeNextVisual Effect Graph (Vfx Graph)

Last updated 7 months ago

If you prefer avoiding animations or want to change properties through code you also have the possibility. This will be mostly used on Materials assigned to Mesh Renderers, it won’t make much sense to use this on Particle Systems.

You can find the property names by hovering the mouse over any property in the Material Inspector:

To do so you’ll need to use the following Unity functions:

You can find all property names on:

AllIn1VfxToolkit\Shaders\Resources\AllIn1Vfx.shader

All properties are located from line 5 to 185 and can also be found at the Effects and Properties Breakdown section. Here an example code snippet:

Material mat = GetComponent<Renderer>().material;
mat.SetFloat("_Alpha", 1f);
mat.SetColor("_Color", new Color(0.5f, 1f, 0f, 1f));
mat.SetTexture("_MainTex", texture);

*Note that there is an important distinction to be made between a “material” and a “sharedMaterial” of a Renderer. You shall use “material” if you only want to change a property of that instance of the material. And “sharedMaterial” if you want to change the property of all the instances of that material

Material.SetFloat:

Material.SetColor:

Material.SetTexture:

https://docs.unity3d.com/ScriptReference/Material.SetFloat.html
https://docs.unity3d.com/ScriptReference/Material.SetColor.html
https://docs.unity3d.com/ScriptReference/Material.SetTexture.html