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
    }
示例#2
0
    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);
    }