AddTexture() private method

private AddTexture ( int nameID, Texture value ) : void
nameID int
value Texture
return void
コード例 #1
0
 static public int AddTexture(IntPtr l)
 {
     try{
         if (matchType(l, 2, typeof(System.String), typeof(UnityEngine.Texture)))
         {
             UnityEngine.MaterialPropertyBlock self = (UnityEngine.MaterialPropertyBlock)checkSelf(l);
             System.String a1;
             checkType(l, 2, out a1);
             UnityEngine.Texture a2;
             checkType(l, 3, out a2);
             self.AddTexture(a1, a2);
             return(0);
         }
         else if (matchType(l, 2, typeof(System.Int32), typeof(UnityEngine.Texture)))
         {
             UnityEngine.MaterialPropertyBlock self = (UnityEngine.MaterialPropertyBlock)checkSelf(l);
             System.Int32 a1;
             checkType(l, 2, out a1);
             UnityEngine.Texture a2;
             checkType(l, 3, out a2);
             self.AddTexture(a1, a2);
             return(0);
         }
         LuaDLL.luaL_error(l, "No matched override function to call");
         return(0);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
コード例 #2
0
 static public int AddTexture(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         if (matchType(l, argc, 2, typeof(int), typeof(UnityEngine.Texture)))
         {
             UnityEngine.MaterialPropertyBlock self = (UnityEngine.MaterialPropertyBlock)checkSelf(l);
             System.Int32 a1;
             checkType(l, 2, out a1);
             UnityEngine.Texture a2;
             checkType(l, 3, out a2);
             self.AddTexture(a1, a2);
             pushValue(l, true);
             return(1);
         }
         else if (matchType(l, argc, 2, typeof(string), typeof(UnityEngine.Texture)))
         {
             UnityEngine.MaterialPropertyBlock self = (UnityEngine.MaterialPropertyBlock)checkSelf(l);
             System.String a1;
             checkType(l, 2, out a1);
             UnityEngine.Texture a2;
             checkType(l, 3, out a2);
             self.AddTexture(a1, a2);
             pushValue(l, true);
             return(1);
         }
         pushValue(l, false);
         LuaDLL.lua_pushstring(l, "No matched override function to call");
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
コード例 #3
0
    public void SwapColors_Custom(ColorPalette palette)
    {
        Texture2D t = spriteRenderer.sprite.texture;

        if (palette.cachedTexture == null)
        {
            var w = t.width;
            var h = t.height;

            var cloneTexture = new Texture2D(w, h);
            cloneTexture.wrapMode = TextureWrapMode.Clamp;
            cloneTexture.filterMode = FilterMode.Point;

            var colors = t.GetPixels();

            for (int i = 0; i < colors.Length; i++)
            {
                colors[i] = palette.GetColor(colors[i]);
            }

            cloneTexture.SetPixels(colors);
            cloneTexture.Apply();

            palette.cachedTexture = cloneTexture;
        }

        block = new MaterialPropertyBlock();
        block.AddTexture("_MainTex", palette.cachedTexture);
    }
コード例 #4
0
 // Use this for initialization
 void Start()
 {
     MaterialPropertyBlock bloc = new MaterialPropertyBlock();
     Renderer rend = gameObject.GetComponent<Renderer> ();
     rend.material = SpriteLightMaterial;
     rend.GetPropertyBlock (bloc);
     bloc.AddTexture ("_LightTex",Light.texture);
     rend.SetPropertyBlock (bloc);
 }
コード例 #5
0
ファイル: SetHologramColor.cs プロジェクト: marcteys/trauts
	void Awake()
	{
		mb = new MaterialPropertyBlock();
		mb.AddTexture("_MainTex",texture);

		foreach (Transform child in transform)
		{	defaultColor = child.renderer.material.color;


			Color newColor = defaultColor;
			//newColor.a = (1-child.localPosition.y*8)/2f;
			mb.AddColor("_Color",newColor);
			mb.AddColor("_TintColor",newColor);

			child.renderer.SetPropertyBlock(mb);
			child.renderer.material.SetTexture("_MainTex", texture);
		}
	}
コード例 #6
0
    // Use this for initialization
    void Start()
    {
        texture = spriteRenderer.sprite.texture;

        var w = texture.width;
        var h = texture.height;

        cloneTexture = new Texture2D (w, h);
        cloneTexture.wrapMode = TextureWrapMode.Clamp;
        cloneTexture.filterMode = FilterMode.Point;

        Color[] pixels = texture.GetPixels ();

        cloneTexture.SetPixels (pixels);
        cloneTexture.Apply ();

        block = new MaterialPropertyBlock ();
        block.AddTexture ("_MainTex", cloneTexture);

        SwapColors ();
    }
コード例 #7
0
        void DestroyPlanetChunk()
        {
            //Make instance of texture
            Texture2D texInstance = MonoBehaviour.Instantiate<Texture2D> (spriteRend.sprite.texture);

            //Set pixels to transparent
            Color[] pixels = texInstance.GetPixels ();

            for (int y = 0; y<pixels.Length; y++) {
                if(y<10000){
                    pixels[y] = new Color(0,0,0,0);

                }
            }

            //Apply pixels to tex instance
            texInstance.SetPixels (pixels);
            texInstance.Apply ();

            //Apply texture to sprite
            MaterialPropertyBlock block = new MaterialPropertyBlock ();
            block.AddTexture ("_MainTex", texInstance);
            spriteRend.SetPropertyBlock(block);
        }
コード例 #8
0
ファイル: Sky.cs プロジェクト: elephantatwork/Secret-Game
		private void ApplyToBlock(ref MaterialPropertyBlock block, ShaderIDs bids) {
			#if USE_PROPERTY_BLOCKS
			block.AddVector(bids.exposureIBL,	exposures);
			block.AddVector(bids.exposureLM,	exposuresLM);

			block.AddMatrix(bids.skyMatrix,		skyMatrix);
			block.AddMatrix(bids.invSkyMatrix,	invMatrix);

			block.AddVector(bids.skyMin, skyMin);
			block.AddVector(bids.skyMax, skyMax);			

			if(specularCube) block.AddTexture(bids.specCubeIBL, specularCube);
			else 			 block.AddTexture(bids.specCubeIBL, blackCube);

			block.AddVector(bids.SH[0],	SH.cBuffer[0]);
			block.AddVector(bids.SH[1],	SH.cBuffer[1]);
			block.AddVector(bids.SH[2],	SH.cBuffer[2]);
			block.AddVector(bids.SH[3],	SH.cBuffer[3]);
			block.AddVector(bids.SH[4],	SH.cBuffer[4]);
			block.AddVector(bids.SH[5],	SH.cBuffer[5]);
			block.AddVector(bids.SH[6],	SH.cBuffer[6]);
			block.AddVector(bids.SH[7],	SH.cBuffer[7]);
			block.AddVector(bids.SH[8], SH.cBuffer[8]);

			#endif
		}
コード例 #9
0
ファイル: Wall.cs プロジェクト: Nabetse990/KvantWall
        void Update()
        {
            if (_needsReset) ResetResources();

            // Call the kernels.
            UpdateKernelShader();
            Graphics.Blit(null, _positionBuffer, _kernelMaterial, 0);
            Graphics.Blit(null, _rotationBuffer, _kernelMaterial, 1);
            Graphics.Blit(null, _scaleBuffer,    _kernelMaterial, 2);

            // Make a material property block for the following drawcalls.
            var props = new MaterialPropertyBlock();
            props.AddTexture("_PositionTex", _positionBuffer);
            props.AddTexture("_RotationTex", _rotationBuffer);
            props.AddTexture("_ScaleTex", _scaleBuffer);
            props.SetVector("_ColumnRow", new Vector2(_columns, _rows));
            props.SetVector("_UVOffset", UVOffset);

            // Temporary variables.
            var mesh = _bulkMesh.mesh;
            var position = transform.position;
            var rotation = transform.rotation;
            var material = _material ? _material : _defaultMaterial;
            var uv = new Vector2(0.5f / _positionBuffer.width, 0);

            position += transform.right * XOffset;
            position += transform.up * YOffset;

            // Draw mesh segments.
            for (var i = 0; i < _positionBuffer.height; i++)
            {
                uv.y = (0.5f + i) / _positionBuffer.height;
                props.AddVector("_BufferOffset", uv);
                Graphics.DrawMesh(
                    mesh, position, rotation,
                    material, 0, null, 0, props,
                    _castShadows, _receiveShadows);
            }
        }
コード例 #10
0
 public override void SetTexture(Texture2D texture)
 {
     base.SetTexture(texture);
     MaterialPropertyBlock props = new MaterialPropertyBlock();
     #if UNITY_4_3 || UNITY_4_5 || UNITY_4_6 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2
     props.AddTexture("_MainTex", texture);
     #else
     props.SetTexture("_MainTex", texture);
     #endif
     spriteRenderer.SetPropertyBlock(props);
 }
コード例 #11
0
 public override void SetTexture(Texture2D texture)
 {
     base.SetTexture(texture);
     MaterialPropertyBlock props = new MaterialPropertyBlock();
     props.AddTexture("_MainTex", texture);
     spriteRenderer.SetPropertyBlock(props);
 }
コード例 #12
0
ファイル: Grass.cs プロジェクト: cupsster/KvantGrass
        void Update()
        {
            if (_needsReset) ResetResources();

            // Advance the time variables.
            _rotationNoiseTime += _rotationNoiseSpeed * Time.deltaTime;

            // Call the kernels.
            UpdateKernelShader();

            if (_needsReset || _positionUpdateFlag)
                Graphics.Blit(null, _positionBuffer, _kernelMaterial, 0);

            Graphics.Blit(null, _rotationBuffer, _kernelMaterial, 1);

            if (_needsReset || _scaleUpdateFlag)
                Graphics.Blit(null, _scaleBuffer,    _kernelMaterial, 2);

            // Make a material property block for the following drawcalls.
            var props = new MaterialPropertyBlock();
            props.AddTexture("_PositionTex", _positionBuffer);
            props.AddTexture("_RotationTex", _rotationBuffer);
            props.AddTexture("_ScaleTex", _scaleBuffer);

            // Temporary variables.
            var mesh = _bulkMesh.mesh;
            var position = transform.position;
            var rotation = transform.rotation;
            var material = _material ? _material : _defaultMaterial;
            var uv = new Vector2(0.5f / _positionBuffer.width, 0);

            // Draw mesh segments.
            for (var i = 0; i < _positionBuffer.height; i++)
            {
                uv.y = (0.5f + i) / _positionBuffer.height;
                props.AddVector("_BufferOffset", uv);
                Graphics.DrawMesh(
                    mesh, position, rotation,
                    material, 0, null, 0, props,
                    _castShadows, _receiveShadows);
            }

            // Clear flag variables.
            _positionUpdateFlag = true;
            _scaleUpdateFlag = true;
            _needsReset = false;
        }
コード例 #13
0
    void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.CompareTag ("SphinxLeftHole")) {

            leftHoleActivated=!leftHoleActivated;

            if (rightHoleActivated && leftHoleActivated) {
                counter++;
                rightHoleActivated = false;
                leftHoleActivated = false;
                rightHoleTrigger.GetComponent<SpriteRenderer>().enabled=false;
                leftHoleTrigger.GetComponent<SpriteRenderer>().enabled=false;
            }

            if(leftHoleActivated==true){
                leftHoleTrigger.GetComponent<SpriteRenderer>().enabled=true;
            } else if (leftHoleActivated==false){
                leftHoleTrigger.GetComponent<SpriteRenderer>().enabled=false;
            }

            switch(counter) {
            case 1:
                MaterialPropertyBlock block1 = new MaterialPropertyBlock();
                block1.AddTexture("_BLUE",blue);
                upgradeDisplay.GetComponent<SpriteRenderer>().SetPropertyBlock(block1);
                break;

            case 2:
                MaterialPropertyBlock block2 = new MaterialPropertyBlock();
                block2.AddTexture("_RED",red);
                upgradeDisplay.GetComponent<SpriteRenderer>().SetPropertyBlock(block2);
                break;
                //case 3: upgradeDisplay.GetComponent<SpriteRenderer>().sprite.texture=green; break;
                //case 4: upgradeDisplay.GetComponent<SpriteRenderer>().sprite.texture=yellow; break;
            default:
                MaterialPropertyBlock blockDef = new MaterialPropertyBlock();
                blockDef.AddTexture("_YELLOW",yellow);
                upgradeDisplay.GetComponent<SpriteRenderer>().SetPropertyBlock(blockDef);
                break;
            }

        }

        if (collision.CompareTag ("SphinxRightHole")) {

            rightHoleActivated=!rightHoleActivated;

            if (rightHoleActivated && leftHoleActivated) {
                counter++;
                rightHoleActivated = false;
                leftHoleActivated = false;
                rightHoleTrigger.GetComponent<SpriteRenderer>().enabled=false;
                leftHoleTrigger.GetComponent<SpriteRenderer>().enabled=false;
            }

            if(rightHoleActivated==true){
                rightHoleTrigger.GetComponent<SpriteRenderer>().enabled=true;
            } else if (rightHoleActivated==false){
                rightHoleTrigger.GetComponent<SpriteRenderer>().enabled=false;
            }

                //MaterialPropertyBlock block = new MaterialPropertyBlock();
                //block.AddTexture("_BLUE",blue);
                //upgradeDisplay.GetComponent<SpriteRenderer>().SetPropertyBlock(block);

                switch(counter) {
                case 1:
                    MaterialPropertyBlock block1 = new MaterialPropertyBlock();
                    block1.AddTexture("_BLUE",blue);
                    upgradeDisplay.GetComponent<SpriteRenderer>().SetPropertyBlock(block1);
                    break;

                case 2:
                    MaterialPropertyBlock block2 = new MaterialPropertyBlock();
                    block2.AddTexture("_RED",red);
                    upgradeDisplay.GetComponent<SpriteRenderer>().SetPropertyBlock(block2);
                    break;
                //case 3: upgradeDisplay.GetComponent<SpriteRenderer>().sprite.texture=green; break;
                //case 4: upgradeDisplay.GetComponent<SpriteRenderer>().sprite.texture=yellow; break;
                default:
                    MaterialPropertyBlock blockDef = new MaterialPropertyBlock();
                    blockDef.AddTexture("_YELLOW",yellow);
                    upgradeDisplay.GetComponent<SpriteRenderer>().SetPropertyBlock(blockDef);
                    break;
                }
            }
    }