当前位置: 首页>>代码示例>>C#>>正文


C# Material.HasProperty方法代码示例

本文整理汇总了C#中Material.HasProperty方法的典型用法代码示例。如果您正苦于以下问题:C# Material.HasProperty方法的具体用法?C# Material.HasProperty怎么用?C# Material.HasProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Material的用法示例。


在下文中一共展示了Material.HasProperty方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Add

        /// <summary>
        /// Add a new material using the specified base and stencil ID.
        /// </summary>
        public static Material Add(Material baseMat, int stencilID)
        {
            if (stencilID <= 0 || baseMat == null)
                return null;

            if (!baseMat.HasProperty("_Stencil"))
            {
                Debug.LogWarning("Material " + baseMat.name + " doesn't have stencil properties", baseMat);
                return null;
            }

            for (int i = 0; i < m_List.Count; ++i)
            {
                MatEntry ent = m_List[i];

                if (ent.baseMat == baseMat && ent.stencilID == stencilID)
                {
                    ++ent.count;
                    return ent.customMat;
                }
            }

            var newEnt = new MatEntry();
            newEnt.count = 1;
            newEnt.baseMat = baseMat;
            newEnt.customMat = new Material(baseMat);
            newEnt.customMat.name = "Stencil " + stencilID + " (" + baseMat.name + ")";
            newEnt.customMat.hideFlags = HideFlags.HideAndDontSave;
            newEnt.stencilID = stencilID;

            if (baseMat.HasProperty("_StencilComp"))
                newEnt.customMat.SetInt("_StencilComp", (int)CompareFunction.Equal);

            newEnt.customMat.SetInt("_Stencil", stencilID);
            m_List.Add(newEnt);
            return newEnt.customMat;
        }
开发者ID:602147629,项目名称:Unity-ugui,代码行数:40,代码来源:StencilMaterial.cs

示例2: GetModifiedMaterial

        public virtual Material GetModifiedMaterial(Material baseMaterial)
        {
            ClearCachedMaterial();

            if (!IsActive())
                return baseMaterial;

            m_RenderMaterial = new Material(baseMaterial)
            {
                name = "Mask " + " (" + baseMaterial.name + ")",
                hideFlags = HideFlags.HideAndDontSave
            };

            if (m_RenderMaterial.HasProperty("_ColorMask"))
                m_RenderMaterial.SetInt("_ColorMask", m_ShowMaskGraphic ? (int)ColorWriteMask.All : 0);
            else
                Debug.LogWarning("Material " + baseMaterial + " doesn't have color mask", baseMaterial);

            return m_RenderMaterial;
        }
开发者ID:602147629,项目名称:Unity-ugui,代码行数:20,代码来源:Mask.cs

示例3: Add

        /// <summary>
        /// Add a new material using the specified base and stencil ID.
        /// </summary>
        public static Material Add(Material baseMat, int stencilID, StencilOp operation, CompareFunction compareFunction, ColorWriteMask colorWriteMask, int readMask, int writeMask)
        {
            if ((stencilID <= 0 && colorWriteMask == ColorWriteMask.All) || baseMat == null)
                return baseMat;

            if (!baseMat.HasProperty("_Stencil"))
            {
                Debug.LogWarning("Material " + baseMat.name + " doesn't have _Stencil property", baseMat);
                return baseMat;
            }
            if (!baseMat.HasProperty("_StencilOp"))
            {
                Debug.LogWarning("Material " + baseMat.name + " doesn't have _StencilOp property", baseMat);
                return baseMat;
            }
            if (!baseMat.HasProperty("_StencilComp"))
            {
                Debug.LogWarning("Material " + baseMat.name + " doesn't have _StencilComp property", baseMat);
                return baseMat;
            }
            if (!baseMat.HasProperty("_StencilReadMask"))
            {
                Debug.LogWarning("Material " + baseMat.name + " doesn't have _StencilReadMask property", baseMat);
                return baseMat;
            }
            if (!baseMat.HasProperty("_StencilReadMask"))
            {
                Debug.LogWarning("Material " + baseMat.name + " doesn't have _StencilWriteMask property", baseMat);
                return baseMat;
            }
            if (!baseMat.HasProperty("_ColorMask"))
            {
                Debug.LogWarning("Material " + baseMat.name + " doesn't have _ColorMask property", baseMat);
                return baseMat;
            }

            for (int i = 0; i < m_List.Count; ++i)
            {
                MatEntry ent = m_List[i];

                if (ent.baseMat == baseMat
                    && ent.stencilId == stencilID
                    && ent.operation == operation
                    && ent.compareFunction == compareFunction
                    && ent.readMask == readMask
                    && ent.writeMask == writeMask
                    && ent.colorMask == colorWriteMask)
                {
                    ++ent.count;
                    return ent.customMat;
                }
            }

            var newEnt = new MatEntry();
            newEnt.count = 1;
            newEnt.baseMat = baseMat;
            newEnt.customMat = new Material(baseMat);
            newEnt.customMat.hideFlags = HideFlags.HideAndDontSave;
            newEnt.stencilId = stencilID;
            newEnt.operation = operation;
            newEnt.compareFunction = compareFunction;
            newEnt.readMask = readMask;
            newEnt.writeMask = writeMask;
            newEnt.colorMask = colorWriteMask;
            newEnt.useAlphaClip = operation != StencilOp.Keep && writeMask > 0;

            newEnt.customMat.name = string.Format("Stencil Id:{0}, Op:{1}, Comp:{2}, WriteMask:{3}, ReadMask:{4}, ColorMask:{5} AlphaClip:{6} ({7})", stencilID, operation, compareFunction, writeMask, readMask, colorWriteMask, newEnt.useAlphaClip, baseMat.name);

            newEnt.customMat.SetInt("_Stencil", stencilID);
            newEnt.customMat.SetInt("_StencilOp", (int)operation);
            newEnt.customMat.SetInt("_StencilComp", (int)compareFunction);
            newEnt.customMat.SetInt("_StencilReadMask", readMask);
            newEnt.customMat.SetInt("_StencilWriteMask", writeMask);
            newEnt.customMat.SetInt("_ColorMask", (int)colorWriteMask);

            // left for backwards compatability
            if (newEnt.customMat.HasProperty("_UseAlphaClip"))
                newEnt.customMat.SetInt("_UseAlphaClip", newEnt.useAlphaClip ? 1 : 0);

            if (newEnt.useAlphaClip)
                newEnt.customMat.EnableKeyword("UNITY_UI_ALPHACLIP");
            else
                newEnt.customMat.DisableKeyword("UNITY_UI_ALPHACLIP");

            m_List.Add(newEnt);
            return newEnt.customMat;
        }
