UnityEngine.Material.SetInt C# (CSharp) Method

SetInt() public method

Set a named integer value.

public SetInt ( int nameID, int value ) : void
nameID int Property name ID, use Shader.PropertyToID to get it.
value int Integer value to set.
return void
        public void SetInt(int nameID, int value)
        {
            this.SetFloat(nameID, (float) value);
        }

Same methods

Material::SetInt ( string propertyName, int value ) : void

Usage Example

コード例 #1
0
        public static void CreateLineMaterial(int iMat = 1)
        {
            Material mMat = lineMaterial1;
            if (iMat == 2) mMat = lineMaterial2;
            if (iMat == 3) mMat = lineMaterial3;
            if (iMat == 4) mMat = lineMaterial4;
            if (iMat == 5) mMat = lineMaterial5;

            if (mMat == null)
            {
                var shader = Shader.Find("Hidden/Internal-Colored");
                mMat = new Material(shader);
                mMat.hideFlags = HideFlags.HideAndDontSave;
                // Turn on alpha blending
                mMat.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha);
                mMat.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
                // Turn backface culling off
                mMat.SetInt("_Cull", (int)UnityEngine.Rendering.CullMode.Off);
                // Turn off depth writes
                mMat.SetInt("_ZWrite", 0);

                if (iMat == 1) lineMaterial1 = mMat;
                if (iMat == 2) lineMaterial2 = mMat;
                if (iMat == 3) lineMaterial3 = mMat;
                if (iMat == 4) lineMaterial4 = mMat;
                if (iMat == 5) lineMaterial5 = mMat;
            }
        }
All Usage Examples Of UnityEngine.Material::SetInt