当前位置: 首页>>代码示例>>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;未经允许,请勿转载。