开发者ID:gdzzzyyy,项目名称:UGUIlok,代码行数:90,代码来源:StencilMaterial.cs

示例4: Add

 public static Material Add(Material baseMat, int stencilID, StencilOp operation, CompareFunction compareFunction, ColorWriteMask colorWriteMask, int readMask, int writeMask)
 {
   if (stencilID <= 0 && colorWriteMask == ColorWriteMask.All || (UnityEngine.Object) baseMat == (UnityEngine.Object) null)
     return baseMat;
   if (!baseMat.HasProperty("_Stencil"))
   {
     Debug.LogWarning((object) ("Material " + baseMat.name + " doesn't have _Stencil property"), (UnityEngine.Object) baseMat);
     return baseMat;
   }
   if (!baseMat.HasProperty("_StencilOp"))
   {
     Debug.LogWarning((object) ("Material " + baseMat.name + " doesn't have _StencilOp property"), (UnityEngine.Object) baseMat);
     return baseMat;
   }
   if (!baseMat.HasProperty("_StencilComp"))
   {
     Debug.LogWarning((object) ("Material " + baseMat.name + " doesn't have _StencilComp property"), (UnityEngine.Object) baseMat);
     return baseMat;
   }
   if (!baseMat.HasProperty("_StencilReadMask"))
   {
     Debug.LogWarning((object) ("Material " + baseMat.name + " doesn't have _StencilReadMask property"), (UnityEngine.Object) baseMat);
     return baseMat;
   }
   if (!baseMat.HasProperty("_StencilReadMask"))
   {
     Debug.LogWarning((object) ("Material " + baseMat.name + " doesn't have _StencilWriteMask property"), (UnityEngine.Object) baseMat);
     return baseMat;
   }
   if (!baseMat.HasProperty("_ColorMask"))
   {
     Debug.LogWarning((object) ("Material " + baseMat.name + " doesn't have _ColorMask property"), (UnityEngine.Object) baseMat);
     return baseMat;
   }
   for (int index = 0; index < StencilMaterial.m_List.Count; ++index)
   {
     StencilMaterial.MatEntry matEntry = StencilMaterial.m_List[index];
     if ((UnityEngine.Object) matEntry.baseMat == (UnityEngine.Object) baseMat && matEntry.stencilId == stencilID && (matEntry.operation == operation && matEntry.compareFunction == compareFunction) && (matEntry.readMask == readMask && matEntry.writeMask == writeMask && matEntry.colorMask == colorWriteMask))
     {
       ++matEntry.count;
       return matEntry.customMat;
     }
   }
   StencilMaterial.MatEntry matEntry1 = new StencilMaterial.MatEntry();
   matEntry1.count = 1;
   matEntry1.baseMat = baseMat;
   matEntry1.customMat = new Material(baseMat);
   matEntry1.customMat.hideFlags = HideFlags.HideAndDontSave;
   matEntry1.stencilId = stencilID;
   matEntry1.operation = operation;
   matEntry1.compareFunction = compareFunction;
   matEntry1.readMask = readMask;
   matEntry1.writeMask = writeMask;
   matEntry1.colorMask = colorWriteMask;
   matEntry1.useAlphaClip = operation != StencilOp.Keep && writeMask > 0;
   matEntry1.customMat.name = string.Format("Stencil Id:{0}, Op:{1}, Comp:{2}, WriteMask:{3}, ReadMask:{4}, ColorMask:{5} AlphaClip:{6} ({7})", (object) stencilID, (object) operation, (object) compareFunction, (object) writeMask, (object) readMask, (object) colorWriteMask, (object) matEntry1.useAlphaClip, (object) baseMat.name);
   matEntry1.customMat.SetInt("_Stencil", stencilID);
   matEntry1.customMat.SetInt("_StencilOp", (int) operation);
   matEntry1.customMat.SetInt("_StencilComp", (int) compareFunction);
   matEntry1.customMat.SetInt("_StencilReadMask", readMask);
   matEntry1.customMat.SetInt("_StencilWriteMask", writeMask);
   matEntry1.customMat.SetInt("_ColorMask", (int) colorWriteMask);
   if (matEntry1.customMat.HasProperty("_UseAlphaClip"))
     matEntry1.customMat.SetInt("_UseAlphaClip", !matEntry1.useAlphaClip ? 0 : 1);
   if (matEntry1.useAlphaClip)
     matEntry1.customMat.EnableKeyword("UNITY_UI_ALPHACLIP");
   else
     matEntry1.customMat.DisableKeyword("UNITY_UI_ALPHACLIP");
   StencilMaterial.m_List.Add(matEntry1);
   return matEntry1.customMat;
 }
开发者ID:BlakeTriana,项目名称:unity-decompiled,代码行数:71,代码来源:StencilMaterial.cs


注:本文中的Material.HasProperty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。