Skip to content

Instantly share code, notes, and snippets.

@unitycoder
Created March 2, 2019 09:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save unitycoder/f7ea9019bb67b7042efbd08f0f4fa785 to your computer and use it in GitHub Desktop.
Save unitycoder/f7ea9019bb67b7042efbd08f0f4fa785 to your computer and use it in GitHub Desktop.
Gradient Texture Maker Example
// requires this script: https://github.com/UnityCommunity/UnityLibrary/blob/master/Assets/Scripts/Texture/GradientTextureMaker.cs
using UnityEngine;
public class TestGradient : MonoBehaviour
{
public Color[] colors;
public FilterMode filterMode = FilterMode.Point;
public TextureWrapMode wrapMode = TextureWrapMode.Clamp;
public bool isLinear = false;
public bool hasMipMap = false;
void Start()
{
var mr = GetComponent<MeshRenderer>();
// generate texture and assign as main texture
mr.material.mainTexture = UnityLibrary.GradientTextureMaker.Create(colors, wrapMode, filterMode, isLinear, hasMipMap);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment