private void Apply() { if (!this.enabled || !this.renderer || !ColorPalette) { return; } AppendMaterials(); #if UNITY_EDITOR ColorPalette.ApplyColorPalette(renderer.sharedMaterials[materialIndex]); #else ColorPalette.ApplyColorPalette(renderer.materials[materialIndex]); #endif }
void OnEnable() { if (mat != null) { return; } Shader shader = Shader.Find("Hidden/PaletteSwap"); mat = new Material(shader); // Disable default blending set in shader mat.SetInt("_BlendSrcMode", (int)UnityEngine.Rendering.BlendMode.SrcAlpha); mat.SetInt("_BlendDstMode", (int)UnityEngine.Rendering.BlendMode.Zero); if (ColorPalette == null) { return; } ColorPalette.ApplyColorPalette(mat); }