Dogan Kirnaz
  • Welcome
  • Setup
    • Quickstart
  • Basics
    • Agent Extensions
    • Audio Extensions
    • Camera Extensions
    • Collision Extensions
    • Coroutine Extensions
    • Encryption Extensions
    • Format Extensions
    • Game Extensions
    • Json Extensions
    • List Extensions
    • Loop Extensions
    • Material Extensions
    • Math Extensions
    • GameObject Extensions
    • Physics Extensions
    • Object Pool Extensions
    • Scene Extensions
    • PlayerPrefs Extensions
  • Support
    • Support
Powered by GitBook
On this page
  1. Basics

Material Extensions

Set Color

This sets the color of the specified material.

Material material = new Material(Shader.Find("Standard"));

material.SetColor(Color.red);

Set Main Texture

This sets the main texture of the specified material.

Material material = new Material(Shader.Find("Standard"));

material.SetMainTexture(texture);

Set Texture Offset

This sets the main texture offset with the given value.

Material material = new Material(Shader.Find("Standard"));

material.SetTextureOffset(0.5f, 0.5f);

Set Texture Scale

This sets the main texture scale with the given value.

Material material = new Material(Shader.Find("Standard"));

material.SetTextureScale(1.5f, 1.5f);

Set Shader

This sets the shader of the specified material.

Material material = new Material(Shader.Find("Standard"));

material.SetShader(shader);

Set Rendering Mode

This sets the shader of the specified material.

Material material = new Material(Shader.Find("Standard"));

material.SetRenderingMode(RenderingMode.Transparent);

Lighten Color

This lightens the specified color by a given amount.

Color color = new Color(0.5f, 0.5f, 0.5f);

Color lighterColor = color.Lighten(0.2f);

Darken Color

This darkens the specified color by a given amount.

Color color = new Color(0.5f, 0.5f, 0.5f);

Color darkerColor = color.Darken(0.2f);

Mix Colors

This mixes two colors based on the specified amount.

Color color1 = Color.red;
Color color2 = Color.blue;

Color mixedColor = color1.Mix(color2, 0.5f);  

Invert Color

This inverts a color and returns.

Color color = new Color(0.5f, 0.5f, 0.5f);

Color invertedColor = color.Invert();

Grayscale Color

This converts the specified color to its grayscale equivalent.

Color color = new Color(0.5f, 0.5f, 0.5f);

Color grayColor = color.Grayscale();

Set Alpha

This sets the alpha (transparency) value of the specified color.

Color color = new Color(0.5f, 0.5f, 0.5f);

Color transparentColor = color.SetAlpha(0.5f);  
PreviousLoop ExtensionsNextMath Extensions

Last updated 23 days ago