當前位置: 首頁>>代碼示例>>C#>>正文


C# Material.SetTextureOffset方法代碼示例

本文整理匯總了C#中UnityEngine.Material.SetTextureOffset方法的典型用法代碼示例。如果您正苦於以下問題:C# Material.SetTextureOffset方法的具體用法?C# Material.SetTextureOffset怎麽用?C# Material.SetTextureOffset使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在UnityEngine.Material的用法示例。


在下文中一共展示了Material.SetTextureOffset方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: SetNewMaterial

    public void SetNewMaterial()
    {
        Renderer _renderer = GetComponent<Renderer>();
        Material newMat = new Material(Shader.Find("Diffuse"));
        //Material newMat = new Material(renderer.sharedMaterial);

        bool baseMaterialHaveNormalMap = _renderer.sharedMaterial.GetTexture("_BumpMap");
        bool baseMaterialHaveCubeMap = _renderer.sharedMaterial.GetTexture("_Cube");

        newMat.SetTexture("_MainTex", _renderer.sharedMaterial.GetTexture("_MainTex"));
        newMat.SetTextureOffset("_MainTex", offset);
        newMat.SetTextureScale("_MainTex", scale);

        if (baseMaterialHaveNormalMap)
        {
            newMat.SetTexture("_BumpMap", _renderer.sharedMaterial.GetTexture("_BumpMap"));
            newMat.SetTextureOffset("_BumpMap", offset);
            newMat.SetTextureScale("_BumpMap", scale);
        }
        if (baseMaterialHaveCubeMap)
        {
            newMat.SetTexture("_Cube", _renderer.sharedMaterial.GetTexture("_Cube"));
            newMat.SetTextureScale("_Cube", scale);
            newMat.SetTextureOffset("_Cube", offset);
        }

        newMat.color = materialColor;

        _renderer.sharedMaterial = newMat;
    }
開發者ID:FrenchKrab,項目名稱:aottg-assetbundleimporter,代碼行數:30,代碼來源:MaterialEditor.cs

示例2: Animate

        //internal void Animate(Material material, float time) {
        //    Vector2 textureOffset = new Vector2(xScrollSpeed * time % 1, yScrollSpeed * time % 1);
        //    material.SetTextureOffset(UnityConstants.MainDiffuseTexture, textureOffset);
        //    material.SetTextureOffset(UnityConstants.NormalMapTexture, textureOffset);
        //}

        internal void Animate(Material material, float deltaTime) {
            _x = (_x + (xScrollSpeed * deltaTime)) % 1;
            _y = (_y + (yScrollSpeed * deltaTime)) % 1;
            Vector2 textureOffset = new Vector2(_x, _y);
            material.SetTextureOffset(UnityConstants.MainDiffuseTexture, textureOffset);
            material.SetTextureOffset(UnityConstants.NormalMapTexture, textureOffset);
        }
開發者ID:Maxii,項目名稱:CodeEnv.Master,代碼行數:13,代碼來源:StarAnimator.cs

示例3: OnRestore

 public override void OnRestore()
 {
     if (_material = material)
     {
         _material.SetTextureOffset(propertyName, _original);
     }
 }
開發者ID:izaleu,項目名稱:Steamplane,代碼行數:7,代碼來源:TweenMaterialTextureOffset.cs

示例4: SetCurrentToFrom

 public void SetCurrentToFrom()
 {
     if (_material = material)
     {
         _material.SetTextureOffset(propertyName, from);
     }
 }
開發者ID:izaleu,項目名稱:Steamplane,代碼行數:7,代碼來源:TweenMaterialTextureOffset.cs

示例5: UpdateTile

    public void UpdateTile()
    {
        //Replace "GetNeighboursRaycast2D" with the method you want to use to find tile neirghbours
        GetNeighboursRaycast2D();

        SelectTile();

        if (!Application.isPlaying) {
            try {
                renderer.sharedMaterial.SetTextureScale("_BumpMap", new Vector2(1f/8f,1f/6f));
                renderer.sharedMaterial.SetTextureOffset("_BumpMap", new Vector2(1f/8f*sx,1f/6f*sy));
            } catch {}
        } else {
            try {
                var tempMaterial = new Material(renderer.sharedMaterial);
                tempMaterial.mainTexture=renderer.sharedMaterial.mainTexture;
                try {
                tempMaterial.SetTextureScale("_BumpMap", new Vector2(1f/8f,1f/6f));
                tempMaterial.SetTextureOffset("_BumpMap", new Vector2(1f/8f*sx,1f/6f*sy));
                } catch {}
                tempMaterial.shader=renderer.sharedMaterial.shader;
                renderer.sharedMaterial = tempMaterial;
            } catch {}
        }
    }
開發者ID:Krosantos,項目名稱:Time-Bubble,代碼行數:25,代碼來源:AutoTileSetQuad.cs

示例6: SetCurrentToTo

 public void SetCurrentToTo()
 {
     if (_material = material)
     {
         _material.SetTextureOffset(propertyName, to);
     }
 }
