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


C# Material.SetTextureScale方法代码示例

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


在下文中一共展示了Material.SetTextureScale方法的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: Initialize

	public void Initialize(float nativeResolutionX, float nativeResolutionY, float ratio_scrWidth_To_bgWidth){
		transform.localScale = new Vector3(nativeResolutionX, nativeResolutionY, 1);
		transform.localPosition = new Vector3(nativeResolutionX / 2, nativeResolutionY / 2, 0);
		
		m_material = gameObject.renderer.material;
		m_material.SetTextureScale("_MainTex", new Vector2(0.5f, 1));
		m_material.SetTextureScale("_MainTex", new Vector2(ratio_scrWidth_To_bgWidth, 1));
	}
开发者ID:21garam,项目名称:SW_Maestro,代码行数:8,代码来源:BackGround.cs

示例3: SetCurrentToFrom

 public void SetCurrentToFrom()
 {
     if (_material = material)
     {
         _material.SetTextureScale(propertyName, from);
     }
 }
开发者ID:izaleu,项目名称:Steamplane,代码行数:7,代码来源:TweenMaterialTextureScale.cs

示例4: SetCurrentToTo

 public void SetCurrentToTo()
 {
     if (_material = material)
     {
         _material.SetTextureScale(propertyName, to);
     }
 }
开发者ID:izaleu,项目名称:Steamplane,代码行数:7,代码来源:TweenMaterialTextureScale.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: Awake

    void Awake()
    {
        _skyboxMaterial = RenderSettings.skybox;

        _skyboxMaterial.SetTextureScale("_BackTex", new Vector2(camera.pixelWidth / camera.pixelHeight, 1));
        SetOffset();
    }
开发者ID:Avatarchik,项目名称:Mind-Hero,代码行数:7,代码来源:ScrollingSkybox.cs

示例7: OnRestore

 public override void OnRestore()
 {
     if (_material = material)
     {
         _material.SetTextureScale(propertyName, _original);
     }
 }
开发者ID:izaleu,项目名称:Steamplane,代码行数:7,代码来源:TweenMaterialTextureScale.cs

示例8: OnStart

        public override void OnStart(PartModule.StartState state)
        {
            base.OnStart(state);
            print(System.Reflection.Assembly.GetExecutingAssembly().GetName().Version);

            _skinnedMeshRenderer = part.GetComponentInChildren<SkinnedMeshRenderer>();
            _trackSurface = _skinnedMeshRenderer.gameObject;
            _moduleWheel = part.GetComponentInChildren<KFModuleWheel>();

            if (HighLogic.LoadedSceneIsFlight && !Equals(vessel.vesselType, VesselType.Debris))
            {
                trackMaterial = _trackSurface.renderer.material;
                Vector2 trackTiling = trackMaterial.mainTextureScale;
                trackTiling = new Vector2(trackTiling.x * _moduleWheel.directionCorrector, trackTiling.y);
                trackMaterial.SetTextureScale("_MainTex", trackTiling);
                trackMaterial.SetTextureScale("_BumpMap", trackTiling);
            }
        }
开发者ID:Gaalidas,项目名称:KF_plugin,代码行数:18,代码来源:KFTrackSurface.cs

示例9: 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

示例10: Awake

    void Awake()
    {
        _material = GetComponent<Renderer>().material;

        _texture = _material.GetTexture(TexturePropertyName);
        _matSize = System.Math.Min(_texture.width, _texture.height);

        _material.SetTextureScale(TexturePropertyName, new Vector2(1f / ((float)XCells), 1f / ((float)YCells)));

        SetSpriteIndex(0);
    }
开发者ID:talford2,项目名称:SpaceX,代码行数:11,代码来源:SpriteAnimation.cs

示例11: OnTween

        public override void OnTween(float factor)
        {
            if (_material = material)
            {
                _temp = _material.GetTextureScale(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.SetTextureScale(propertyName, _temp);
            }
        }
开发者ID:izaleu,项目名称:Steamplane,代码行数:12,代码来源:TweenMaterialTextureScale.cs

示例12: 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

示例13: 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

示例14: Start

        public void Start()
        {
            var prop = internalProp;

            Cpu = part.GetComponent<kOSProcessor>().cpu;

            var size = 0.1f;
            var m = new Mesh();
            m.name = "Scripted_Plane_New_Mesh";
            m.vertices = new Vector3[] { new Vector3(size, -size, 0.01f), new Vector3(size, size, 0.01f), new Vector3(-size, size, 0.01f), new Vector3(-size, -size, 0.01f) };
            m.uv = new Vector2[] { new Vector2(0, 0.4f), new Vector2(0, 1), new Vector2(0.79f, 1), new Vector2(0.79f, 0.4f) };
            m.triangles = new int[] { 0, 1, 2, 0, 2, 3 };
            m.RecalculateNormals();

            MeshFilter mf = prop.FindModelComponents<MeshFilter>()[0];
            prop.FindModelComponents<MeshFilter>()[1].mesh = null;
            mf.mesh = m;

            screenGo = mf.gameObject;

            BoxCollider b = screenGo.GetComponent<BoxCollider>() ?? screenGo.AddComponent<BoxCollider>();
            ClickHandler handler = screenGo.GetComponent<ClickHandler>() ?? screenGo.AddComponent<ClickHandler>();
            handler.OnClick = OnMouseDown;

            foreach (MeshRenderer renderer in prop.FindModelComponents<MeshRenderer>())
            {
                Material mat = new Material(Shader.Find(" Diffuse"));
                mat.SetTexture("_MainTex", InternalDisplayTexture);
                mat.SetTextureScale("_MainTex", new Vector2(1, 1));

                renderer.material = mat;
            }

            foreach (PartModule module in part.Modules)
            {
                if (module is kOSProcessor)
                {
                    var k = (kOSProcessor)module;

                    k.InternalDisplayTexture = InternalDisplayTexture;
                }
            }
        }
开发者ID:Nivekk,项目名称:KOS,代码行数:43,代码来源:InternalDisplay.cs

示例15: 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


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