예제 #1
0
    public static Material ShareMaterial(GlowEffect _glowEffect)
    {
        for (int i = 0; i < allMaterials.Count; i++)
        {
            if (allMaterials[i].SpriteTexture == _glowEffect.Renderer.sprite.texture &&
                allMaterials[i].DrawOutside == _glowEffect.DrawOutside &&
                allMaterials[i].InstancingEnabled == _glowEffect.EnableInstancing)
            {
                return(allMaterials[i]);
            }
        }
        GlowMaterial material = new GlowMaterial(_glowEffect.Renderer.sprite.texture, _glowEffect.DrawOutside, _glowEffect.EnableInstancing);

        material.hideFlags = HideFlags.DontSaveInBuild | HideFlags.DontSaveInEditor | HideFlags.NotEditable;
        allMaterials.Add(material);
        return(material);
    }
예제 #2
0
    //[SerializeField]
    //Color lightColor;
    #endregion
    #endregion

    #region Methods

    void SetMaterialProperties()
    {
        if (!Renderer)
        {
            return;
        }

        Renderer.sharedMaterial = GlowMaterial.ShareMaterial(this);

        if (materialProperties == null)
        {
            materialProperties = new MaterialPropertyBlock();
        }

        materialProperties.SetColor(outlineColorId, GlowColor * GlowIntensity);
        materialProperties.SetFloat(alphaThresholdId, AlphaThreshold);
        materialProperties.SetFloat(isOutlineEnabledId, isActiveAndEnabled ? 1 : 0);
        materialProperties.SetFloat(outlineSizeId, OutlineWidth);
        Renderer.SetPropertyBlock(materialProperties);
    }