開發者ID:izaleu,項目名稱:Steamplane,代碼行數:7,代碼來源:TweenMaterialTextureOffset.cs

示例7: AnimateTracks

 void AnimateTracks(Material track, Transform[] wheels, float speed)
 {
     var offset = track.mainTextureOffset;
     offset.x += speed * Time.deltaTime;
     track.mainTextureOffset = offset;
     track.SetTextureOffset ("_BumpMap", offset);
     foreach (var w in wheels) {
         w.RotateAround (w.right, speed * Time.deltaTime * wheelSpeedFactor);
     }
 }
開發者ID:zukeru,項目名稱:gztanks,代碼行數:10,代碼來源:TankAnimator.cs

示例8: Apply

		public void Apply(ConfigNode node)
		{
			//create scaled material and set proprties to defaults
			scaledMaterial = new Material (Shaders.EmissiveScaled);
			scaledMaterial.SetTextureScale ("_EmissiveMap", Vector2.one);
			scaledMaterial.SetTextureOffset ("_EmissiveMap", Vector2.zero);
			scaledMaterial.SetColor ("_Color", new Color (1f, 1f, 1f));
			scaledMaterial.SetFloat ("_Brightness", 1.25f);
			scaledMaterial.SetFloat ("_Transparency", 0.75f);
		}
開發者ID:HappyFaceIndustries,項目名稱:KopernicusExpansion,代碼行數:10,代碼來源:EmissiveEffectsLoader.cs

示例9: OnTween

        public override void OnTween(float factor)
        {
            if (_material = material)
            {
                _temp = _material.GetTextureOffset(propertyName);

                if (mask.GetBit(0)) _temp.x = from.x + (to.x - from.x) * factor;
                if (mask.GetBit(1)) _temp.y = from.y + (to.y - from.y) * factor;

                _material.SetTextureOffset(propertyName, _temp);
            }
        }
開發者ID:izaleu,項目名稱:Steamplane,代碼行數:12,代碼來源:TweenMaterialTextureOffset.cs

示例10: RendererCache

			// Constructor
			public RendererCache(Renderer r, Material sharedOpaqueMaterial, float zTest, float stencilRef)
			{
				data = new List<Data>();
				renderer = r;
				go = r.gameObject;

				Material[] materials = r.sharedMaterials;

				if (materials != null)
				{
					for (int i = 0; i < materials.Length; i++)
					{
						Material sourceMat = materials[i];

						if (sourceMat == null) { continue; }

						Data d = new Data();
						
						string tag = sourceMat.GetTag("RenderType", true, "Opaque");
						if (tag == "Transparent" || tag == "TransparentCutout")
						{
							Material replacementMat = new Material(transparentShader);
							replacementMat.SetFloat(ShaderPropertyID._ZTest, zTest);
							replacementMat.SetFloat(ShaderPropertyID._StencilRef, stencilRef);
							if (sourceMat.HasProperty(ShaderPropertyID._MainTex))
							{
								replacementMat.SetTexture(ShaderPropertyID._MainTex, sourceMat.mainTexture);
								replacementMat.SetTextureOffset("_MainTex", sourceMat.mainTextureOffset);
								replacementMat.SetTextureScale("_MainTex", sourceMat.mainTextureScale);
							}
							
							int cutoff = ShaderPropertyID._Cutoff;
							replacementMat.SetFloat(cutoff, sourceMat.HasProperty(cutoff) ? sourceMat.GetFloat(cutoff) : transparentCutoff);

							d.material = replacementMat;
							d.transparent = true;
						}
						else
						{
							d.material = sharedOpaqueMaterial;
							d.transparent = false;
						}

						d.submeshIndex = i;
						data.Add(d);
					}
				}

				visible = IsVisible();
			}
開發者ID:sixeco,項目名稱:Unnoticed,代碼行數:51,代碼來源:RendererCache.cs

示例11: Initialize

        // int zTest, int stencilRef
        //
        public void Initialize(Material sharedOpaqueMaterial, Shader transparentShader)
        {
            data = new List<Data>();

            Material[] materials = r.sharedMaterials;

            if (materials != null)
            {
                for (int i = 0; i < materials.Length; i++)
                {
                    Material sourceMat = materials[i];

                    if (sourceMat == null) { continue; }

                    Data d = new Data();

                    string tag = sourceMat.GetTag(sRenderType, true, sOpaque);
                    if (tag == sTransparent || tag == sTransparentCutout)
                    {
                        Material replacementMat = new Material(transparentShader);
                        //replacementMat.SetInt(ShaderPropertyID._ZTest, zTest);
                        //replacementMat.SetInt(ShaderPropertyID._StencilRef, stencilRef);

                        // To render both sides of the Sprite
                        if (r is SpriteRenderer) { replacementMat.SetInt(ShaderPropertyID._Cull, cullOff); }

                        if (sourceMat.HasProperty(ShaderPropertyID._MainTex))
                        {
                            replacementMat.SetTexture(ShaderPropertyID._MainTex, sourceMat.mainTexture);
                            replacementMat.SetTextureOffset(sMainTex, sourceMat.mainTextureOffset);
                            replacementMat.SetTextureScale(sMainTex, sourceMat.mainTextureScale);
                        }

                        int cutoff = ShaderPropertyID._Cutoff;
                        replacementMat.SetFloat(cutoff, sourceMat.HasProperty(cutoff) ? sourceMat.GetFloat(cutoff) : transparentCutoff);

                        d.material = replacementMat;
                        d.transparent = true;
                    }
                    else
                    {
                        d.material = sharedOpaqueMaterial;
                        d.transparent = false;
                    }

                    d.submeshIndex = i;
                    data.Add(d);
                }
            }
        }
