當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。