開發者ID:britg,項目名稱:triple-trope-demo,代碼行數:52,代碼來源:HighlighterRenderer.cs

示例12: ApplyValueLerp

 public static void ApplyValueLerp(AMMaterialTrack.ValueType valueType, string prop, int propId, Material mat, AMMaterialKey fromKey, AMMaterialKey toKey, float t)
 {
     switch(valueType) {
         case AMMaterialTrack.ValueType.Float:
         case AMMaterialTrack.ValueType.Range:
             mat.SetFloat(propId, Mathf.Lerp(fromKey.val, toKey.val, t));
             break;
         case AMMaterialTrack.ValueType.Vector:
             mat.SetVector(propId, Vector4.Lerp(fromKey.vector, toKey.vector, t));
             break;
         case AMMaterialTrack.ValueType.Color:
             mat.SetColor(propId, Color.Lerp(fromKey.color, toKey.color, t));
             break;
         case AMMaterialTrack.ValueType.TexOfs:
             mat.SetTextureOffset(prop, Vector2.Lerp(fromKey.texOfs, toKey.texOfs, t));
             break;
         case AMMaterialTrack.ValueType.TexScale:
             mat.SetTextureScale(prop, Vector2.Lerp(fromKey.texScale, toKey.texScale, t));
             break;
     }
 }
開發者ID:igrir,項目名稱:MateAnimator,代碼行數:21,代碼來源:AMMaterialKey.cs

示例13: InitDefaultVariables

    private void InitDefaultVariables()
    {
        currentRenderer = GetComponent<Renderer>();
        if (currentRenderer==null)
            throw new Exception("UvTextureAnimator can't get renderer");
        if (!currentRenderer.enabled)
            currentRenderer.enabled = true;
        allCount = 0;
        animationStoped = false;
        animationLifeTime = TilesX * TilesY / AnimationFPS;
        count = TilesY * TilesX;
        index = TilesX - 1;
        var offset = Vector3.zero;
        StartFrameOffset = StartFrameOffset - (StartFrameOffset / count) * count;
        var size = new Vector2(1f / TilesX, 1f / TilesY);

        if (currentRenderer!=null) {
            instanceMaterial = currentRenderer.material;
            instanceMaterial.SetTextureScale("_MainTex", size);
            instanceMaterial.SetTextureOffset("_MainTex", offset);
        }
    }
開發者ID:GroupByStudios,項目名稱:TDS_Gauss,代碼行數:22,代碼來源:ExplosionsSpriteSheetAnimation.cs

示例14: SetValues

	public void SetValues(Material m, IEnumerable<StoredValue> values)
	{
		foreach(var v in values)
		{
			switch(v.Property.type)
			{
			case MaterialProperty.PropertyType.color:
				m.SetColor(v.Property.name, (Color)v.Value);
				break;
			case MaterialProperty.PropertyType.real:
				m.SetFloat(v.Property.name, (float)v.Value);
				break;
			case MaterialProperty.PropertyType.texture:
				m.SetTexture(v.Property.name, (Texture)v.Value);
				break;
			case MaterialProperty.PropertyType.vector:
				m.SetVector(v.Property.name, (Vector4)v.Value);
				break;
			case MaterialProperty.PropertyType.textureOffset:
				m.SetTextureOffset(v.Property.name, (Vector2)v.Value);
				break;
			case MaterialProperty.PropertyType.textureScale:
				m.SetTextureScale(v.Property.name, (Vector2)v.Value);
				break;
			case MaterialProperty.PropertyType.matrix:
				m.SetMatrix(v.Property.name, (Matrix4x4)v.Value);
				break;
			}
		}
	}
開發者ID:MHaubenstock,項目名稱:RPG-Board-3D,代碼行數:30,代碼來源:StoreMaterials.cs

示例15: Start

 // Use this for initialization
 void Start()
 {
     characterSheet = renderer.material;
     characterSheet.SetTextureOffset("_MainTex", new Vector2(xOffset, yOffset));
 }
開發者ID:nhatpham,項目名稱:Fighter,代碼行數:6,代碼來源:WalkTest.cs


注:本文中的UnityEngine.Material.SetTextureOffset方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。